aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-09-20 18:44:32 +0200
committerMacroFake <falke.marco@gmail.com>2022-09-20 18:44:35 +0200
commit9bd842a5928f160c1bc8fca6ca7d8d43f096fd6a (patch)
tree8af7211d844c29c7eabf7f1c4fbb0108e8ed65cc /test
parentfc4017552c980ec9e95de677ea8166702351b79d (diff)
parent74eb194f8155624c598ede1a3f45545f8d74c9db (diff)
downloadbitcoin-9bd842a5928f160c1bc8fca6ca7d8d43f096fd6a.tar.xz
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: https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/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: https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/src/wallet/feebumper.cpp#L42-L45 https://github.com/bitcoin/bitcoin/blob/0b02ce914e8594e8938e527c91c07f57def4e943/src/wallet/feebumper.cpp#L47-L50 ACKs for top commit: glozow: ACK 74eb194f8155624c598ede1a3f45545f8d74c9db Tree-SHA512: 487d0e30a7cc5e2a5f63424ab6aed2963e05e47e2649fb1ad2289c4b48ad488f2dae5c27bf50e532e7eb2f2f5bf0340ed7dda985d14473f31dec0d757bb56324
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_bumpfee.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py
index f4ae697292..158ef66110 100755
--- a/test/functional/wallet_bumpfee.py
+++ b/test/functional/wallet_bumpfee.py
@@ -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)