Skip to content

Commit 16478ce

Browse files
committed
feat: improve improved funtional test feature_asset_locks.py to test more
- rollback of block with tx Asset Lock - rollback of block with tx Asset Unlock - duplicate 'asset unlock' tx for new block asset unlock rollback and reconsider
1 parent f3fe87d commit 16478ce

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

test/functional/feature_asset_locks.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,37 @@ def run_test(self):
169169
node.generate(13)
170170
self.sync_all()
171171

172+
assert_equal(get_credit_pool_amount(node), locked_1)
173+
172174
# tx is mined, let's get blockhash
175+
self.log.info("Invalidate block with asset lock tx...")
173176
block_hash_1 = node.gettransaction(txid_in_block)['blockhash']
174-
self.log.info(block_hash_1)
177+
for inode in self.nodes:
178+
inode.invalidateblock(block_hash_1)
179+
node.generate(3)
180+
self.sync_all()
181+
assert_equal(get_credit_pool_amount(node), 0)
182+
self.log.info("Resubmit asset lock tx to new chain...")
183+
txid_in_block = node.sendrawtransaction(hexstring=asset_lock_tx.serialize().hex(), maxfeerate=0)
184+
node.generate(3)
185+
self.sync_all()
175186

176187
assert_equal(get_credit_pool_amount(node), locked_1)
177188

178-
self.log.info("Mining a quorum...")
179-
self.mine_quorum()
180189
node.generate(3)
181190
self.sync_all()
191+
assert_equal(get_credit_pool_amount(node), locked_1)
192+
self.log.info("Reconsider old blocks...")
193+
for inode in self.nodes:
194+
inode.reconsiderblock(block_hash_1)
195+
assert_equal(get_credit_pool_amount(node), locked_1)
196+
self.sync_all()
182197

198+
self.log.info("Mine a quorum...")
199+
self.mine_quorum()
200+
node.generate(3)
201+
self.sync_all()
202+
assert_equal(get_credit_pool_amount(node), locked_1)
183203

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

199219
node.sendrawtransaction(hexstring=asset_unlock_tx.serialize().hex(), maxfeerate=0)
220+
node.generate(1)
221+
self.sync_all()
222+
try:
223+
node.sendrawtransaction(hexstring=asset_unlock_tx.serialize().hex(), maxfeerate=0)
224+
raise AssertionError("Transaction should not be mined: double copy")
225+
except JSONRPCException as e:
226+
assert "Transaction already in block chain" in e.error['message']
227+
228+
self.log.info("Invalidate block with asset unlock tx...")
229+
block_asset_unlock = node.getbestblockhash()
230+
for inode in self.nodes:
231+
inode.invalidateblock(block_asset_unlock)
232+
assert_equal(get_credit_pool_amount(node), locked_1)
233+
# TODO: strange, fails if generate there new blocks
234+
#node.generate(3)
235+
#self.sync_all()
236+
for inode in self.nodes:
237+
inode.reconsiderblock(block_asset_unlock)
238+
assert_equal(get_credit_pool_amount(node), locked_1 - COIN)
200239

201240
# mine next quorum, tx should be still accepted
202241
self.mine_quorum()

0 commit comments

Comments
 (0)