aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-09 18:16:06 +0800
committerFelix Lange <fjl@twurst.com>2017-01-09 23:24:42 +0800
commitb9b3efb09f9281a5859646d2dcf36b5813132efb (patch)
treef9dc8f9d82108b33bec4669b09a99d06d24239a9 /whisper
parent0f34d506b5ae9b76de97318c906e56dddd5309f6 (diff)
downloaddexon-b9b3efb09f9281a5859646d2dcf36b5813132efb.tar.gz
dexon-b9b3efb09f9281a5859646d2dcf36b5813132efb.tar.zst
dexon-b9b3efb09f9281a5859646d2dcf36b5813132efb.zip
all: fix ineffectual assignments and remove uses of crypto.Sha3
go get github.com/gordonklaus/ineffassign ineffassign .
Diffstat (limited to 'whisper')
-rw-r--r--whisper/whisperv2/envelope_test.go2
-rw-r--r--whisper/whisperv5/filter.go2
-rw-r--r--whisper/whisperv5/message_test.go4
-rw-r--r--whisper/whisperv5/whisper_test.go18
4 files changed, 9 insertions, 17 deletions
diff --git a/whisper/whisperv2/envelope_test.go b/whisper/whisperv2/envelope_test.go
index c1b128c61..490ed9f6f 100644
--- a/whisper/whisperv2/envelope_test.go
+++ b/whisper/whisperv2/envelope_test.go
@@ -47,7 +47,7 @@ func TestEnvelopeOpen(t *testing.T) {
t.Fatalf("payload mismatch: have 0x%x, want 0x%x", opened.Payload, message.Payload)
}
if opened.Sent.Unix() != message.Sent.Unix() {
- t.Fatalf("send time mismatch: have %d, want %d", opened.Sent, message.Sent)
+ t.Fatalf("send time mismatch: have %v, want %v", opened.Sent, message.Sent)
}
if opened.TTL/time.Second != DefaultTTL/time.Second {
t.Fatalf("message TTL mismatch: have %v, want %v", opened.TTL, DefaultTTL)
diff --git a/whisper/whisperv5/filter.go b/whisper/whisperv5/filter.go
index 3845d0c20..a386aa164 100644
--- a/whisper/whisperv5/filter.go
+++ b/whisper/whisperv5/filter.go
@@ -86,7 +86,7 @@ func (fs *Filters) NotifyWatchers(env *Envelope, p2pMessage bool) {
continue
}
- match := false
+ var match bool
if msg != nil {
match = watcher.MatchMessage(msg)
} else {
diff --git a/whisper/whisperv5/message_test.go b/whisper/whisperv5/message_test.go
index 3eb71653d..7c90f59c0 100644
--- a/whisper/whisperv5/message_test.go
+++ b/whisper/whisperv5/message_test.go
@@ -77,10 +77,8 @@ func singleMessageTest(t *testing.T, symmetric bool) {
text := make([]byte, 0, 512)
steg := make([]byte, 0, 512)
- raw := make([]byte, 0, 1024)
text = append(text, params.Payload...)
steg = append(steg, params.Padding...)
- raw = append(raw, params.Padding...)
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
@@ -238,10 +236,8 @@ func singleEnvelopeOpenTest(t *testing.T, symmetric bool) {
text := make([]byte, 0, 512)
steg := make([]byte, 0, 512)
- raw := make([]byte, 0, 1024)
text = append(text, params.Payload...)
steg = append(steg, params.Padding...)
- raw = append(raw, params.Padding...)
msg := NewSentMessage(params)
env, err := msg.Wrap(params)
diff --git a/whisper/whisperv5/whisper_test.go b/whisper/whisperv5/whisper_test.go
index dbe0627fa..b9cd9b1a0 100644
--- a/whisper/whisperv5/whisper_test.go
+++ b/whisper/whisperv5/whisper_test.go
@@ -50,20 +50,17 @@ func TestWhisperBasic(t *testing.T) {
peerID := make([]byte, 64)
randomize(peerID)
- peer, err := w.getPeer(peerID)
+ peer, _ := w.getPeer(peerID)
if peer != nil {
- t.Fatalf("failed GetPeer.")
+ t.Fatal("found peer for random key.")
}
- err = w.MarkPeerTrusted(peerID)
- if err == nil {
+ if err := w.MarkPeerTrusted(peerID); err == nil {
t.Fatalf("failed MarkPeerTrusted.")
}
- err = w.RequestHistoricMessages(peerID, peerID)
- if err == nil {
+ if err := w.RequestHistoricMessages(peerID, peerID); err == nil {
t.Fatalf("failed RequestHistoricMessages.")
}
- err = w.SendP2PMessage(peerID, nil)
- if err == nil {
+ if err := w.SendP2PMessage(peerID, nil); err == nil {
t.Fatalf("failed SendP2PMessage.")
}
exist := w.HasSymKey("non-existing")
@@ -85,11 +82,10 @@ func TestWhisperBasic(t *testing.T) {
var derived []byte
ver := uint64(0xDEADBEEF)
- derived, err = deriveKeyMaterial(peerID, ver)
- if err != unknownVersionError(ver) {
+ if _, err := deriveKeyMaterial(peerID, ver); err != unknownVersionError(ver) {
t.Fatalf("failed deriveKeyMaterial with param = %v: %s.", peerID, err)
}
- derived, err = deriveKeyMaterial(peerID, 0)
+ derived, err := deriveKeyMaterial(peerID, 0)
if err != nil {
t.Fatalf("failed second deriveKeyMaterial with param = %v: %s.", peerID, err)
}