Created
August 27, 2021 18:43
-
-
Save jurraca/f3c0fe1ca277fb3053d13f0800925974 to your computer and use it in GitHub Desktop.
Chaincode Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_test(self): | |
# ... lines 138-208 | |
self.log.info("Mine another block, and check that node 2 receives it") | |
# setup p2p connection for node 1 | |
peer_messaging = self.nodes[1].add_p2p_connection(BaseNode()) | |
# create new block | |
new_block = create_block(self.tip, create_coinbase(height+1), self.block_time) | |
new_block.solve() | |
# broadcast the block message | |
block_message = msg_block(new_block) | |
peer_messaging.send_message(block_message) | |
# update state | |
self.tip = new_block.sha256 | |
blocks.append(self.tip) | |
self.block_time += 1 | |
height += 1 | |
self.nodes[1].waitforblockheight(height) | |
# request block message based on chain tip | |
getdata_request = msg_getdata() | |
getdata_request.inv.append(CInv(MSG_BLOCK, blocks[-1])) | |
peer_receiving.send_message(getdata_request) | |
# assert that node 2 received all the blocks. | |
peer_receiving.wait_until(lambda: sorted(blocks) == sorted(list(peer_receiving.block_receive_map.keys())), timeout=5) | |
# rest of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment