Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
46ea193a
Commit
46ea193a
authored
Apr 15, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: remove some unneeded testing complexity
parent
bcf41797
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
32 deletions
+5
-32
common_test.go
whisper/common_test.go
+0
-29
peer_test.go
whisper/peer_test.go
+3
-2
whisper_test.go
whisper/whisper_test.go
+2
-1
No files found.
whisper/common_test.go
View file @
46ea193a
...
@@ -4,40 +4,11 @@ package whisper
...
@@ -4,40 +4,11 @@ package whisper
import
(
import
(
"bytes"
"bytes"
"fmt"
"io/ioutil"
"io/ioutil"
"math/rand"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p"
"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.
// bufMsgPipe creates a buffered message pipe between two endpoints.
func
bufMsgPipe
()
(
*
p2p
.
MsgPipeRW
,
*
p2p
.
MsgPipeRW
)
{
func
bufMsgPipe
()
(
*
p2p
.
MsgPipeRW
,
*
p2p
.
MsgPipeRW
)
{
A
,
midA
:=
p2p
.
MsgPipe
()
A
,
midA
:=
p2p
.
MsgPipe
()
...
...
whisper/peer_test.go
View file @
46ea193a
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"time"
"time"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
)
)
type
testPeer
struct
{
type
testPeer
struct
{
...
@@ -15,7 +16,7 @@ type testPeer struct {
...
@@ -15,7 +16,7 @@ type testPeer struct {
func
startTestPeer
()
*
testPeer
{
func
startTestPeer
()
*
testPeer
{
// Create a simulated P2P remote peer and data streams to it
// 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
()
tester
,
tested
:=
p2p
.
MsgPipe
()
// Create a whisper client and connect with it to the tester peer
// Create a whisper client and connect with it to the tester peer
...
@@ -30,7 +31,7 @@ func startTestPeer() *testPeer {
...
@@ -30,7 +31,7 @@ func startTestPeer() *testPeer {
client
.
handlePeer
(
remote
,
tested
)
client
.
handlePeer
(
remote
,
tested
)
}()
}()
// Assemble and return the test peer
return
&
testPeer
{
return
&
testPeer
{
client
:
client
,
client
:
client
,
stream
:
tester
,
stream
:
tester
,
...
...
whisper/whisper_test.go
View file @
46ea193a
...
@@ -5,13 +5,14 @@ import (
...
@@ -5,13 +5,14 @@ import (
"time"
"time"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
)
)
func
startTestCluster
(
n
int
)
[]
*
Whisper
{
func
startTestCluster
(
n
int
)
[]
*
Whisper
{
// Create the batch of simulated peers
// Create the batch of simulated peers
nodes
:=
make
([]
*
p2p
.
Peer
,
n
)
nodes
:=
make
([]
*
p2p
.
Peer
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
i
:=
0
;
i
<
n
;
i
++
{
nodes
[
i
]
=
p2p
.
NewPeer
(
randomNodeID
(),
randomNodeName
(),
whisperCaps
()
)
nodes
[
i
]
=
p2p
.
NewPeer
(
discover
.
NodeID
{},
""
,
nil
)
}
}
whispers
:=
make
([]
*
Whisper
,
n
)
whispers
:=
make
([]
*
Whisper
,
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
i
:=
0
;
i
<
n
;
i
++
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment