Skip to content

Commit

Permalink
feat: improve improved funtional test feature_asset_locks.py to test …
Browse files Browse the repository at this point in the history
…more

 - rollback of block for tx Asset Lock
 - duplicate 'asset unlock' tx
  • Loading branch information
knst committed Oct 4, 2022
1 parent f3fe87d commit 18e1141
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,37 @@ def run_test(self):
node.generate(13)
self.sync_all()

assert_equal(get_credit_pool_amount(node), locked_1)

# tx is mined, let's get blockhash
self.log.info("Invalidate block with asset lock tx...")
block_hash_1 = node.gettransaction(txid_in_block)['blockhash']
self.log.info(block_hash_1)
for inode in self.nodes:
inode.invalidateblock(block_hash_1)
node.generate(3)
self.sync_all()
assert_equal(get_credit_pool_amount(node), 0)
self.log.info("Resubmit asset lock tx to new chain...")
txid_in_block = node.sendrawtransaction(hexstring=asset_lock_tx.serialize().hex(), maxfeerate=0)
node.generate(3)
self.sync_all()

assert_equal(get_credit_pool_amount(node), locked_1)

self.log.info("Mining a quorum...")
self.mine_quorum()
node.generate(3)
self.sync_all()
assert_equal(get_credit_pool_amount(node), locked_1)
self.log.info("Reconsider old blocks...")
for inode in self.nodes:
inode.reconsiderblock(block_hash_1)
assert_equal(get_credit_pool_amount(node), locked_1)
self.sync_all()

self.log.info("Mine a quorum...")
self.mine_quorum()
node.generate(3)
self.sync_all()
assert_equal(get_credit_pool_amount(node), locked_1)

self.log.info("Testing asset unlock...")
asset_unlock_tx = create_assetunlock(node, self.mninfo, 101, COIN, pubkey)
Expand All @@ -197,6 +217,13 @@ def run_test(self):
assert_equal(asset_unlock_tx_payload.quorumHash, int(self.mninfo[0].node.quorum("selectquorum", llmq_type_test, 'e6c7a809d79f78ea85b72d5df7e9bd592aecf151e679d6e976b74f053a7f9056')["quorumHash"], 16))

node.sendrawtransaction(hexstring=asset_unlock_tx.serialize().hex(), maxfeerate=0)
node.generate(1)
self.sync_all()
try:
node.sendrawtransaction(hexstring=asset_unlock_tx.serialize().hex(), maxfeerate=0)
raise AssertionError("Transaction should not be mined: double copy")
except JSONRPCException as e:
assert "Transaction already in block chain" in e.error['message']

# mine next quorum, tx should be still accepted
self.mine_quorum()
Expand Down

0 comments on commit 18e1141

Please sign in to comment.