Skip to content

Commit

Permalink
fix: actually show json for assetlock/unlock txes (#5633)
Browse files Browse the repository at this point in the history
## Issue being fixed or feature implemented
The bug was introduced in the original PR #5026 and refactored later
(which is good actually cause we shouldn't mix refactoring and
bug-fixing :) )

## What was done?
fix conditions, add tests

## How Has This Been Tested?
`feature_asset_locks.py`

## Breaking Changes
n/a

## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
  • Loading branch information
UdjinM6 authored Oct 23, 2023
1 parent 343db5f commit faba796
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
entry.pushKV("mnhfTx", mnhfTx.ToJson());
}
} else if (tx.nType == TRANSACTION_ASSET_LOCK) {
if (CAssetLockPayload assetLockTx; !GetTxPayload(tx, assetLockTx)) {
if (CAssetLockPayload assetLockTx; GetTxPayload(tx, assetLockTx)) {
entry.pushKV("assetLockTx", assetLockTx.ToJson());
}
} else if (tx.nType == TRANSACTION_ASSET_UNLOCK) {
if (CAssetUnlockPayload assetUnlockTx; !GetTxPayload(tx, assetUnlockTx)) {
if (CAssetUnlockPayload assetUnlockTx; GetTxPayload(tx, assetUnlockTx)) {
entry.pushKV("assetUnlockTx", assetUnlockTx.ToJson());
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/functional/feature_asset_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def run_test(self):
self.check_mempool_result(tx=asset_lock_tx, result_expected={'allowed': True})
self.validate_credit_pool_balance(0)
txid_in_block = self.send_tx(asset_lock_tx)
assert "assetLockTx" in node.getrawtransaction(txid_in_block, 1)
self.validate_credit_pool_balance(0)
node.generate(1)
assert_equal(self.get_credit_pool_balance(node=node_wallet), 0)
Expand Down Expand Up @@ -327,7 +328,8 @@ def run_test(self):

assert_equal(asset_unlock_tx_payload.quorumHash, int(self.mninfo[0].node.quorum("selectquorum", llmq_type_test, 'e6c7a809d79f78ea85b72d5df7e9bd592aecf151e679d6e976b74f053a7f9056')["quorumHash"], 16))

self.send_tx(asset_unlock_tx)
txid = self.send_tx(asset_unlock_tx)
assert "assetUnlockTx" in node.getrawtransaction(txid, 1)
self.mempool_size += 1
self.check_mempool_size()
self.validate_credit_pool_balance(locked_1)
Expand Down

0 comments on commit faba796

Please sign in to comment.