(self)
| 94 | ]] |
| 95 | |
| 96 | def run_test(self): |
| 97 | node = self.nodes[0] # convenience reference to the node |
| 98 | |
| 99 | self.bootstrap_p2p() # Add one p2p connection to the node |
| 100 | |
| 101 | self.block_heights = {} |
| 102 | self.coinbase_key = ECKey() |
| 103 | self.coinbase_key.generate() |
| 104 | self.coinbase_pubkey = self.coinbase_key.get_pubkey().get_bytes() |
| 105 | self.tip = None |
| 106 | self.blocks = {} |
| 107 | self.genesis_hash = int(self.nodes[0].getbestblockhash(), 16) |
| 108 | self.block_heights[self.genesis_hash] = 0 |
| 109 | self.spendable_outputs = [] |
| 110 | |
| 111 | # Create a new block |
| 112 | b_dup_cb = self.next_block('dup_cb') |
| 113 | b_dup_cb.vtx[0].vin[0].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG |
| 114 | b_dup_cb.vtx[0].rehash() |
| 115 | duplicate_tx = b_dup_cb.vtx[0] |
| 116 | b_dup_cb = self.update_block('dup_cb', []) |
| 117 | self.send_blocks([b_dup_cb]) |
| 118 | |
| 119 | b0 = self.next_block(0) |
| 120 | self.save_spendable_output() |
| 121 | self.send_blocks([b0]) |
| 122 | |
| 123 | # These constants chosen specifically to trigger an immature coinbase spend |
| 124 | # at a certain time below. |
| 125 | NUM_BUFFER_BLOCKS_TO_GENERATE = 99 |
| 126 | NUM_OUTPUTS_TO_COLLECT = 33 |
| 127 | |
| 128 | # Allow the block to mature |
| 129 | blocks = [] |
| 130 | for i in range(NUM_BUFFER_BLOCKS_TO_GENERATE): |
| 131 | blocks.append(self.next_block(f"maturitybuffer.{i}")) |
| 132 | self.save_spendable_output() |
| 133 | self.send_blocks(blocks) |
| 134 | |
| 135 | # collect spendable outputs now to avoid cluttering the code later on |
| 136 | out = [] |
| 137 | for _ in range(NUM_OUTPUTS_TO_COLLECT): |
| 138 | out.append(self.get_spendable_output()) |
| 139 | |
| 140 | # Start by building a couple of blocks on top (which output is spent is |
| 141 | # in parentheses): |
| 142 | # genesis -> b1 (0) -> b2 (1) |
| 143 | b1 = self.next_block(1, spend=out[0]) |
| 144 | self.save_spendable_output() |
| 145 | |
| 146 | b2 = self.next_block(2, spend=out[1]) |
| 147 | self.save_spendable_output() |
| 148 | |
| 149 | self.send_blocks([b1, b2], timeout=4) |
| 150 | |
| 151 | # Select a txn with an output eligible for spending. This won't actually be spent, |
| 152 | # since we're testing submission of a series of blocks with invalid txns. |
| 153 | attempt_spend_tx = out[2] |
nothing calls this directly
no test coverage detected