Skip to content

Commit f3be9bc

Browse files
committed
test: add tests for listunspent with coinType option
1 parent a82d33e commit f3be9bc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/functional/wallet_basic.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
assert_array_result,
1313
assert_equal,
1414
assert_fee_amount,
15+
assert_greater_than,
1516
assert_raises_rpc_error,
1617
count_bytes,
1718
)
@@ -325,6 +326,33 @@ def run_test(self):
325326
assert_equal(uTx['amount'], Decimal('0'))
326327
assert found
327328

329+
self.log.info("Test listunspent with coinType option")
330+
# 0=ALL_COINS
331+
# 1=ONLY_FULLY_MIXED
332+
# 2=ONLY_READY_TO_MIX
333+
# 3=ONLY_NONDENOMINATED
334+
# 4=ONLY_MASTERNODE_COLLATERAL
335+
# 5=ONLY_COINJOIN_COLLATERAL
336+
assert_greater_than(self.nodes[1].getbalance(), 1001)
337+
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
338+
for cointype in range(6):
339+
len_cointype = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': cointype}))
340+
assert_equal(len_cointype, 0)
341+
address = self.nodes[0].getnewaddress()
342+
for amount in {0.00100001, 0.00100000, 1000, 0.00010000}:
343+
self.nodes[1].sendtoaddress(address=address, amount=amount)
344+
self.sync_mempools(self.nodes[0:2])
345+
for cointype in range(2, 6):
346+
len_cointype = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': cointype}))
347+
assert_equal(len_cointype, 2 if cointype == 3 else 1) # masternode collaterals are counted as ONLY_NONDENOMINATED too
348+
len_default = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True))
349+
len0 = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': 0}))
350+
len1 = len(self.nodes[0].listunspent(minconf=0, maxconf=0, include_unsafe=True, query_options={'coinType': 1}))
351+
assert_equal(len_default, len0)
352+
assert_equal(len0, 4)
353+
assert_equal(len1, 0)
354+
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
355+
328356
self.log.info("Test -walletbroadcast")
329357
self.stop_nodes()
330358
self.start_node(0, ["-walletbroadcast=0"])

0 commit comments

Comments
 (0)