aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/envelope_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-20 19:56:38 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-28 15:47:35 +0800
commit7948cc0029db76557d6540341bdfeb818ce32c65 (patch)
treed4547188632e4f53878cc0d06d1e4da840f35b07 /whisper/envelope_test.go
parent5aa523e32bedd923c4075a21daefd1b4a512277c (diff)
downloadgo-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar.gz
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar.bz2
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar.lz
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar.xz
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.tar.zst
go-tangerine-7948cc0029db76557d6540341bdfeb818ce32c65.zip
rpc, whisper, xeth: fix RPC message retrieval data race
Diffstat (limited to 'whisper/envelope_test.go')
-rw-r--r--whisper/envelope_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/whisper/envelope_test.go b/whisper/envelope_test.go
new file mode 100644
index 000000000..ed1f08365
--- /dev/null
+++ b/whisper/envelope_test.go
@@ -0,0 +1,36 @@
+package whisper
+
+import (
+ "bytes"
+ "testing"
+)
+
+func TestEnvelopeOpen(t *testing.T) {
+ payload := []byte("hello world")
+ message := NewMessage(payload)
+
+ envelope, err := message.Wrap(DefaultPoW, Options{})
+ if err != nil {
+ t.Fatalf("failed to wrap message: %v", err)
+ }
+ opened, err := envelope.Open(nil)
+ if err != nil {
+ t.Fatalf("failed to open envelope: %v.", err)
+ }
+ if opened.Flags != message.Flags {
+ t.Fatalf("flags mismatch: have %d, want %d", opened.Flags, message.Flags)
+ }
+ if bytes.Compare(opened.Signature, message.Signature) != 0 {
+ t.Fatalf("signature mismatch: have 0x%x, want 0x%x", opened.Signature, message.Signature)
+ }
+ if bytes.Compare(opened.Payload, message.Payload) != 0 {
+ t.Fatalf("payload mismatch: have 0x%x, want 0x%x", opened.Payload, message.Payload)
+ }
+ if opened.Sent != message.Sent {
+ t.Fatalf("send time mismatch: have %d, want %d", opened.Sent, message.Sent)
+ }
+
+ if opened.Hash != envelope.Hash() {
+ t.Fatalf("message hash mismatch: have 0x%x, want 0x%x", opened.Hash, envelope.Hash())
+ }
+}