aboutsummaryrefslogtreecommitdiff
path: root/dht/krpc_test.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2018-02-15 11:42:34 +0000
committerFelix Hanley <felix@userspace.com.au>2018-02-15 11:42:40 +0000
commit32a655f042a3752d93c4507b4c128b21bf6aa602 (patch)
tree224c0d7e51efccac3b32dc5d0662baa2ab7304a5 /dht/krpc_test.go
parent2ded0704c8f675c3d92cf2b4874a32c65faf2553 (diff)
downloaddhtsearch-32a655f042a3752d93c4507b4c128b21bf6aa602.tar.gz
dhtsearch-32a655f042a3752d93c4507b4c128b21bf6aa602.tar.bz2
Refactor DHT code into separate package
Diffstat (limited to 'dht/krpc_test.go')
-rw-r--r--dht/krpc_test.go25
1 files changed, 25 insertions, 0 deletions
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)
+ }
+ }
+}