Skip to content

Commit

Permalink
Ensure the channel wrapper is always updated correctly with the node id
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelawless committed Sep 21, 2020
1 parent 4dce125 commit 37a52b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nano/core_test/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,14 @@ TEST (network, replace_port)
auto wrong_endpoint = nano::endpoint (node1->network.endpoint ().address (), 23000);
auto channel0 (node0->network.udp_channels.insert (wrong_endpoint, node1->network_params.protocol.protocol_version));
ASSERT_NE (nullptr, channel0);
channel0->set_node_id (node1->node_id.pub);
node0->network.udp_channels.modify (channel0, [&node1](std::shared_ptr<nano::transport::channel> channel_a) {
channel_a->set_node_id (node1->node_id.pub);
});
auto peers_list (node0->network.list (std::numeric_limits<size_t>::max ()));
ASSERT_EQ (peers_list[0]->get_node_id (), node1->node_id.pub);
auto channel1 (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.protocol.protocol_version));
ASSERT_EQ (node0->network.udp_channels.size (), 1);
node0->network.send_keepalive (channel1);
node0->network.udp_channels.modify (channel0, [](auto) {});
// On handshake, the channel is replaced
ASSERT_TIMELY (5s, !node0->network.udp_channels.channel (wrong_endpoint) && node0->network.udp_channels.channel (node1->network.endpoint ()));
}
Expand Down

0 comments on commit 37a52b9

Please # to comment.