aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/message_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-27 18:50:50 +0800
committerobscuren <geffobscura@gmail.com>2014-10-27 18:50:50 +0800
commit797b93c98cdd8183fca58f0c1c554b0d5af26d41 (patch)
tree10de24dc414b05cdb2a57dfa37db7e3f7a7c5605 /p2p/message_test.go
parentb095bd32371f02d204a4d0fbde75dc58baa7430d (diff)
parentf62b6742f2189f45463c362897e9f49a11d811a2 (diff)
downloadgo-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar.gz
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar.bz2
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar.lz
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar.xz
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.tar.zst
go-tangerine-797b93c98cdd8183fca58f0c1c554b0d5af26d41.zip
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'p2p/message_test.go')
-rw-r--r--p2p/message_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/p2p/message_test.go b/p2p/message_test.go
new file mode 100644
index 000000000..e9d46f2c3
--- /dev/null
+++ b/p2p/message_test.go
@@ -0,0 +1,38 @@
+package p2p
+
+import (
+ "testing"
+)
+
+func TestNewMsg(t *testing.T) {
+ msg, _ := NewMsg(3, 1, "000")
+ if msg.Code() != 3 {
+ t.Errorf("incorrect code %v", msg.Code())
+ }
+ data0 := msg.Data().Get(0).Uint()
+ data1 := string(msg.Data().Get(1).Bytes())
+ if data0 != 1 {
+ t.Errorf("incorrect data %v", data0)
+ }
+ if data1 != "000" {
+ t.Errorf("incorrect data %v", data1)
+ }
+}
+
+func TestEncodeDecodeMsg(t *testing.T) {
+ msg, _ := NewMsg(3, 1, "000")
+ encoded := msg.Encode(3)
+ msg, _ = NewMsgFromBytes(encoded)
+ msg.Decode(3)
+ if msg.Code() != 3 {
+ t.Errorf("incorrect code %v", msg.Code())
+ }
+ data0 := msg.Data().Get(0).Uint()
+ data1 := msg.Data().Get(1).Str()
+ if data0 != 1 {
+ t.Errorf("incorrect data %v", data0)
+ }
+ if data1 != "000" {
+ t.Errorf("incorrect data %v", data1)
+ }
+}