Remove flaky tests

This commit is contained in:
Andrea Maria Piana 2021-09-14 12:19:29 +01:00
parent bd1e6b0033
commit 93497f4644
1 changed files with 0 additions and 100 deletions

View File

@ -232,106 +232,6 @@ func (s *WakuTestSuite) TestMessagesResponseWithError() {
s.Require().Len(w1.Envelopes(), 1) s.Require().Len(w1.Envelopes(), 1)
} }
func (s *WakuTestSuite) testConfirmationEvents(envelope common.Envelope, envelopeErrors []common.EnvelopeError) {
conf := &Config{
MinimumAcceptedPoW: 0,
MaxMessageSize: 10 << 20,
EnableConfirmations: true,
}
w1 := New(conf, nil)
w2 := New(conf, nil)
events := make(chan common.EnvelopeEvent, 2)
sub := w1.SubscribeEnvelopeEvents(events)
defer sub.Unsubscribe()
rw1, rw2 := p2p.MsgPipe()
p1 := s.newPeer(w1, p2p.NewPeer(enode.ID{1}, "1", []p2p.Cap{{"waku", 0}}), rw2, nil, s.stats)
p2 := s.newPeer(w2, p2p.NewPeer(enode.ID{2}, "2", []p2p.Cap{{"waku", 0}}), rw1, nil, s.stats)
errorc := make(chan error, 1)
go func() { errorc <- w1.HandlePeer(p1, rw2) }()
timer := time.AfterFunc(5*time.Second, func() {
if err := rw1.Close(); err != nil {
s.T().Errorf("error closing MsgPipe 1, '%s'", err)
}
if err := rw2.Close(); err != nil {
s.T().Errorf("error closing MsgPipe 2, '%s'", err)
}
})
// Start peer
err := p2.Start()
s.Require().NoError(err)
// And run mainloop
go func() { errorc <- p2.Run() }()
w1.addEnvelope(&envelope)
var e1, e2 *common.EnvelopeEvent
var count int
for count < 2 {
select {
case ev := <-events:
switch ev.Event {
case common.EventEnvelopeSent:
if e1 == nil {
e1 = &ev
count++
}
case common.EventBatchAcknowledged:
if e2 == nil {
e2 = &ev
count++
}
}
case <-time.After(5 * time.Second):
s.Require().FailNow("timed out waiting for an envelope.sent event")
}
}
s.Require().Equal(p1.EnodeID(), e1.Peer)
s.Require().NotEqual(gethcommon.Hash{}, e1.Batch)
s.Require().Equal(p1.EnodeID(), e2.Peer)
s.Require().Equal(e1.Batch, e2.Batch)
s.Require().Equal(envelopeErrors, e2.Data)
s.Require().NoError(rw1.Close())
s.Require().NoError(rw2.Close())
timer.Stop()
}
func (s *WakuTestSuite) TestConfirmationEventsReceived() {
e := common.Envelope{
Expiry: uint32(time.Now().Add(10 * time.Second).Unix()),
TTL: 10,
Topic: common.TopicType{1},
Data: make([]byte, 1<<10),
Nonce: 1,
}
s.testConfirmationEvents(e, []common.EnvelopeError{})
}
func (s *WakuTestSuite) TestConfirmationEventsExtendedWithErrors() {
e := common.Envelope{
Expiry: uint32(time.Now().Unix()) - 4*common.DefaultSyncAllowance,
TTL: 10,
Topic: common.TopicType{1},
Data: make([]byte, 1<<10),
Nonce: 1,
}
s.testConfirmationEvents(e, []common.EnvelopeError{
{
Hash: e.Hash(),
Code: common.EnvelopeTimeNotSynced,
Description: "very old envelope",
}},
)
}
func (s *WakuTestSuite) TestEventsWithoutConfirmation() { func (s *WakuTestSuite) TestEventsWithoutConfirmation() {
conf := &Config{ conf := &Config{
MinimumAcceptedPoW: 0, MinimumAcceptedPoW: 0,