mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
p2p/simulations: add more test cases for ConnectNodesFull()
As I surprised myself it works even with 0 or 1 nodes.
This commit is contained in:
parent
7240f4d800
commit
566901f92d
1 changed files with 22 additions and 7 deletions
|
|
@ -125,15 +125,30 @@ func TestConnectToRandomNode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConnectNodesFull(t *testing.T) {
|
||||
net, ids := newTestNetwork(t, 12)
|
||||
defer net.Shutdown()
|
||||
|
||||
err := net.ConnectNodesFull(ids)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
tests := []struct {
|
||||
name string
|
||||
nodeCount int
|
||||
}{
|
||||
{name: "no node", nodeCount: 0},
|
||||
{name: "single node", nodeCount: 1},
|
||||
{name: "2 nodes", nodeCount: 2},
|
||||
{name: "3 nodes", nodeCount: 3},
|
||||
{name: "even number of nodes", nodeCount: 12},
|
||||
{name: "odd number of nodes", nodeCount: 13},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
net, ids := newTestNetwork(t, test.nodeCount)
|
||||
defer net.Shutdown()
|
||||
|
||||
VerifyFull(t, net, ids)
|
||||
err := net.ConnectNodesFull(ids)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
VerifyFull(t, net, ids)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConnectNodesChain(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue