diff options
author | Ferenc Szabo <frncmx@gmail.com> | 2019-01-25 00:07:43 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2019-01-25 00:07:43 +0800 |
commit | 6167dd65b572c69fde5e4583b4c3a304fc83a544 (patch) | |
tree | ba33ea36475ddd1cb06e009748467bcd1f9eb4c8 | |
parent | 684facedb821d3026c870eaa80bc6bc9ec79c645 (diff) | |
download | go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar.gz go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar.bz2 go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar.lz go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar.xz go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.tar.zst go-tangerine-6167dd65b572c69fde5e4583b4c3a304fc83a544.zip |
swarm/pss: fix data race in notify_test.go (TestStart) (#18518)
-rw-r--r-- | swarm/pss/notify/notify_test.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/swarm/pss/notify/notify_test.go b/swarm/pss/notify/notify_test.go index 5c29f68e0..860a91bbe 100644 --- a/swarm/pss/notify/notify_test.go +++ b/swarm/pss/notify/notify_test.go @@ -128,7 +128,7 @@ func TestStart(t *testing.T) { defer rightSub.Unsubscribe() updateC := make(chan []byte) - updateMsg := []byte{} + var updateMsg []byte ctrlClient := NewController(psses[rightPub]) ctrlNotifier := NewController(psses[leftPub]) ctrlNotifier.NewNotifier("foo.eth", 2, updateC) @@ -145,17 +145,24 @@ func TestStart(t *testing.T) { if err != nil { t.Fatal(err) } + + copyOfUpdateMsg := make([]byte, len(updateMsg)) + copy(copyOfUpdateMsg, updateMsg) + ctrlClientError := make(chan error, 1) ctrlClient.Subscribe(rsrcName, pubkey, addrbytes, func(s string, b []byte) error { - if s != "foo.eth" || !bytes.Equal(updateMsg, b) { - t.Fatalf("unexpected result in client handler: '%s':'%x'", s, b) + if s != "foo.eth" || !bytes.Equal(copyOfUpdateMsg, b) { + ctrlClientError <- fmt.Errorf("unexpected result in client handler: '%s':'%x'", s, b) + } else { + log.Info("client handler receive", "s", s, "b", b) } - log.Info("client handler receive", "s", s, "b", b) return nil }) var inMsg *pss.APIMsg select { case inMsg = <-rmsgC: + case err := <-ctrlClientError: + t.Fatal(err) case <-ctx.Done(): t.Fatal(ctx.Err()) } |