From 4a473a1763437a288b7f50c9a8b6690566f922ca Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 19 Sep 2024 03:50:44 +0700 Subject: [PATCH] chore: test new validation of asset unlocks tests after fork 'withdrawals' --- test/functional/feature_asset_locks.py | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/test/functional/feature_asset_locks.py b/test/functional/feature_asset_locks.py index 930415ee81d4f5..8a5321a0e6894a 100755 --- a/test/functional/feature_asset_locks.py +++ b/test/functional/feature_asset_locks.py @@ -38,6 +38,7 @@ assert_equal, assert_greater_than, assert_greater_than_or_equal, + softfork_active, ) from test_framework.wallet_util import bytes_to_wif @@ -274,6 +275,7 @@ def run_test(self): self.test_asset_unlocks(node_wallet, node, pubkey) self.test_withdrawal_limits(node_wallet, node, pubkey) self.test_mn_rr(node_wallet, node, pubkey) + self.test_withdrawal_fork(node_wallet, node, pubkey) def test_asset_locks(self, node_wallet, node, pubkey): @@ -439,8 +441,9 @@ def test_asset_unlocks(self, node_wallet, node, pubkey): self.log.info("Checking that two quorums later it is too late because quorum is not active...") self.mine_quorum_2_nodes(llmq_type_name='llmq_test_platform', llmq_type=106) self.log.info("Expecting new reject-reason...") + assert not softfork_active(self.nodes[0], 'withdrawals') self.check_mempool_result(tx=asset_unlock_tx_too_late, - result_expected={'allowed': False, 'reject-reason' : 'bad-assetunlock-not-active-quorum'}) + result_expected={'allowed': False, 'reject-reason' : 'bad-assetunlock-too-old-quorum'}) block_to_reconsider = node.getbestblockhash() self.log.info("Test block invalidation with asset unlock tx...") @@ -454,7 +457,8 @@ def test_asset_unlocks(self, node_wallet, node, pubkey): self.validate_credit_pool_balance(locked - 2 * COIN) self.log.info("Forcibly mining asset_unlock_tx_too_late and ensure block is invalid") - self.create_and_check_block([asset_unlock_tx_too_late], expected_error = "bad-assetunlock-not-active-quorum") + assert not softfork_active(self.nodes[0], 'withdrawals') + self.create_and_check_block([asset_unlock_tx_too_late], expected_error = "bad-assetunlock-too-old-quorum") node.generate(1) self.sync_all() @@ -657,6 +661,30 @@ def test_mn_rr(self, node_wallet, node, pubkey): self.sync_all() assert_equal(locked, self.get_credit_pool_balance()) + def test_withdrawal_fork(self, node_wallet, node, pubkey): + self.log.info("Testing asset unlock after 'withdrawal' activation...") + + assert softfork_active(self.nodes[0], 'withdrawals') + self.log.info("Generating several txes by same quorum....") + + asset_unlock_tx = self.create_assetunlock(401, COIN, pubkey) + asset_unlock_tx_payload = CAssetUnlockTx() + asset_unlock_tx_payload.deserialize(BytesIO(asset_unlock_tx.vExtraPayload)) + + self.log.info("Check that new Asset Unlock is valid for current quorum") + self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}}) + + while asset_unlock_tx_payload.quorumHash in node.quorum('list')['llmq_test_platform']: + self.log.info(f"Generate one more quorum until signing quorum becomes not available") + self.mine_quorum(llmq_type_name="llmq_test_platform", llmq_type=106) + + self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': True, 'fees': {'base': Decimal(str(tiny_amount / COIN))}}) + + self.log.info(f"Generate one more quorum after which asset unlock meant to be expired") + self.mine_quorum(llmq_type_name="llmq_test_platform", llmq_type=106) + self.check_mempool_result(tx=asset_unlock_tx, result_expected={'allowed': False, 'reject-reason': 'bad-assetunlock-too-old-quorum'}) + + if __name__ == '__main__': AssetLocksTest().main()