@@ -57,14 +57,16 @@ def skip_test_if_missing_module(self):
57
57
self .skip_if_no_wallet ()
58
58
59
59
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 )
64
66
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 ()
68
70
69
71
self .log .info ("Mining blocks ..." )
70
72
self .nodes [0 ].generate (1 )
@@ -73,22 +75,28 @@ def run_test(self):
73
75
self .nodes [1 ].generatetoaddress (101 , ADDRESS_WATCHONLY )
74
76
self .sync_all ()
75
77
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 )
79
83
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 ()
82
86
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 )
85
89
86
90
self .log .info ("Test getbalance with different arguments" )
87
91
assert_equal (self .nodes [0 ].getbalance ("*" ), 50 )
88
92
assert_equal (self .nodes [0 ].getbalance ("*" , 1 ), 50 )
89
- assert_equal (self .nodes [0 ].getbalance ("*" , 1 , True ), 100 )
90
93
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 )
92
100
assert_equal (self .nodes [1 ].getbalance (minconf = 0 , include_watchonly = True ), 50 )
93
101
94
102
# 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):
156
164
expected_balances_1 = {'mine' : {'immature' : Decimal ('0E-8' ),
157
165
'trusted' : Decimal ('0E-8' ), # node 1's send had an unsafe input
158
166
'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" ]
159
169
assert_equal (self .nodes [0 ].getbalances (), expected_balances_0 )
160
170
assert_equal (self .nodes [1 ].getbalances (), expected_balances_1 )
161
171
# getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
0 commit comments