diff options
author | Ivan Daniluk <ivan.daniluk@gmail.com> | 2018-05-08 23:05:27 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-08 23:05:27 +0800 |
commit | c4a4613d9504db43a26a3c79dda8bf6be0d1237a (patch) | |
tree | a9bb552bddbb3fe3ecc795768b376f5b99104e16 /p2p/simulations/adapters/ws_test.go | |
parent | fedae9501582cb64c850def557b1fc3742d892dc (diff) | |
download | dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar.gz dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar.bz2 dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar.lz dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar.xz dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.tar.zst dexon-c4a4613d9504db43a26a3c79dda8bf6be0d1237a.zip |
p2p/simulations/adapters: fix websocket log line parsing in exec adapter (#16667)
Diffstat (limited to 'p2p/simulations/adapters/ws_test.go')
-rw-r--r-- | p2p/simulations/adapters/ws_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/p2p/simulations/adapters/ws_test.go b/p2p/simulations/adapters/ws_test.go new file mode 100644 index 000000000..0bb9ed2b2 --- /dev/null +++ b/p2p/simulations/adapters/ws_test.go @@ -0,0 +1,21 @@ +package adapters + +import ( + "bytes" + "testing" + "time" +) + +func TestFindWSAddr(t *testing.T) { + line := `t=2018-05-02T19:00:45+0200 lvl=info msg="WebSocket endpoint opened" node.id=26c65a606d1125a44695bc08573190d047152b6b9a776ccbbe593e90f91444d9c1ebdadac6a775ad9fdd0923468a1d698ed3a842c1fb89c1bc0f9d4801f8c39c url=ws://127.0.0.1:59975` + buf := bytes.NewBufferString(line) + got, err := findWSAddr(buf, 10*time.Second) + if err != nil { + t.Fatalf("Failed to find addr: %v", err) + } + expected := `ws://127.0.0.1:59975` + + if got != expected { + t.Fatalf("Expected to get '%s', but got '%s'", expected, got) + } +} |