Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_block.py
Show First 20 Lines • Show All 996 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tx.vout.append(CTxOut(0, script_output)) | tx.vout.append(CTxOut(0, script_output)) | ||||
tx.vin.append(CTxIn(COutPoint(b.vtx[1].sha256, 0))) | tx.vin.append(CTxIn(COutPoint(b.vtx[1].sha256, 0))) | ||||
b = self.update_block(i, [tx]) | b = self.update_block(i, [tx]) | ||||
assert_equal(len(b.serialize()), LEGACY_MAX_BLOCK_SIZE) | assert_equal(len(b.serialize()), LEGACY_MAX_BLOCK_SIZE) | ||||
blocks.append(b) | blocks.append(b) | ||||
self.save_spendable_output() | self.save_spendable_output() | ||||
spend = self.get_spendable_output() | spend = self.get_spendable_output() | ||||
self.sync_blocks(blocks, True, timeout=180) | self.sync_blocks(blocks, True, timeout=960) | ||||
chain1_tip = i | chain1_tip = i | ||||
# now create alt chain of same length | # now create alt chain of same length | ||||
self.move_tip(88) | self.move_tip(88) | ||||
blocks2 = [] | blocks2 = [] | ||||
for i in range(89, LARGE_REORG_SIZE + 89): | for i in range(89, LARGE_REORG_SIZE + 89): | ||||
blocks2.append(self.next_block("alt" + str(i))) | blocks2.append(self.next_block("alt" + str(i))) | ||||
self.sync_blocks(blocks2, False, request_block=False) | self.sync_blocks(blocks2, False, request_block=False) | ||||
# extend alt chain to trigger re-org | # extend alt chain to trigger re-org | ||||
block = self.next_block("alt" + str(chain1_tip + 1)) | block = self.next_block("alt" + str(chain1_tip + 1)) | ||||
self.sync_blocks([block], True, timeout=180) | self.sync_blocks([block], True, timeout=960) | ||||
# ... and re-org back to the first chain | # ... and re-org back to the first chain | ||||
self.move_tip(chain1_tip) | self.move_tip(chain1_tip) | ||||
block = self.next_block(chain1_tip + 1) | block = self.next_block(chain1_tip + 1) | ||||
self.sync_blocks([block], False, request_block=False) | self.sync_blocks([block], False, request_block=False) | ||||
block = self.next_block(chain1_tip + 2) | block = self.next_block(chain1_tip + 2) | ||||
self.sync_blocks([block], True, timeout=180) | self.sync_blocks([block], True, timeout=960) | ||||
# Helper methods | # Helper methods | ||||
################ | ################ | ||||
def add_transactions_to_block(self, block, tx_list): | def add_transactions_to_block(self, block, tx_list): | ||||
[tx.rehash() for tx in tx_list] | [tx.rehash() for tx in tx_list] | ||||
block.vtx.extend(tx_list) | block.vtx.extend(tx_list) | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |