Title: Getting node 1 to mine a block, send it to node 2,and check node2 received it. Post by: decent1984 on July 31, 2021, 11:16:35 PM Hi There,
I am trying to write the code for the above requirement within the `example_test.py` in the functional test directory, This is the code I have written: Code: def run_test(self): Now, How can I test if it is actually happening [Getting node 1 to mine a block, send it to node 2,and check node2 received it.] or if I am just imagining all these things? Thanks again Noob. Title: Re: Getting node 1 to mine a block, send it to node 2,and check node2 received it. Post by: pooya87 on August 01, 2021, 05:13:13 AM You should only test your own code and behavior not what others do, meaning in this scenario you test that the connection is instantiated correctly, messages are constructed and sent correctly and things like that and you don't care if the other node received these messages or not.
But if you want to know I remember some full node clients sent back the inv message with the hash of the new block they just received and that could be an indication. You could also send them a getdata message requesting the block and see if they have it or not. Title: Re: Getting node 1 to mine a block, send it to node 2,and check node2 received it. Post by: NotATether on August 01, 2021, 06:45:48 PM Use this function p2port() (https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L314-L316):
Code: def p2p_port(n): to calculate the port number used by the bitcoind node number (the host is always 'localhost' and the node numbers increment from 0), then call getblockhash() on both nodes using curl or some other network client to see if two blocks were really generated. |