aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/whisper_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-06-26 18:44:35 +0800
committerGitHub <noreply@github.com>2017-06-26 18:44:35 +0800
commitfeb29327066d6076d1802cdc1492d43a39cec276 (patch)
tree93f3231648b0f225c0c8d44bf81304282f93b605 /whisper/whisperv5/whisper_test.go
parentf321ed23fbaad8a13cc672f601b15f5272b4b2bb (diff)
parentea1d1825a8509b3353c535c9444861e15471942a (diff)
downloaddexon-feb29327066d6076d1802cdc1492d43a39cec276.tar
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.gz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.bz2
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.lz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.xz
dexon-feb29327066d6076d1802cdc1492d43a39cec276.tar.zst
dexon-feb29327066d6076d1802cdc1492d43a39cec276.zip
Merge pull request #14540 from bas-vk/whisper-api
whisperv5: integrate whisper and implement API
Diffstat (limited to 'whisper/whisperv5/whisper_test.go')
-rw-r--r--whisper/whisperv5/whisper_test.go48
1 files changed, 40 insertions, 8 deletions
diff --git a/whisper/whisperv5/whisper_test.go b/whisper/whisperv5/whisper_test.go
index 225728c42..145143833 100644
--- a/whisper/whisperv5/whisper_test.go
+++ b/whisper/whisperv5/whisper_test.go
@@ -18,13 +18,14 @@ package whisperv5
import (
"bytes"
+ "crypto/ecdsa"
mrand "math/rand"
"testing"
"time"
)
func TestWhisperBasic(t *testing.T) {
- w := New()
+ w := New(&DefaultConfig)
p := w.Protocols()
shh := p[0]
if shh.Name != ProtocolName {
@@ -117,8 +118,39 @@ func TestWhisperBasic(t *testing.T) {
}
}
+func TestWhisperAsymmetricKeyImport(t *testing.T) {
+ var (
+ w = New(&DefaultConfig)
+ privateKeys []*ecdsa.PrivateKey
+ )
+
+ for i := 0; i < 50; i++ {
+ id, err := w.NewKeyPair()
+ if err != nil {
+ t.Fatalf("could not generate key: %v", err)
+ }
+
+ pk, err := w.GetPrivateKey(id)
+ if err != nil {
+ t.Fatalf("could not export private key: %v", err)
+ }
+
+ privateKeys = append(privateKeys, pk)
+
+ if !w.DeleteKeyPair(id) {
+ t.Fatalf("could not delete private key")
+ }
+ }
+
+ for _, pk := range privateKeys {
+ if _, err := w.AddKeyPair(pk); err != nil {
+ t.Fatalf("could not import private key: %v", err)
+ }
+ }
+}
+
func TestWhisperIdentityManagement(t *testing.T) {
- w := New()
+ w := New(&DefaultConfig)
id1, err := w.NewKeyPair()
if err != nil {
t.Fatalf("failed to generate new key pair: %s.", err)
@@ -240,7 +272,7 @@ func TestWhisperSymKeyManagement(t *testing.T) {
var err error
var k1, k2 []byte
- w := New()
+ w := New(&DefaultConfig)
id1 := string("arbitrary-string-1")
id2 := string("arbitrary-string-2")
@@ -443,7 +475,7 @@ func TestWhisperSymKeyManagement(t *testing.T) {
func TestExpiry(t *testing.T) {
InitSingleTest()
- w := New()
+ w := New(&DefaultConfig)
w.SetMinimumPoW(0.0000001)
defer w.SetMinimumPoW(DefaultMinimumPoW)
w.Start(nil)
@@ -500,9 +532,9 @@ func TestExpiry(t *testing.T) {
func TestCustomization(t *testing.T) {
InitSingleTest()
- w := New()
+ w := New(&DefaultConfig)
defer w.SetMinimumPoW(DefaultMinimumPoW)
- defer w.SetMaxMessageLength(DefaultMaxMessageLength)
+ defer w.SetMaxMessageSize(DefaultMaxMessageSize)
w.Start(nil)
defer w.Stop()
@@ -547,13 +579,13 @@ func TestCustomization(t *testing.T) {
if err != nil {
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}
- w.SetMaxMessageLength(env.size() - 1)
+ w.SetMaxMessageSize(uint32(env.size() - 1))
err = w.Send(env)
if err == nil {
t.Fatalf("successfully sent oversized envelope (seed %d): false positive.", seed)
}
- w.SetMaxMessageLength(DefaultMaxMessageLength)
+ w.SetMaxMessageSize(DefaultMaxMessageSize)
err = w.Send(env)
if err != nil {
t.Fatalf("failed to send second envelope with seed %d: %s.", seed, err)