Hello,
I have a question on the heartbeat mechanism in Test_HW2_Scenario.
In the test setup, we have the following comments:
// at least every peer will send a heartbeat message on start,
// which will make everyone to have an entry in its routing
// table to every one else, thanks to the antientropy.
In my previous implementation of the heartbeat mechanism, it will start a goroutine when we call Start() on the node. The goroutine searches for a random neighbor and periodically sends the heartbeat message.
In this test, the nodes will start automatically when we initiate them, for example,
nodeA := z.NewTestNode(t, peerFac, transp, "127.0.0.1:0", opts...)
This means that only after the nodes have already started, the routing tables are updated with AddPeer() function.
I tried to run with this setup, and it is very likely that when the nodes try to send the first heartbeat message, they cannot find any neighbor because the routing tables are updated later.
My question is: how can we ensure what is said in the comments that "at least every peer will send a heartbeat message on start", considering AddPeer() is called later? A hack would be to wait for, say 1 second, and then trigger the heartbeat when starting the node, but I guess this is not intended.
Best,
Wanhao