aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/mailserver/server_test.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-04-10 05:49:22 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-10 05:49:22 +0800
commit9cd713551627a9b48e04a77f64a15ea6f829dcf4 (patch)
treef1849e61cd8269dfe9c70861f49216cf78acec3b /whisper/mailserver/server_test.go
parent8570ef19eb8dfe4e2a450525c589dec291f3a517 (diff)
downloaddexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.gz
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.bz2
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.lz
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.xz
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.tar.zst
dexon-9cd713551627a9b48e04a77f64a15ea6f829dcf4.zip
whisper: big refactoring (#13852)
* whisper: GetMessages fixed; size restriction updated * whisper: made PoW and MaxMsgSize customizable * whisper: test added * whisper: sym key management changed * whisper: identity management refactored * whisper: API refactoring (Post and Filter) * whisper: big refactoring complete * whisper: spelling fix * whisper: variable topic size allowed for a filter * whisper: final update * whisper: formatting * whisper: file exchange introduced in wnode * whisper: bugfix * whisper: API updated + new tests * whisper: statistics updated * whisper: wnode server updated * whisper: allowed filtering for variable topic size * whisper: tests added * whisper: resolving merge conflicts * whisper: refactoring (documenting mostly) * whsiper: tests fixed * whisper: down cased error messages * whisper: documenting the API functions * whisper: logging fixed * whisper: fixed wnode parameters * whisper: logs fixed (typos)
Diffstat (limited to 'whisper/mailserver/server_test.go')
-rw-r--r--whisper/mailserver/server_test.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/whisper/mailserver/server_test.go b/whisper/mailserver/server_test.go
index 8b58a826f..ffdff3191 100644
--- a/whisper/mailserver/server_test.go
+++ b/whisper/mailserver/server_test.go
@@ -30,8 +30,8 @@ import (
)
const powRequirement = 0.00001
-const keyName = "6d604bac5401ce9a6b995f1b45a4ab"
+var keyID string
var shh *whisper.Whisper
var seed = time.Now().Unix()
@@ -90,7 +90,7 @@ func TestMailServer(t *testing.T) {
server.Init(shh, dir, password, powRequirement)
defer server.Close()
- err = shh.AddSymKey(keyName, []byte(password))
+ keyID, err = shh.AddSymKeyFromPassword(password)
if err != nil {
t.Fatalf("Failed to create symmetric key for mail request: %s", err)
}
@@ -102,7 +102,14 @@ func TestMailServer(t *testing.T) {
}
func deliverTest(t *testing.T, server *WMailServer, env *whisper.Envelope) {
- testPeerID := shh.NewIdentity()
+ id, err := shh.NewKeyPair()
+ if err != nil {
+ t.Fatalf("failed to generate new key pair with seed %d: %s.", seed, err)
+ }
+ testPeerID, err := shh.GetPrivateKey(id)
+ if err != nil {
+ t.Fatalf("failed to retrieve new key pair with seed %d: %s.", seed, err)
+ }
birth := env.Expiry - env.TTL
p := &ServerTestParams{
topic: env.Topic,
@@ -167,8 +174,13 @@ func createRequest(t *testing.T, p *ServerTestParams) *whisper.Envelope {
binary.BigEndian.PutUint32(data[4:], p.upp)
copy(data[8:], p.topic[:])
+ key, err := shh.GetSymKey(keyID)
+ if err != nil {
+ t.Fatalf("failed to retrieve sym key with seed %d: %s.", seed, err)
+ }
+
params := &whisper.MessageParams{
- KeySym: shh.GetSymKey(keyName),
+ KeySym: key,
Topic: p.topic,
Payload: data,
PoW: powRequirement * 2,