@@ -86,30 +86,32 @@ def run_test(self):
86
86
87
87
self .log .info ("Test getbalance and getunconfirmedbalance with unconfirmed inputs" )
88
88
89
- # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
90
- assert_equal (self .nodes [0 ].getbalance (), Decimal ('9.99' )) # change from node 0's send
91
- assert_equal (self .nodes [1 ].getbalance (), Decimal ('29.99' )) # change from node 1's send
92
- # Same with minconf=0
93
- assert_equal (self .nodes [0 ].getbalance (minconf = 0 ), Decimal ('9.99' ))
94
- assert_equal (self .nodes [1 ].getbalance (minconf = 0 ), Decimal ('29.99' ))
95
- # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
96
- # TODO: fix getbalance tracking of coin spentness depth
97
- assert_equal (self .nodes [0 ].getbalance (minconf = 1 ), Decimal ('0' ))
98
- assert_equal (self .nodes [1 ].getbalance (minconf = 1 ), Decimal ('0' ))
99
- # getunconfirmedbalance
100
- assert_equal (self .nodes [0 ].getunconfirmedbalance (), Decimal ('60' )) # output of node 1's spend
101
- assert_equal (self .nodes [1 ].getunconfirmedbalance (), Decimal ('0' )) # Doesn't include output of node 0's send since it was spent
89
+ def test_balances (* , fee_node_1 = 0 ):
90
+ # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
91
+ assert_equal (self .nodes [0 ].getbalance (), Decimal ('9.99' )) # change from node 0's send
92
+ assert_equal (self .nodes [1 ].getbalance (), Decimal ('30' ) - fee_node_1 ) # change from node 1's send
93
+ # Same with minconf=0
94
+ assert_equal (self .nodes [0 ].getbalance (minconf = 0 ), Decimal ('9.99' ))
95
+ assert_equal (self .nodes [1 ].getbalance (minconf = 0 ), Decimal ('30' ) - fee_node_1 )
96
+ # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
97
+ # TODO: fix getbalance tracking of coin spentness depth
98
+ assert_equal (self .nodes [0 ].getbalance (minconf = 1 ), Decimal ('0' ))
99
+ assert_equal (self .nodes [1 ].getbalance (minconf = 1 ), Decimal ('0' ))
100
+ # getunconfirmedbalance
101
+ assert_equal (self .nodes [0 ].getunconfirmedbalance (), Decimal ('60' )) # output of node 1's spend
102
+ assert_equal (self .nodes [0 ].getwalletinfo ()["unconfirmed_balance" ], Decimal ('60' ))
103
+ assert_equal (self .nodes [1 ].getunconfirmedbalance (), Decimal ('0' )) # Doesn't include output of node 0's send since it was spent
104
+ assert_equal (self .nodes [1 ].getwalletinfo ()["unconfirmed_balance" ], Decimal ('0' ))
105
+
106
+ test_balances (fee_node_1 = Decimal ('0.01' ))
102
107
103
108
# Node 1 bumps the transaction fee and resends
104
109
self .nodes [1 ].sendrawtransaction (txs [1 ]['hex' ])
110
+ self .nodes [0 ].sendrawtransaction (txs [1 ]['hex' ]) # sending on both nodes is faster than waiting for propagation
105
111
self .sync_all ()
106
112
107
113
self .log .info ("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs" )
108
-
109
- assert_equal (self .nodes [0 ].getwalletinfo ()["unconfirmed_balance" ], Decimal ('60' )) # output of node 1's send
110
- assert_equal (self .nodes [0 ].getunconfirmedbalance (), Decimal ('60' ))
111
- assert_equal (self .nodes [1 ].getwalletinfo ()["unconfirmed_balance" ], Decimal ('0' )) # Doesn't include output of node 0's send since it was spent
112
- assert_equal (self .nodes [1 ].getunconfirmedbalance (), Decimal ('0' ))
114
+ test_balances (fee_node_1 = Decimal ('0.02' ))
113
115
114
116
self .nodes [1 ].generatetoaddress (1 , ADDRESS_WATCHONLY )
115
117
self .sync_all ()
0 commit comments