Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

whisper/whisperv6: fix staticcheck warnings #20328

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions whisper/whisperv6/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func InitSingleTest() {
mrand.Seed(seed)
}

func InitDebugTest(i int64) {
seed = i
mrand.Seed(seed)
}

type FilterTestCase struct {
f *Filter
id string
Expand Down Expand Up @@ -309,8 +304,7 @@ func TestMatchEnvelope(t *testing.T) {
if err != nil {
t.Fatalf("failed to create new message with seed %d: %s.", seed, err)
}
env, err := msg.Wrap(params)
if err != nil {
if _, err = msg.Wrap(params); err != nil {
t.Fatalf("failed Wrap with seed %d: %s.", seed, err)
}

Expand All @@ -322,7 +316,7 @@ func TestMatchEnvelope(t *testing.T) {
if err != nil {
t.Fatalf("failed to create new message with seed %d: %s.", seed, err)
}
env, err = msg.Wrap(params)
env, err := msg.Wrap(params)
if err != nil {
t.Fatalf("failed Wrap() with seed %d: %s.", seed, err)
}
Expand Down
22 changes: 1 addition & 21 deletions whisper/whisperv6/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
mrand "math/rand"
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -74,7 +73,6 @@ var keys = []string{
}

type TestData struct {
started int64
counter [NumNodes]int
mutex sync.RWMutex
}
Expand Down Expand Up @@ -212,13 +210,10 @@ func initialize(t *testing.T) {
},
}

go startServer(t, node.server)

startServer(t, node.server)
nodes[i] = &node
}

waitForServersToStart(t)

for i := 0; i < NumNodes; i++ {
for j := 0; j < i; j++ {
peerNodeId := nodes[j].id
Expand All @@ -234,8 +229,6 @@ func startServer(t *testing.T, s *p2p.Server) {
if err != nil {
t.Fatalf("failed to start the first server. err: %v", err)
}

atomic.AddInt64(&result.started, 1)
}

func stopServers() {
Expand Down Expand Up @@ -494,19 +487,6 @@ func checkBloomFilterExchange(t *testing.T) {
}
}

func waitForServersToStart(t *testing.T) {
const iterations = 200
var started int64
for j := 0; j < iterations; j++ {
time.Sleep(50 * time.Millisecond)
started = atomic.LoadInt64(&result.started)
if started == NumNodes {
return
}
}
t.Fatalf("Failed to start all the servers, running: %d", started)
}

//two generic whisper node handshake
func TestPeerHandshakeWithTwoFullNode(t *testing.T) {
w1 := Whisper{}
Expand Down