diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-04-06 17:21:45 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-11-01 17:54:19 -0500 |
commit | a42652ec10c733a5bf37e418e45d4841f54331b4 (patch) | |
tree | 894650ef47c0ebec519ba08864bf74669c549784 | |
parent | 4b871909d6e4a51888e062d322bf53263deda15e (diff) |
Move import and watchonly tests to be legacy wallet only in wallet_balance.py
Imports and watchonly behavior are legacy wallet only, so make them only
run when the test is in legacy wallet mode.
-rwxr-xr-x | test/functional/wallet_balance.py | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py index 589fab9992..0e786ca595 100755 --- a/test/functional/wallet_balance.py +++ b/test/functional/wallet_balance.py @@ -57,14 +57,16 @@ class WalletTest(BitcoinTestFramework): self.skip_if_no_wallet() def run_test(self): - self.nodes[0].importaddress(ADDRESS_WATCHONLY) - # Check that nodes don't own any UTXOs - assert_equal(len(self.nodes[0].listunspent()), 0) - assert_equal(len(self.nodes[1].listunspent()), 0) + if not self.options.descriptors: + # Tests legacy watchonly behavior which is not present (and does not need to be tested) in descriptor wallets + self.nodes[0].importaddress(ADDRESS_WATCHONLY) + # Check that nodes don't own any UTXOs + assert_equal(len(self.nodes[0].listunspent()), 0) + assert_equal(len(self.nodes[1].listunspent()), 0) - self.log.info("Check that only node 0 is watching an address") - assert 'watchonly' in self.nodes[0].getbalances() - assert 'watchonly' not in self.nodes[1].getbalances() + self.log.info("Check that only node 0 is watching an address") + assert 'watchonly' in self.nodes[0].getbalances() + assert 'watchonly' not in self.nodes[1].getbalances() self.log.info("Mining blocks ...") self.nodes[0].generate(1) @@ -73,22 +75,28 @@ class WalletTest(BitcoinTestFramework): self.nodes[1].generatetoaddress(101, ADDRESS_WATCHONLY) self.sync_all() - assert_equal(self.nodes[0].getbalances()['mine']['trusted'], 50) - assert_equal(self.nodes[0].getwalletinfo()['balance'], 50) - assert_equal(self.nodes[1].getbalances()['mine']['trusted'], 50) + if not self.options.descriptors: + # Tests legacy watchonly behavior which is not present (and does not need to be tested) in descriptor wallets + assert_equal(self.nodes[0].getbalances()['mine']['trusted'], 50) + assert_equal(self.nodes[0].getwalletinfo()['balance'], 50) + assert_equal(self.nodes[1].getbalances()['mine']['trusted'], 50) - assert_equal(self.nodes[0].getbalances()['watchonly']['immature'], 5000) - assert 'watchonly' not in self.nodes[1].getbalances() + assert_equal(self.nodes[0].getbalances()['watchonly']['immature'], 5000) + assert 'watchonly' not in self.nodes[1].getbalances() - assert_equal(self.nodes[0].getbalance(), 50) - assert_equal(self.nodes[1].getbalance(), 50) + assert_equal(self.nodes[0].getbalance(), 50) + assert_equal(self.nodes[1].getbalance(), 50) self.log.info("Test getbalance with different arguments") assert_equal(self.nodes[0].getbalance("*"), 50) assert_equal(self.nodes[0].getbalance("*", 1), 50) - assert_equal(self.nodes[0].getbalance("*", 1, True), 100) assert_equal(self.nodes[0].getbalance(minconf=1), 50) - assert_equal(self.nodes[0].getbalance(minconf=0, include_watchonly=True), 100) + if not self.options.descriptors: + assert_equal(self.nodes[0].getbalance(minconf=0, include_watchonly=True), 100) + assert_equal(self.nodes[0].getbalance("*", 1, True), 100) + else: + assert_equal(self.nodes[0].getbalance(minconf=0, include_watchonly=True), 50) + assert_equal(self.nodes[0].getbalance("*", 1, True), 50) assert_equal(self.nodes[1].getbalance(minconf=0, include_watchonly=True), 50) # Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0. @@ -156,6 +164,8 @@ class WalletTest(BitcoinTestFramework): expected_balances_1 = {'mine': {'immature': Decimal('0E-8'), 'trusted': Decimal('0E-8'), # node 1's send had an unsafe input 'untrusted_pending': Decimal('30.0') - fee_node_1}} # Doesn't include output of node 0's send since it was spent + if self.options.descriptors: + del expected_balances_0["watchonly"] assert_equal(self.nodes[0].getbalances(), expected_balances_0) assert_equal(self.nodes[1].getbalances(), expected_balances_1) # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions |