|
12 | 12 | assert_array_result, |
13 | 13 | assert_equal, |
14 | 14 | assert_fee_amount, |
| 15 | + assert_greater_than, |
15 | 16 | assert_raises_rpc_error, |
16 | 17 | count_bytes, |
17 | 18 | ) |
@@ -325,6 +326,33 @@ def run_test(self): |
325 | 326 | assert_equal(uTx['amount'], Decimal('0')) |
326 | 327 | assert found |
327 | 328 |
|
| 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 | + |
328 | 356 | self.log.info("Test -walletbroadcast") |
329 | 357 | self.stop_nodes() |
330 | 358 | self.start_node(0, ["-walletbroadcast=0"]) |
|
0 commit comments