diff --git a/test/functional/feature_asset_locks.py b/test/functional/feature_asset_locks.py index 411b48ce1fce3..ce69085493ace 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 @@ -267,6 +268,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): @@ -432,8 +434,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(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...") @@ -447,7 +450,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() @@ -650,6 +654,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()