aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/message_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2014-11-25 23:01:39 +0800
committerFelix Lange <fjl@twurst.com>2014-11-25 23:01:39 +0800
commit9b85002b700500d421ba7e13ac2062a6b8090a83 (patch)
tree1cfa335fe194c391b946f9efb9760417729330ef /p2p/message_test.go
parentf816fdcb692d64cd5196b08c678550060e7e7df7 (diff)
downloaddexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar.gz
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar.bz2
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar.lz
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar.xz
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.tar.zst
dexon-9b85002b700500d421ba7e13ac2062a6b8090a83.zip
p2p: remove Msg.Value and MsgLoop
Diffstat (limited to 'p2p/message_test.go')
-rw-r--r--p2p/message_test.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/p2p/message_test.go b/p2p/message_test.go
index 0f51f759e..7b39b061d 100644
--- a/p2p/message_test.go
+++ b/p2p/message_test.go
@@ -29,8 +29,7 @@ func TestEncodeDecodeMsg(t *testing.T) {
if err := writeMsg(buf, msg); err != nil {
t.Fatalf("encodeMsg error: %v", err)
}
-
- t.Logf("encoded: %x", buf.Bytes())
+ // t.Logf("encoded: %x", buf.Bytes())
decmsg, err := readMsg(buf)
if err != nil {
@@ -42,18 +41,19 @@ func TestEncodeDecodeMsg(t *testing.T) {
if decmsg.Size != 5 {
t.Errorf("incorrect size %d, want %d", decmsg.Size, 5)
}
- data, err := decmsg.Value()
- if err != nil {
- t.Fatalf("first payload item decode error: %v", err)
+
+ var data struct {
+ I int
+ S string
}
- if v := data.Len(); v != 2 {
- t.Errorf("incorrect data.Len(): got %v, expected %d", v, 1)
+ if err := decmsg.Decode(&data); err != nil {
+ t.Fatalf("Decode error: %v", err)
}
- if v := data.Get(0).Uint(); v != 1 {
- t.Errorf("incorrect data[0]: got %v, expected %d", v, 1)
+ if data.I != 1 {
+ t.Errorf("incorrect data.I: got %v, expected %d", data.I, 1)
}
- if v := data.Get(1).Str(); v != "000" {
- t.Errorf("incorrect data[1]: got %q, expected %q", v, "000")
+ if data.S != "000" {
+ t.Errorf("incorrect data.S: got %q, expected %q", data.S, "000")
}
}