aboutsummaryrefslogtreecommitdiffstats
path: root/whisper
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-15 17:50:10 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-15 17:50:10 +0800
commit46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf (patch)
tree16fc077080f7b723c737aa7f8b759a14e7c66575 /whisper
parentbcf41797cacac35879d6bc153d3e4ce3cd9896f0 (diff)
downloaddexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar.gz
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar.bz2
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar.lz
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar.xz
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.tar.zst
dexon-46ea193a49f60bb54cd5fc083adcc6fdf58dbdaf.zip
whisper: remove some unneeded testing complexity
Diffstat (limited to 'whisper')
-rw-r--r--whisper/common_test.go29
-rw-r--r--whisper/peer_test.go5
-rw-r--r--whisper/whisper_test.go3
3 files changed, 5 insertions, 32 deletions
diff --git a/whisper/common_test.go b/whisper/common_test.go
index 76e6463e6..a5df762e1 100644
--- a/whisper/common_test.go
+++ b/whisper/common_test.go
@@ -4,40 +4,11 @@ package whisper
import (
"bytes"
- "fmt"
"io/ioutil"
- "math/rand"
- "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
)
-// randomNodeID generates and returns a random P2P discovery node id for the
-// whisper tests.
-func randomNodeID() (id discover.NodeID) {
- for i := range id {
- id[i] = byte(rand.Intn(255))
- }
- return id
-}
-
-// randomNodeName generates and returns a random P2P node name for the whisper
-// tests.
-func randomNodeName() string {
- return common.MakeName(fmt.Sprintf("whisper-go-test-%3d", rand.Intn(999)), "1.0")
-}
-
-// whisperCaps returns the node capabilities for running the whisper sub-protocol.
-func whisperCaps() []p2p.Cap {
- return []p2p.Cap{
- p2p.Cap{
- Name: protocolName,
- Version: uint(protocolVersion),
- },
- }
-}
-
// bufMsgPipe creates a buffered message pipe between two endpoints.
func bufMsgPipe() (*p2p.MsgPipeRW, *p2p.MsgPipeRW) {
A, midA := p2p.MsgPipe()
diff --git a/whisper/peer_test.go b/whisper/peer_test.go
index 5f24504da..53aff7c55 100644
--- a/whisper/peer_test.go
+++ b/whisper/peer_test.go
@@ -5,6 +5,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/p2p/discover"
)
type testPeer struct {
@@ -15,7 +16,7 @@ type testPeer struct {
func startTestPeer() *testPeer {
// Create a simulated P2P remote peer and data streams to it
- remote := p2p.NewPeer(randomNodeID(), randomNodeName(), whisperCaps())
+ remote := p2p.NewPeer(discover.NodeID{}, "", nil)
tester, tested := p2p.MsgPipe()
// Create a whisper client and connect with it to the tester peer
@@ -30,7 +31,7 @@ func startTestPeer() *testPeer {
client.handlePeer(remote, tested)
}()
- // Assemble and return the test peer
+
return &testPeer{
client: client,
stream: tester,
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go
index c072ba26b..35e2f0524 100644
--- a/whisper/whisper_test.go
+++ b/whisper/whisper_test.go
@@ -5,13 +5,14 @@ import (
"time"
"github.com/ethereum/go-ethereum/p2p"
+ "github.com/ethereum/go-ethereum/p2p/discover"
)
func startTestCluster(n int) []*Whisper {
// Create the batch of simulated peers
nodes := make([]*p2p.Peer, n)
for i := 0; i < n; i++ {
- nodes[i] = p2p.NewPeer(randomNodeID(), randomNodeName(), whisperCaps())
+ nodes[i] = p2p.NewPeer(discover.NodeID{}, "", nil)
}
whispers := make([]*Whisper, n)
for i := 0; i < n; i++ {