Created
September 28, 2020 15:24
-
-
Save jarolrod/06bf6146ea82e9dbb95c92ab5a820163 to your computer and use it in GitHub Desktop.
Code Snippet to accomplish sub-deliverable on the example 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
# Chaincode Labs Fall Study Group Sub-Deliverable | |
# Current Tips should be the same | |
node0Tip = int(self.nodes[0].getbestblockhash(), 16) | |
node1Tip = int(self.nodes[1].getbestblockhash(), 16) | |
assert(node0Tip == node1Tip) | |
# Generate new block on node[0] | |
# Use generate() rpc call in order to get new block | |
oldBlockTip = node0Tip | |
self.log.info("Generate a new block on node[0].") | |
newBlockTip = int(self.nodes[0].generate(nblocks=1)[0], 16) | |
# Check that node[0]'s old and new block tip are different | |
# This signals a succesful new block | |
self.log.info("Check that new Block was successful.") | |
assert (not (oldBlockTip == newBlockTip)) | |
# Generate() should have already synced node0 and node 1 | |
self.log.info("Check that node[1] has recieved the block from node[0].") | |
node1Tip = int(self.nodes[1].getbestblockhash(), 16) | |
assert (newBlockTip == node1Tip) | |
# Check for succesful send | |
self.log.info("Check that node[0] has sent the block to node[1]") | |
node0Tip = int(self.nodes[0].getbestblockhash(), 16) | |
node1Tip = int(self.nodes[1].getbestblockhash(), 16) | |
assert(node0Tip == node1Tip) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment