mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge #19597: test: test decodepsbt fee calculation (count input value only once per UTXO)
82dee87933
test: test decodepsbt fee calculation (count input value only once per UTXO) (Sebastian Falbesoner) Pull request description: Fixes #19523, adding a simple test to `rpc_psbt.py` that checks that the decodepsbt fee matches the one given by the wallet (`walletcreatefundedpsbt`). This is in particular important for PSBTs with segwit inputs that have both a witness- and a non-witness-UTXO type set. Example test run after reverting commit75122780e2
("Increment input value sum only once per UTXO in decodepsbt"): ``` $ test/functional/rpc_psbt.py 2020-07-26T11:31:44.862000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test__sutcd4y 20.00007580 2020-07-26T11:31:47.073000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/test_framework.py", line 118, in main self.run_test() File "test/functional/rpc_psbt.py", line 166, in run_test assert_equal(decoded['fee'], created_psbt['fee']) File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/util.py", line 49, in assert_equal raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args)) AssertionError: not(20.00007580 == 0.00007580) 2020-07-26T11:31:47.125000Z TestFramework (INFO): Stopping nodes ...... ``` ACKs for top commit: achow101: ACK82dee87933
Tree-SHA512: 296b8a701f851d482ef6200c6cbf0cf0257a79a828ac6dbc39b05d8c2d839c6fdb9d3f5a084015295cfa3eac7c11faa2f2d52e619c11627b04c75150eead8330
This commit is contained in:
commit
2a784723f0
1 changed files with 4 additions and 2 deletions
|
@ -155,12 +155,14 @@ class PSBTTest(BitcoinTestFramework):
|
|||
p2pkh_pos = out['n']
|
||||
|
||||
# spend single key from node 1
|
||||
rawtx = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})['psbt']
|
||||
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(rawtx)
|
||||
created_psbt = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})
|
||||
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(created_psbt['psbt'])
|
||||
# Make sure it has both types of UTXOs
|
||||
decoded = self.nodes[1].decodepsbt(walletprocesspsbt_out['psbt'])
|
||||
assert 'non_witness_utxo' in decoded['inputs'][0]
|
||||
assert 'witness_utxo' in decoded['inputs'][0]
|
||||
# Check decodepsbt fee calculation (input values shall only be counted once per UTXO)
|
||||
assert_equal(decoded['fee'], created_psbt['fee'])
|
||||
assert_equal(walletprocesspsbt_out['complete'], True)
|
||||
self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex'])
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue