Merge bitcoin/bitcoin#26127: test: check that bumping tx with already spent coin fails

74eb194f8155624c598ede1a3f45545f8d74c9db test: check that bumping tx with already spent coin fails (Sebastian Falbesoner)

Pull request description:

  This PR adds missing coverage for the `bumpfee` RPC,  for the case that a wallet transaction is passed with an input that is already spent:
  0b02ce914e/src/wallet/feebumper.cpp (L182-L186)

  This is achieved by simply creating a transaction with a wallet and then mining it (I'm not aware of any other scenario how this could be achieved). Additionally, two RPC throw checks are changed in the test to be more specific:
  0b02ce914e/src/wallet/feebumper.cpp (L42-L45)
  0b02ce914e/src/wallet/feebumper.cpp (L47-L50)

ACKs for top commit:
  glozow:
    ACK 74eb194f8155624c598ede1a3f45545f8d74c9db

Tree-SHA512: 487d0e30a7cc5e2a5f63424ab6aed2963e05e47e2649fb1ad2289c4b48ad488f2dae5c27bf50e532e7eb2f2f5bf0340ed7dda985d14473f31dec0d757bb56324
This commit is contained in:
MacroFake 2022-09-20 18:44:32 +02:00
commit 9bd842a592
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -93,6 +93,7 @@ class BumpFeeTest(BitcoinTestFramework):
test_watchonly_psbt(self, peer_node, rbf_node, dest_address)
test_rebumping(self, rbf_node, dest_address)
test_rebumping_not_replaceable(self, rbf_node, dest_address)
test_bumpfee_already_spent(self, rbf_node, dest_address)
test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address)
test_bumpfee_metadata(self, rbf_node, dest_address)
test_locked_wallet_fails(self, rbf_node, dest_address)
@ -229,7 +230,7 @@ def test_segwit_bumpfee_succeeds(self, rbf_node, dest_address):
def test_nonrbf_bumpfee_fails(self, peer_node, dest_address):
self.log.info('Test that we cannot replace a non RBF transaction')
not_rbfid = peer_node.sendtoaddress(dest_address, Decimal("0.00090000"))
assert_raises_rpc_error(-4, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
assert_raises_rpc_error(-4, "Transaction is not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
self.clear_mempool()
@ -499,7 +500,8 @@ def test_rebumping(self, rbf_node, dest_address):
self.log.info('Test that re-bumping the original tx fails, but bumping successor works')
rbfid = spend_one_input(rbf_node, dest_address)
bumped = rbf_node.bumpfee(rbfid, {"fee_rate": ECONOMICAL})
assert_raises_rpc_error(-4, "already bumped", rbf_node.bumpfee, rbfid, {"fee_rate": NORMAL})
assert_raises_rpc_error(-4, f"Cannot bump transaction {rbfid} which was already bumped by transaction {bumped['txid']}",
rbf_node.bumpfee, rbfid, {"fee_rate": NORMAL})
rbf_node.bumpfee(bumped["txid"], {"fee_rate": NORMAL})
self.clear_mempool()
@ -513,6 +515,15 @@ def test_rebumping_not_replaceable(self, rbf_node, dest_address):
self.clear_mempool()
def test_bumpfee_already_spent(self, rbf_node, dest_address):
self.log.info('Test that bumping tx with already spent coin fails')
txid = spend_one_input(rbf_node, dest_address)
self.generate(rbf_node, 1) # spend coin simply by mining block with tx
spent_input = rbf_node.gettransaction(txid=txid, verbose=True)['decoded']['vin'][0]
assert_raises_rpc_error(-1, f"{spent_input['txid']}:{spent_input['vout']} is already spent",
rbf_node.bumpfee, txid, {"fee_rate": NORMAL})
def test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address):
self.log.info('Test that unconfirmed outputs from bumped txns are not spendable')
rbfid = spend_one_input(rbf_node, rbf_node_address)