Skip to content

Commit 5531119

Browse files
committed
Added new test for future blocks reacceptance
Adds a test case for checking reacceptance a previously rejected block that was too far in the future.
1 parent 511a5af commit 5531119

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/functional/feature_block.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,21 @@ def run_test(self):
700700
self.send_blocks([b55], True)
701701
self.save_spendable_output()
702702

703+
# The block which was previously rejected because of being "too far(3 hours)" must be accepted 2 hours later.
704+
# The new block is only 1 hour into future now and we must reorg onto to the new longer chain.
705+
# The new bestblock b48p is invalidated manually.
706+
# -> b31 (8) -> b33 (9) -> b35 (10) -> b39 (11) -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15)
707+
# \-> b54 (15)
708+
# -> b44 (14)\-> b48 () -> b48p ()
709+
self.log.info("Accept a previously rejected future block at a later time")
710+
node.setmocktime(int(time.time()) + 2*60*60)
711+
self.move_tip(48)
712+
self.block_heights[b48.sha256] = self.block_heights[b44.sha256] + 1 # b48 is a parent of b44
713+
b48p = self.next_block("48p")
714+
self.send_blocks([b48, b48p], success=True) # Reorg to the longer chain
715+
node.invalidateblock(b48p.hash) # mark b48p as invalid
716+
node.setmocktime(0)
717+
703718
# Test Merkle tree malleability
704719
#
705720
# -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57p2 (16)

0 commit comments

Comments
 (0)