16 In this test we connect to one node over p2p, and test block requests: 17 1) Valid blocks should be requested and become chain tip. 18 2) Invalid block with duplicated transaction should be re-requested. 19 3) Invalid block with bad coinbase value should be rejected and not 26 ''' Can either run this test as 1 node with expected answers, or two and compare them. 27 Change the "outcome" variable from each TestInstance object to only do the comparison. ''' 33 test.add_all_connections(self.
nodes)
46 Create a new block with an anyone-can-spend coinbase 54 self.
tip = block.sha256
59 Now we need that block to mature so we can spend the coinbase. 65 self.
tip = block.sha256
67 test.blocks_and_transactions.append([block,
True])
72 Now we use merkle-root malleability to generate an invalid block with 74 Manufacture a block with 3 transactions (coinbase, spend of prior 75 coinbase, spend of that spend). Duplicate the 3rd transaction to 76 leave merkle root and blockheader unchanged but invalidate the block. 85 block2.vtx.extend([tx1, tx2])
86 block2.hashMerkleRoot = block2.calc_merkle_root()
89 orig_hash = block2.sha256
90 block2_orig = copy.deepcopy(block2)
93 block2.vtx.append(tx2)
94 assert_equal(block2.hashMerkleRoot, block2.calc_merkle_root())
96 assert(block2_orig.vtx != block2.vtx)
98 self.
tip = block2.sha256
103 Make sure that a totally screwed up block is not valid. 107 block3.vtx[0].vout[0].nValue = 1000 * COIN
108 block3.vtx[0].sha256=
None 109 block3.vtx[0].calc_sha256()
110 block3.hashMerkleRoot = block3.calc_merkle_root()
117 if __name__ ==
'__main__':
def sync_masternodes(rpc_connections)
UniValue getbestblockhash(const UniValue ¶ms, bool fHelp)
def assert_equal(thing1, thing2)