Skip to content

Commit 7bc3698

Browse files
committed
chore: test new validation of asset unlocks tests after fork 'withdrawals'
1 parent 37e8d69 commit 7bc3698

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

test/functional/feature_asset_locks.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
assert_equal,
3939
assert_greater_than,
4040
assert_greater_than_or_equal,
41+
softfork_active,
4142
)
4243
from test_framework.wallet_util import bytes_to_wif
4344

@@ -274,6 +275,7 @@ def run_test(self):
274275
self.test_asset_unlocks(node_wallet, node, pubkey)
275276
self.test_withdrawal_limits(node_wallet, node, pubkey)
276277
self.test_mn_rr(node_wallet, node, pubkey)
278+
self.test_withdrawal_fork(node_wallet, node, pubkey)
277279

278280

279281
def test_asset_locks(self, node_wallet, node, pubkey):
@@ -439,8 +441,9 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
439441
self.log.info("Checking that two quorums later it is too late because quorum is not active...")
440442
self.mine_quorum_2_nodes(llmq_type_name='llmq_test_platform', llmq_type=106)
441443
self.log.info("Expecting new reject-reason...")
444+
assert not softfork_active(self.nodes[0], 'withdrawals')
442445
self.check_mempool_result(tx=asset_unlock_tx_too_late,
443-
result_expected={'allowed': False, 'reject-reason' : 'bad-assetunlock-not-active-quorum'})
446+
result_expected={'allowed': False, 'reject-reason' : 'bad-assetunlock-too-old-quorum'})
444447

445448
block_to_reconsider = node.getbestblockhash()
446449
self.log.info("Test block invalidation with asset unlock tx...")
@@ -454,7 +457,8 @@ def test_asset_unlocks(self, node_wallet, node, pubkey):
454457
self.validate_credit_pool_balance(locked - 2 * COIN)
455458

456459
self.log.info("Forcibly mining asset_unlock_tx_too_late and ensure block is invalid")
457-
self.create_and_check_block([asset_unlock_tx_too_late], expected_error = "bad-assetunlock-not-active-quorum")
460+
assert not softfork_active(self.nodes[0], 'withdrawals')
461+
self.create_and_check_block([asset_unlock_tx_too_late], expected_error = "bad-assetunlock-too-old-quorum")
458462

459463
node.generate(1)
460464
self.sync_all()
@@ -657,6 +661,30 @@ def test_mn_rr(self, node_wallet, node, pubkey):
657661
self.sync_all()
658662
assert_equal(locked, self.get_credit_pool_balance())
659663

664+
def test_withdrawal_fork(self, node_wallet, node, pubkey):
665+
self.log.info("Testing asset unlock after 'withdrawal' activation...")
666+
667+
assert softfork_active(self.nodes[0], 'withdrawals')
668+
self.log.info("Generating several txes by same quorum....")
669+
670+
asset_unlock_tx = self.create_assetunlock(401, COIN, pubkey)
671+
asset_unlock_tx_payload = CAssetUnlockTx()
672+
asset_unlock_tx_payload.deserialize(BytesIO(asset_unlock_tx.vExtraPayload))
673+
674+
self.log.info("Check that new Asset Unlock is valid for current quorum")
675+
self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
676+
677+
while asset_unlock_tx_payload.quorumHash in node.quorum('list')['llmq_test_platform']:
678+
self.log.info(f"Generate one more quorum until signing quorum becomes not available")
679+
self.mine_quorum(llmq_type_name="llmq_test_platform", llmq_type=106)
680+
681+
self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}})
682+
683+
self.log.info(f"Generate one more quorum after which asset unlock meant to be expired")
684+
self.mine_quorum(llmq_type_name="llmq_test_platform", llmq_type=106)
685+
self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': False, 'reject-reason': 'bad-assetunlock-too-old-quorum'})
686+
687+
660688

661689
if __name__ == '__main__':
662690
AssetLocksTest().main()

0 commit comments

Comments
 (0)