Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-p2p-compactblocks.py
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
return TestInstance([[self.tip, False]]) | return TestInstance([[self.tip, False]]) | ||||
else: | else: | ||||
return TestInstance([[self.tip, reject]]) | return TestInstance([[self.tip, reject]]) | ||||
# move the tip back to a previous block | # move the tip back to a previous block | ||||
def tip(number): | def tip(number): | ||||
self.tip = self.blocks[number] | self.tip = self.blocks[number] | ||||
# adds transactions to the block and updates state | |||||
def update_block(block_number, new_transactions): | |||||
block = self.blocks[block_number] | |||||
self.add_transactions_to_block(block, new_transactions) | |||||
old_sha256 = block.sha256 | |||||
make_conform_to_ctor(block) | |||||
block.hashMerkleRoot = block.calc_merkle_root() | |||||
block.solve() | |||||
# Update the internal state just like in next_block | |||||
self.tip = block | |||||
if block.sha256 != old_sha256: | |||||
self.block_heights[ | |||||
block.sha256] = self.block_heights[old_sha256] | |||||
del self.block_heights[old_sha256] | |||||
self.blocks[block_number] = block | |||||
return block | |||||
# shorthand for functions | # shorthand for functions | ||||
block = self.next_block | block = self.next_block | ||||
# Create a new block | # Create a new block | ||||
block(0) | block(0) | ||||
save_spendable_output() | save_spendable_output() | ||||
yield accepted() | yield accepted() | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |