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:
Ferenc Szabo 2018-12-19 14:05:32 +01:00
parent 7240f4d800
commit 566901f92d

View file

@ -125,7 +125,20 @@ func TestConnectToRandomNode(t *testing.T) {
} }
func TestConnectNodesFull(t *testing.T) { func TestConnectNodesFull(t *testing.T) {
net, ids := newTestNetwork(t, 12) 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() defer net.Shutdown()
err := net.ConnectNodesFull(ids) err := net.ConnectNodesFull(ids)
@ -134,6 +147,8 @@ func TestConnectNodesFull(t *testing.T) {
} }
VerifyFull(t, net, ids) VerifyFull(t, net, ids)
})
}
} }
func TestConnectNodesChain(t *testing.T) { func TestConnectNodesChain(t *testing.T) {