Пример #1
0
func TestRemoveTransportsFromNode(t *testing.T) {
	nodeManager := &NodeManager{Port: 7100}
	defer nodeManager.CloseAll()
	nodeManager.CreateNodeConfigList(10)
	nodeManager.ConnectNodes()

	pubKey := nodeManager.PubKeyList[4]
	configFrom := nodeManager.ConfigList[pubKey]
	node := nodeManager.NodesList[pubKey]

	assert.Len(t, node.GetTransports(), 2, "Error expected 2 transport in the node")

	config := CreateTestConfig(nodeManager.Port)
	nodeManager.Port += 100
	ConnectNodeToNode(configFrom, config)
	AddPeersToNode(node, *config)

	assert.Len(t, node.GetTransports(), 3, "Error expected 3 transport in the node")

	config2 := CreateTestConfig(nodeManager.Port)
	nodeManager.Port += 100
	ConnectNodeToNode(configFrom, config2)
	AddPeersToNode(node, *config2)

	assert.Len(t, node.GetTransports(), 4, "Error expected 4 transport in the node")

	transport := node.GetTransports()[0]

	nodeManager.RemoveTransportsFromNode(4, transport)

	assert.Len(t, node.GetTransports(), 3, "Error expected 3 transport in the node")
}
Пример #2
0
func TestAddTransportsToNode(t *testing.T) {
	nodeManager := &NodeManager{Port: 5100}
	defer nodeManager.CloseAll()
	nodeManager.CreateNodeConfigList(10)
	nodeManager.ConnectNodes()

	config := CreateTestConfig(nodeManager.Port)
	nodeManager.Port += 100

	pubKey := nodeManager.PubKeyList[1]
	configFrom := nodeManager.ConfigList[pubKey]
	node := nodeManager.NodesList[pubKey]

	assert.Len(t, node.GetTransports(), 2, "Error expected 2 transport in the node")

	ConnectNodeToNode(configFrom, config)
	AddPeersToNode(node, *config)

	assert.Len(t, node.GetTransports(), 3, "Error expected 3 transport in the node")

	config2 := CreateTestConfig(nodeManager.Port)

	pubKey2 := nodeManager.PubKeyList[3]
	configFrom2 := nodeManager.ConfigList[pubKey2]
	node2 := nodeManager.NodesList[pubKey2]

	assert.Len(t, node2.GetTransports(), 2, "Error expected 2 transport in the node2")

	ConnectNodeToNode(configFrom2, config2)
	AddPeersToNode(node2, *config2)

	assert.Len(t, node2.GetTransports(), 3, "Error expected 3 transport in the node2")
}
Пример #3
0
func TestGetTransportsFromNode(t *testing.T) {
	nodeManager := &NodeManager{Port: 6100}
	defer nodeManager.CloseAll()
	nodeManager.CreateNodeConfigList(10)
	nodeManager.ConnectNodes()

	pubKey := nodeManager.PubKeyList[2]
	node := nodeManager.NodesList[pubKey]

	assert.Len(t, node.GetTransports(), 2, "Error expected 2 transport in the node")
}