Skip to content

Commit 5ffaf88

Browse files
committed
test: eliminiated magic numbers in feature_csv_activation.py
1 parent 09f706a commit 5ffaf88

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/functional/feature_csv_activation.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
softfork_active,
5858
)
5959

60+
TESTING_TX_COUNT = 83 # Number of testing transactions: 1 BIP113 tx, 16 BIP68 txs, 66 BIP112 txs (see comments above)
61+
COINBASE_BLOCK_COUNT = TESTING_TX_COUNT # Number of coinbase blocks we need to generate as inputs for our txs
6062
BASE_RELATIVE_LOCKTIME = 10
6163
CSV_ACTIVATION_HEIGHT = 432
6264
SEQ_DISABLE_FLAG = 1 << 31
@@ -188,15 +190,16 @@ def run_test(self):
188190
self.log.info("Generate blocks in the past for coinbase outputs.")
189191
long_past_time = int(time.time()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future
190192
self.nodes[0].setmocktime(long_past_time - 100) # enough so that the generated blocks will still all be before long_past_time
191-
self.coinbase_blocks = self.nodes[0].generate(1 + 16 + 2 * 32 + 2) # 83 blocks generated for inputs
193+
self.coinbase_blocks = self.nodes[0].generate(COINBASE_BLOCK_COUNT) # blocks generated for inputs
192194
self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time
193-
self.tipheight = 83 # height of the next block to build
195+
self.tipheight = COINBASE_BLOCK_COUNT # height of the next block to build
194196
self.last_block_time = long_past_time
195197
self.tip = int(self.nodes[0].getbestblockhash(), 16)
196198
self.nodeaddress = self.nodes[0].getnewaddress()
197199

198200
# Activation height is hardcoded
199-
test_blocks = self.generate_blocks(344)
201+
# We advance to block height five below BIP112 activation for the following tests
202+
test_blocks = self.generate_blocks(CSV_ACTIVATION_HEIGHT-5 - COINBASE_BLOCK_COUNT)
200203
self.send_blocks(test_blocks)
201204
assert not softfork_active(self.nodes[0], 'csv')
202205

@@ -239,7 +242,7 @@ def run_test(self):
239242
self.tip = int(inputblockhash, 16)
240243
self.tipheight += 1
241244
self.last_block_time += 600
242-
assert_equal(len(self.nodes[0].getblock(inputblockhash, True)["tx"]), 83 + 1)
245+
assert_equal(len(self.nodes[0].getblock(inputblockhash, True)["tx"]), TESTING_TX_COUNT + 1)
243246

244247
# 2 more version 4 blocks
245248
test_blocks = self.generate_blocks(2)

0 commit comments

Comments
 (0)