diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2019-01-09 14:05:55 +0800 |
---|---|---|
committer | Viktor Trón <viktor.tron@gmail.com> | 2019-01-09 14:05:55 +0800 |
commit | d70c4faf20d5533e30eec5cbb9b5180eb837b78c (patch) | |
tree | b059c20fa8093b6f8479a7706077cc24cdcaba0e /swarm/network/stream/intervals_test.go | |
parent | 81f04fa60608a67bac693879acbe086562d3970d (diff) | |
download | dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar.gz dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar.bz2 dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar.lz dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar.xz dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.tar.zst dexon-d70c4faf20d5533e30eec5cbb9b5180eb837b78c.zip |
swarm: Fix T.Fatal inside a goroutine in tests (#18409)
* swarm/storage: fix T.Fatal inside a goroutine
* swarm/network/simulation: fix T.Fatal inside a goroutine
* swarm/network/stream: fix T.Fatal inside a goroutine
* swarm/network/simulation: consistent failures in TestPeerEventsTimeout
* swarm/network/simulation: rename sendRunSignal to triggerSimulationRun
Diffstat (limited to 'swarm/network/stream/intervals_test.go')
-rw-r--r-- | swarm/network/stream/intervals_test.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/swarm/network/stream/intervals_test.go b/swarm/network/stream/intervals_test.go index 7c7feeb11..121758c18 100644 --- a/swarm/network/stream/intervals_test.go +++ b/swarm/network/stream/intervals_test.go @@ -19,9 +19,11 @@ package stream import ( "context" "encoding/binary" + "errors" "fmt" "os" "sync" + "sync/atomic" "testing" "time" @@ -117,7 +119,7 @@ func testIntervals(t *testing.T, live bool, history *Range, skipCheck bool) { t.Fatal(err) } - result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) error { + result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) (err error) { nodeIDs := sim.UpNodeIDs() storer := nodeIDs[0] checker := nodeIDs[1] @@ -162,11 +164,19 @@ func testIntervals(t *testing.T, live bool, history *Range, skipCheck bool) { return err } + var disconnected atomic.Value go func() { for d := range disconnections { if d.Error != nil { log.Error("peer drop", "node", d.NodeID, "peer", d.PeerID) - t.Fatal(d.Error) + disconnected.Store(true) + } + } + }() + defer func() { + if err != nil { + if yes, ok := disconnected.Load().(bool); ok && yes { + err = errors.New("disconnect events received") } } }() |