17 print(
"Initializing test directory "+self.options.tmpdir)
28 print "Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:" 29 print "Mine 4 blocks on Node 0" 34 print "Mine competing 6 blocks on Node 1" 38 print "Connect nodes to force a reorg" 44 print "Invalidate block 2 on node 0 and verify we reorg to node 0's original chain" 48 if (newheight != 4
or newhash != besthash):
49 raise AssertionError(
"Wrong tip for node0, hash %s, height %d"%(newhash,newheight))
51 print "\nMake sure we won't reorg to a lower work chain:" 53 print "Sync node 2 to node 1 so both have 6 blocks" 56 print "Invalidate block 5 on node 1 so its tip is now at 4" 59 print "Invalidate block 3 on node 2, so its tip is now 2" 62 print "..and then mine a block" 64 print "Verify all nodes are at the right height" 72 raise AssertionError(
"Node 1 reorged to a lower height: %d"%node1height)
74 if __name__ ==
'__main__':
UniValue getblockhash(const UniValue ¶ms, bool fHelp)
UniValue getblockcount(const UniValue ¶ms, bool fHelp)
def initialize_chain_clean(test_dir, num_nodes)
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
UniValue generate(const UniValue ¶ms, bool fHelp)
def sync_blocks(rpc_connections, wait=1)
UniValue getbestblockhash(const UniValue ¶ms, bool fHelp)
def connect_nodes_bi(nodes, a, b)