Skip to content

Commit 8728a66

Browse files
committed
[tests] fix block time in feature_pruning.py
1 parent dc5c2e4 commit 8728a66

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/functional/feature_pruning.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ def mine_large_blocks(node, n):
2828
# followed by 950k of OP_NOP. This would be non-standard in a non-coinbase
2929
# transaction but is consensus valid.
3030

31+
# Set the nTime if this is the first time this function has been called.
32+
# A static variable ensures that time is monotonicly increasing and is therefore
33+
# different for each block created => blockhash is unique.
34+
if "nTimes" not in mine_large_blocks.__dict__:
35+
mine_large_blocks.nTime = 0
36+
3137
# Get the block parameters for the first block
3238
big_script = CScript([OP_RETURN] + [OP_NOP] * 950000)
3339
best_block = node.getblock(node.getbestblockhash())
3440
height = int(best_block["height"]) + 1
35-
try:
36-
# Static variable ensures that time is monotonicly increasing and is therefore
37-
# different for each block created => blockhash is unique.
38-
mine_large_blocks.nTime = min(mine_large_blocks.nTime, int(best_block["time"])) + 1
39-
except AttributeError:
40-
mine_large_blocks.nTime = int(best_block["time"]) + 1
41+
mine_large_blocks.nTime = max(mine_large_blocks.nTime, int(best_block["time"])) + 1
4142
previousblockhash = int(best_block["hash"], 16)
4243

4344
for _ in range(n):

0 commit comments

Comments
 (0)