message: test: Add getunconfirmedbalance test with conflicts
diff: @@ -86,30 +86,32 @@ class WalletTest(BitcoinTestFramework):
  self.log.info("Test getbalance and getunconfirmedbalance with unconfirmed inputs")
  + def test_balances(*, fee_node_1=0):
  # getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
  assert_equal(self.nodes[0].getbalance(), Decimal('9.99')) # change from node 0's send
  - assert_equal(self.nodes[1].getbalance(), Decimal('29.99')) # change from node 1's send
  + assert_equal(self.nodes[1].getbalance(), Decimal('30') - fee_node_1) # change from node 1's send
  # Same with minconf=0
  assert_equal(self.nodes[0].getbalance(minconf=0), Decimal('9.99'))
  - assert_equal(self.nodes[1].getbalance(minconf=0), Decimal('29.99'))
  + assert_equal(self.nodes[1].getbalance(minconf=0), Decimal('30') - fee_node_1)
  # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
  # TODO: fix getbalance tracking of coin spentness depth
  assert_equal(self.nodes[0].getbalance(minconf=1), Decimal('0'))
  assert_equal(self.nodes[1].getbalance(minconf=1), Decimal('0'))
  # getunconfirmedbalance
  assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend
  + assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60'))
  assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0')) # Doesn't include output of node 0's send since it was spent
  + assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('0'))
  +
  + test_balances(fee_node_1=Decimal('0.01'))
  # Node 1 bumps the transaction fee and resends
  self.nodes[1].sendrawtransaction(txs[1]['hex'])
  + self.nodes[0].sendrawtransaction(txs[1]['hex']) # sending on both nodes is faster than waiting for propagation
  self.sync_all()
  self.log.info("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs")
  -
  - assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60')) # output of node 1's send
  - assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60'))
  - assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('0')) # Doesn't include output of node 0's send since it was spent
  - assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0'))
  + test_balances(fee_node_1=Decimal('0.02'))
  self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY)
  self.sync_all()
  