@@ -57,14 +57,16 @@ def skip_test_if_missing_module(self):
5757 self .skip_if_no_wallet ()
5858
5959 def run_test (self ):
60- self .nodes [0 ].importaddress (ADDRESS_WATCHONLY )
61- # Check that nodes don't own any UTXOs
62- assert_equal (len (self .nodes [0 ].listunspent ()), 0 )
63- assert_equal (len (self .nodes [1 ].listunspent ()), 0 )
60+ if not self .options .descriptors :
61+ # Tests legacy watchonly behavior which is not present (and does not need to be tested) in descriptor wallets
62+ self .nodes [0 ].importaddress (ADDRESS_WATCHONLY )
63+ # Check that nodes don't own any UTXOs
64+ assert_equal (len (self .nodes [0 ].listunspent ()), 0 )
65+ assert_equal (len (self .nodes [1 ].listunspent ()), 0 )
6466
65- self .log .info ("Check that only node 0 is watching an address" )
66- assert 'watchonly' in self .nodes [0 ].getbalances ()
67- assert 'watchonly' not in self .nodes [1 ].getbalances ()
67+ self .log .info ("Check that only node 0 is watching an address" )
68+ assert 'watchonly' in self .nodes [0 ].getbalances ()
69+ assert 'watchonly' not in self .nodes [1 ].getbalances ()
6870
6971 self .log .info ("Mining blocks ..." )
7072 self .nodes [0 ].generate (1 )
@@ -73,22 +75,28 @@ def run_test(self):
7375 self .nodes [1 ].generatetoaddress (101 , ADDRESS_WATCHONLY )
7476 self .sync_all ()
7577
76- assert_equal (self .nodes [0 ].getbalances ()['mine' ]['trusted' ], 50 )
77- assert_equal (self .nodes [0 ].getwalletinfo ()['balance' ], 50 )
78- assert_equal (self .nodes [1 ].getbalances ()['mine' ]['trusted' ], 50 )
78+ if not self .options .descriptors :
79+ # Tests legacy watchonly behavior which is not present (and does not need to be tested) in descriptor wallets
80+ assert_equal (self .nodes [0 ].getbalances ()['mine' ]['trusted' ], 50 )
81+ assert_equal (self .nodes [0 ].getwalletinfo ()['balance' ], 50 )
82+ assert_equal (self .nodes [1 ].getbalances ()['mine' ]['trusted' ], 50 )
7983
80- assert_equal (self .nodes [0 ].getbalances ()['watchonly' ]['immature' ], 5000 )
81- assert 'watchonly' not in self .nodes [1 ].getbalances ()
84+ assert_equal (self .nodes [0 ].getbalances ()['watchonly' ]['immature' ], 5000 )
85+ assert 'watchonly' not in self .nodes [1 ].getbalances ()
8286
83- assert_equal (self .nodes [0 ].getbalance (), 50 )
84- assert_equal (self .nodes [1 ].getbalance (), 50 )
87+ assert_equal (self .nodes [0 ].getbalance (), 50 )
88+ assert_equal (self .nodes [1 ].getbalance (), 50 )
8589
8690 self .log .info ("Test getbalance with different arguments" )
8791 assert_equal (self .nodes [0 ].getbalance ("*" ), 50 )
8892 assert_equal (self .nodes [0 ].getbalance ("*" , 1 ), 50 )
89- assert_equal (self .nodes [0 ].getbalance ("*" , 1 , True ), 100 )
9093 assert_equal (self .nodes [0 ].getbalance (minconf = 1 ), 50 )
91- assert_equal (self .nodes [0 ].getbalance (minconf = 0 , include_watchonly = True ), 100 )
94+ if not self .options .descriptors :
95+ assert_equal (self .nodes [0 ].getbalance (minconf = 0 , include_watchonly = True ), 100 )
96+ assert_equal (self .nodes [0 ].getbalance ("*" , 1 , True ), 100 )
97+ else :
98+ assert_equal (self .nodes [0 ].getbalance (minconf = 0 , include_watchonly = True ), 50 )
99+ assert_equal (self .nodes [0 ].getbalance ("*" , 1 , True ), 50 )
92100 assert_equal (self .nodes [1 ].getbalance (minconf = 0 , include_watchonly = True ), 50 )
93101
94102 # Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0.
@@ -156,6 +164,8 @@ def test_balances(*, fee_node_1=0):
156164 expected_balances_1 = {'mine' : {'immature' : Decimal ('0E-8' ),
157165 'trusted' : Decimal ('0E-8' ), # node 1's send had an unsafe input
158166 'untrusted_pending' : Decimal ('30.0' ) - fee_node_1 }} # Doesn't include output of node 0's send since it was spent
167+ if self .options .descriptors :
168+ del expected_balances_0 ["watchonly" ]
159169 assert_equal (self .nodes [0 ].getbalances (), expected_balances_0 )
160170 assert_equal (self .nodes [1 ].getbalances (), expected_balances_1 )
161171 # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
0 commit comments