aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_fundrawtransaction.py
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2022-03-01 09:56:42 +0000
committerfanquake <fanquake@gmail.com>2022-03-01 13:40:11 +0000
commit9b5f674abb0e90280436fbacb8711250cde11773 (patch)
tree0f173c70b5ff3a3cf60cb3eb4a1bc30a01c07c75 /test/functional/rpc_fundrawtransaction.py
parenteff97097239fa42764aaa14a7ae57ac9e73b9bd9 (diff)
parent269553fe73b17f8acda3071a48836c66092d31d0 (diff)
downloadbitcoin-9b5f674abb0e90280436fbacb8711250cde11773.tar.xz
Merge bitcoin/bitcoin#23276: [22.x] Backports for 22.x
269553fe73b17f8acda3071a48836c66092d31d0 test: Call ceildiv helper with integer (Martin Zumsande) 2f60fc6d8c6b1d8e74c340fed495b76deac4a048 ci: Replace soon EOL hirsute with jammy (MarcoFalke) 801b0f05aaf974ab9b0e3f7b59948564638d593f build: patch qt to explicitly define previously implicit header include (Kittywhiskers Van Gogh) c768bfa08af034c744402d4294cc323d653b97b8 tests: Calculate fees more similarly to CFeeRate::GetFee (Andrew Chow) f66bc42957ad2e86982c8c487f821683d3009b43 tests: Test for assertion when feerate is rounded down (Andrew Chow) bd7e08e36bf2e1238ddf8cc01433f8db82f848c9 fees: Always round up fee calculated from a feerate (Andrew Chow) 227ae652542451834faddbaffb54fc384e9156e6 wallet: fix segfault by avoiding invalid default-ctored `external_spk_managers` entry (Sebastian Falbesoner) 282863a7e9ddfb14ef02182945ca1978699dbe52 refactor: include a missing <limits> header in fs.cpp (Joan Karadimov) 7febe4f3c7f482390c4aa6fc528e2ee3fb34b142 consensus: don't call GetBlockPos in ReadBlockFromDisk without lock (Jon Atack) c671c6f4706d17cccfe5c35950235f8777a7975f the result of CWallet::IsHDEnabled() was initialized with true. (Saibato) a5a153882609c8d77118a88a9a440d4966c8d0ef build, qt: Fix typo in QtInputSupport check (Hennadii Stepanov) c95b188fc08387d0a89668e56bce3a4fad1ee611 system: skip trying to set the locale on NetBSD (fanquake) c1cdeddd905b5444eac330d565b297b3d4941c5d guix: Fix powerpc64(le) dynamic linker name (Carl Dong) 92d44ff36cc12e34f93bfcc4ec31ffae8787100c doc: Add 23061 release notes (MarcoFalke) db76db7329f6357c5226cd08611fe0f669c002af Fix (inverse) meaning of -persistmempool (MarcoFalke) 85c78e08ec857e51a9748d1a2492d1d3794b221a build: Restrict check for CRC32C intrinsic to aarch64 (W. J. van der Laan) Pull request description: Collecting backports for the 22.1 release. Currently: * https://github.com/bitcoin/bitcoin/pull/23045 * https://github.com/bitcoin/bitcoin/pull/23061 * https://github.com/bitcoin/bitcoin/pull/23148 * https://github.com/bitcoin/bitcoin/pull/22390 * https://github.com/bitcoin/bitcoin/pull/22820 * https://github.com/bitcoin/bitcoin/pull/22781 * https://github.com/bitcoin/bitcoin/pull/22895 * https://github.com/bitcoin/bitcoin/pull/23335 * https://github.com/bitcoin/bitcoin/pull/23333 * https://github.com/bitcoin/bitcoin/pull/22949 * https://github.com/bitcoin/bitcoin/pull/23580 * https://github.com/bitcoin/bitcoin/pull/23504 * https://github.com/bitcoin/bitcoin/pull/24239 ACKs for top commit: achow101: ACK 269553fe73b17f8acda3071a48836c66092d31d0 Tree-SHA512: b3a57ea241be7a83488eeb032276f4cf82a0987aada906a82f94a20c4acf9f2397708249dcecbe1c7575e70d09c60b835233d4718af4013c7bc58896c618274c
Diffstat (limited to 'test/functional/rpc_fundrawtransaction.py')
-rwxr-xr-xtest/functional/rpc_fundrawtransaction.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py
index fcc310394a..bbd3dbb10c 100755
--- a/test/functional/rpc_fundrawtransaction.py
+++ b/test/functional/rpc_fundrawtransaction.py
@@ -100,6 +100,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.test_transaction_too_large()
self.test_include_unsafe()
self.test_22670()
+ self.test_feerate_rounding()
def test_change_position(self):
"""Ensure setting changePosition in fundraw with an exact match is handled properly."""
@@ -1026,6 +1027,33 @@ class RawTransactionsTest(BitcoinTestFramework):
do_fund_send(upper_bound)
self.restart_node(0)
+ self.connect_nodes(0, 1)
+ self.connect_nodes(0, 2)
+ self.connect_nodes(0, 3)
+
+ def test_feerate_rounding(self):
+ self.log.info("Test that rounding of GetFee does not result in an assertion")
+
+ self.nodes[1].createwallet("roundtest")
+ w = self.nodes[1].get_wallet_rpc("roundtest")
+
+ addr = w.getnewaddress(address_type="bech32")
+ self.nodes[0].sendtoaddress(addr, 1)
+ self.nodes[0].generate(1)
+ self.sync_all()
+
+ # A P2WPKH input costs 68 vbytes; With a single P2WPKH output, the rest of the tx is 42 vbytes for a total of 110 vbytes.
+ # At a feerate of 1.85 sat/vb, the input will need a fee of 125.8 sats and the rest 77.7 sats
+ # The entire tx fee should be 203.5 sats.
+ # Coin selection rounds the fee individually instead of at the end (due to how CFeeRate::GetFee works).
+ # If rounding down (which is the incorrect behavior), then the calculated fee will be 125 + 77 = 202.
+ # If rounding up, then the calculated fee will be 126 + 78 = 204.
+ # In the former case, the calculated needed fee is higher than the actual fee being paid, so an assertion is reached
+ # To test this does not happen, we subtract 202 sats from the input value. If working correctly, this should
+ # fail with insufficient funds rather than bitcoind asserting.
+ rawtx = w.createrawtransaction(inputs=[], outputs=[{self.nodes[0].getnewaddress(address_type="bech32"): 1 - 0.00000202}])
+ assert_raises_rpc_error(-4, "Insufficient funds", w.fundrawtransaction, rawtx, {"fee_rate": 1.85})
+
if __name__ == '__main__':
RawTransactionsTest().main()