aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/common_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-14 23:21:56 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-14 23:21:56 +0800
commit86372b20c0995abe0343ce5f453be113e5f192d0 (patch)
tree12050e8bf3a532dd4ee1c1275e4738949f42854c /whisper/common_test.go
parentf6efdd8aad96db24f29268b4393e95644dbbd18a (diff)
downloaddexon-86372b20c0995abe0343ce5f453be113e5f192d0.tar.gz
dexon-86372b20c0995abe0343ce5f453be113e5f192d0.tar.zst
dexon-86372b20c0995abe0343ce5f453be113e5f192d0.zip
whisper: add basic tests for the whiper peers
Diffstat (limited to 'whisper/common_test.go')
-rw-r--r--whisper/common_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/whisper/common_test.go b/whisper/common_test.go
new file mode 100644
index 000000000..8c12f8aeb
--- /dev/null
+++ b/whisper/common_test.go
@@ -0,0 +1,38 @@
+// Contains some common utility functions for testing.
+
+package whisper
+
+import (
+ "fmt"
+ "math/rand"
+
+ "github.com/ethereum/go-ethereum/p2p"
+
+ "github.com/ethereum/go-ethereum/common"
+ "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),
+ },
+ }
+}