From 32a655f042a3752d93c4507b4c128b21bf6aa602 Mon Sep 17 00:00:00 2001 From: Felix Hanley Date: Thu, 15 Feb 2018 22:42:34 +1100 Subject: Refactor DHT code into separate package --- dht/krpc_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dht/krpc_test.go (limited to 'dht/krpc_test.go') diff --git a/dht/krpc_test.go b/dht/krpc_test.go new file mode 100644 index 0000000..d710678 --- /dev/null +++ b/dht/krpc_test.go @@ -0,0 +1,25 @@ +package dht + +import ( + "testing" +) + +func TestStringToCompactNodeInfo(t *testing.T) { + + tests := []struct { + in string + out []byte + }{ + {in: "192.168.1.1:6881", out: []byte("asdfasdf")}, + } + + for _, tt := range tests { + r, err := stringToCompactNodeInfo(tt.in) + if err != nil { + t.Errorf("stringToCompactNodeInfo failed with %s", err) + } + if r != tt.out { + t.Errorf("stringToCompactNodeInfo(%s) => %s, expected %s", tt.in, r, tt.out) + } + } +} -- cgit v1.2.3