Merge #6445: test: add tests for listunspent with coinType option

f3be9bcb95 test: add tests for `listunspent` with `coinType` option (UdjinM6)

Pull request description:

  ## Issue being fixed or feature implemented
  extend tests a bit

  ## What was done?

  ## How Has This Been Tested?

  ## Breaking Changes

  ## Checklist:
  - [ ] 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
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    utACK f3be9bcb95

Tree-SHA512: 3f063011224880fee35edb04ce265dff33a52273c3d45ef1dbcebcecb22c25d8ad7c91b83514f36142716a6fbd0ddd3a8a3f2a9b59ce78ce975bbce69a2a13b5
This commit is contained in:
pasta 2024-12-11 15:14:03 -06:00
commit c07073da16
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38

View File

@ -12,6 +12,7 @@ from test_framework.util import (
assert_array_result, assert_array_result,
assert_equal, assert_equal,
assert_fee_amount, assert_fee_amount,
assert_greater_than,
assert_raises_rpc_error, assert_raises_rpc_error,
count_bytes, count_bytes,
) )
@ -325,6 +326,33 @@ class WalletTest(BitcoinTestFramework):
assert_equal(uTx['amount'], Decimal('0')) assert_equal(uTx['amount'], Decimal('0'))
assert found assert found
self.log.info("Test listunspent with coinType option")
# 0=ALL_COINS
# 1=ONLY_FULLY_MIXED
# 2=ONLY_READY_TO_MIX
# 3=ONLY_NONDENOMINATED
# 4=ONLY_MASTERNODE_COLLATERAL
# 5=ONLY_COINJOIN_COLLATERAL
assert_greater_than(self.nodes[1].getbalance(), 1001)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
for cointype in range(6):
len_cointype = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': cointype}))
assert_equal(len_cointype, 0)
address = self.nodes[0].getnewaddress()
for amount in {0.00100001, 0.00100000, 1000, 0.00010000}:
self.nodes[1].sendtoaddress(address=address, amount=amount)
self.sync_mempools(self.nodes[0:2])
for cointype in range(2, 6):
len_cointype = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': cointype}))
assert_equal(len_cointype, 2 if cointype == 3 else 1) # masternode collaterals are counted as ONLY_NONDENOMINATED too
len_default = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True))
len0 = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': 0}))
len1 = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': 1}))
assert_equal(len_default, len0)
assert_equal(len0, 4)
assert_equal(len1, 0)
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
self.log.info("Test -walletbroadcast") self.log.info("Test -walletbroadcast")
self.stop_nodes() self.stop_nodes()
self.start_node(0, ["-walletbroadcast=0"]) self.start_node(0, ["-walletbroadcast=0"])