aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/message_test.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-01-31 18:16:20 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-01-31 18:16:20 +0800
commit690f6ea1d74f949d4830d3a38c786510fc43d37c (patch)
treef60153a53bc05fabf8981a9a5d9868033fdae209 /whisper/whisperv5/message_test.go
parent1c140f73820e2a915dcc61eccaeca7ea359cf07b (diff)
downloaddexon-690f6ea1d74f949d4830d3a38c786510fc43d37c.tar.gz
dexon-690f6ea1d74f949d4830d3a38c786510fc43d37c.tar.zst
dexon-690f6ea1d74f949d4830d3a38c786510fc43d37c.zip
cmd/wnode, whisper: add whisper CLI tool and mail server (#3580)
Diffstat (limited to 'whisper/whisperv5/message_test.go')
-rw-r--r--whisper/whisperv5/message_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/whisper/whisperv5/message_test.go b/whisper/whisperv5/message_test.go
index 7c90f59c0..c6f1ca2ca 100644
--- a/whisper/whisperv5/message_test.go
+++ b/whisper/whisperv5/message_test.go
@@ -22,6 +22,7 @@ import (
"testing"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/rlp"
)
func copyFromBuf(dst []byte, src []byte, beg int) int {
@@ -311,3 +312,35 @@ func TestEncryptWithZeroKey(t *testing.T) {
t.Fatalf("wrapped with nil key, seed: %d.", seed)
}
}
+
+func TestRlpEncode(t *testing.T) {
+ InitSingleTest()
+
+ params, err := generateMessageParams()
+ if err != nil {
+ t.Fatalf("failed generateMessageParams with seed %d: %s.", seed, err)
+ }
+ msg := NewSentMessage(params)
+ env, err := msg.Wrap(params)
+ if err != nil {
+ t.Fatalf("wrapped with zero key, seed: %d.", seed)
+ }
+
+ raw, err := rlp.EncodeToBytes(env)
+ if err != nil {
+ t.Fatalf("RLP encode failed: %s.", err)
+ }
+
+ var decoded Envelope
+ rlp.DecodeBytes(raw, &decoded)
+ if err != nil {
+ t.Fatalf("RLP decode failed: %s.", err)
+ }
+
+ he := env.Hash()
+ hd := decoded.Hash()
+
+ if he != hd {
+ t.Fatalf("Hashes are not equal: %x vs. %x", he, hd)
+ }
+}