Repository navigation
Tests: Cleanup create_transaction implementations - #13669
Conversation
d9592da to
41b8251
Compare
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Concept ACK. I intend to review this. My personal preference would be to split this into smaller commits (eg one just removing the |
|
Thanks @jnewbery - Agreed. I'll try to split this up better. |
41b8251 to
83e35da
Compare
|
I have split this up into 3 commits now. |
jnewbery
left a comment
There was a problem hiding this comment.
Tested ACK 83e35dae61f3c41d7adf8b00d6120a98fea5ca79. Nice tidyup!
A few nits inline. Up to you whether you want to take them.
There was a problem hiding this comment.
I actually prefer the argument ordering before (ie all TxIn fields (prevtx, n, script_sig) then all TxOut fields (amount, script_pub_key)). I like the renames (sig => script_sig and value => amount).
There was a problem hiding this comment.
👍 - you are right, it makes more sense that way now that you mention it.
There was a problem hiding this comment.
Thanks for improving the comment. Can be improved further by stating that this is a one-input, one-output transaction.
There was a problem hiding this comment.
nit: comment could be improved by:
- saying this is spending the first output of transaction txid (I don't see why this function is specific to spending a coinbase tx).
- stating that node must be able to sign for the txout provided
- stating that the node must not be running multiple wallets
588d563 to
44bbcee
Compare
|
Rebased on updated based on @jnewbery comments |
|
utACK 44bbcee This is great. Cuts down on a lot of code duplication and improves commenting. 💯 |
|
utACK 44bbcee |
44bbcee [Tests] Cleanup feature_block.py, remove unnecessary PreviousSpendableOutput object (Conor Scott) 736f941 [Tests] Cleanup extra instances of create_transaction (Conor Scott) 1576518 [Tests] Rename create_tx and move to blocktools.py (Conor Scott) Pull request description: There currently exist seven ([1](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_cltv.py#L52-L60), [2](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_csv_activation.py#L88-L95) [3](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_dersig.py#L40-L48), [4](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_nulldummy.py#L100-L108), [5](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L529-L535), [6](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L120-L129), [7](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_block.py#L1218-L1220)) implementations of a function called something similar to `create_transaction` in the functional tests, some of which are exact copies of each other. This PR aims to clean this up into [three different cases implemented in blocktools.py](https://github.com/conscott/bitcoin/blob/create_tx_cleanup/test/functional/test_framework/blocktools.py#L121-L149) 1. `create_tx_with_script`: Return transaction object spending generic tx output optionally specifying scriptSig and scriptPubKey 2. `create_transaction`: Return transaction object spending coinbase tx 2. `create_raw_transaction`: Return raw transaction (hex string) spending coinbase tx I am not committed to any of these function names, so I'll gladly take suggestions on there. Additionally there are some related cleanups to feature_block.py tests, specifically removing the [PreviousSpendableOutput](https://github.com/conscott/bitcoin/blob/master/test/functional/feature_block.py#L51-L54) object, which seems like an unnecessary layer given that every instance spends the 0 output. Tree-SHA512: 63c6233b6f0942c81ba1ca67ea6770809b8c9409314c6d4cf8e5a3991cb9ee92b22bebe88c0dde45cd71e754eb351230c4c404b70ff118f5f43c034452ada65c
44bbcee [Tests] Cleanup feature_block.py, remove unnecessary PreviousSpendableOutput object (Conor Scott) 736f941 [Tests] Cleanup extra instances of create_transaction (Conor Scott) 1576518 [Tests] Rename create_tx and move to blocktools.py (Conor Scott) Pull request description: There currently exist seven ([1](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_cltv.py#L52-L60), [2](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_csv_activation.py#L88-L95) [3](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_dersig.py#L40-L48), [4](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_nulldummy.py#L100-L108), [5](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L529-L535), [6](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L120-L129), [7](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_block.py#L1218-L1220)) implementations of a function called something similar to `create_transaction` in the functional tests, some of which are exact copies of each other. This PR aims to clean this up into [three different cases implemented in blocktools.py](https://github.com/conscott/bitcoin/blob/create_tx_cleanup/test/functional/test_framework/blocktools.py#L121-L149) 1. `create_tx_with_script`: Return transaction object spending generic tx output optionally specifying scriptSig and scriptPubKey 2. `create_transaction`: Return transaction object spending coinbase tx 2. `create_raw_transaction`: Return raw transaction (hex string) spending coinbase tx I am not committed to any of these function names, so I'll gladly take suggestions on there. Additionally there are some related cleanups to feature_block.py tests, specifically removing the [PreviousSpendableOutput](https://github.com/conscott/bitcoin/blob/master/test/functional/feature_block.py#L51-L54) object, which seems like an unnecessary layer given that every instance spends the 0 output. Tree-SHA512: 63c6233b6f0942c81ba1ca67ea6770809b8c9409314c6d4cf8e5a3991cb9ee92b22bebe88c0dde45cd71e754eb351230c4c404b70ff118f5f43c034452ada65c
44bbcee [Tests] Cleanup feature_block.py, remove unnecessary PreviousSpendableOutput object (Conor Scott) 736f941 [Tests] Cleanup extra instances of create_transaction (Conor Scott) 1576518 [Tests] Rename create_tx and move to blocktools.py (Conor Scott) Pull request description: There currently exist seven ([1](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_cltv.py#L52-L60), [2](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_csv_activation.py#L88-L95) [3](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_dersig.py#L40-L48), [4](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_nulldummy.py#L100-L108), [5](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L529-L535), [6](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/blocktools.py#L120-L129), [7](https://github.com/bitcoin/bitcoin/blob/master/test/functional/feature_block.py#L1218-L1220)) implementations of a function called something similar to `create_transaction` in the functional tests, some of which are exact copies of each other. This PR aims to clean this up into [three different cases implemented in blocktools.py](https://github.com/conscott/bitcoin/blob/create_tx_cleanup/test/functional/test_framework/blocktools.py#L121-L149) 1. `create_tx_with_script`: Return transaction object spending generic tx output optionally specifying scriptSig and scriptPubKey 2. `create_transaction`: Return transaction object spending coinbase tx 2. `create_raw_transaction`: Return raw transaction (hex string) spending coinbase tx I am not committed to any of these function names, so I'll gladly take suggestions on there. Additionally there are some related cleanups to feature_block.py tests, specifically removing the [PreviousSpendableOutput](https://github.com/conscott/bitcoin/blob/master/test/functional/feature_block.py#L51-L54) object, which seems like an unnecessary layer given that every instance spends the 0 output. Tree-SHA512: 63c6233b6f0942c81ba1ca67ea6770809b8c9409314c6d4cf8e5a3991cb9ee92b22bebe88c0dde45cd71e754eb351230c4c404b70ff118f5f43c034452ada65c
There currently exist seven (1, 2 3, 4, 5, 6, 7) implementations of a function called something similar to
create_transactionin the functional tests, some of which are exact copies of each other.This PR aims to clean this up into three different cases implemented in blocktools.py
create_tx_with_script: Return transaction object spending generic tx output optionally specifying scriptSig and scriptPubKeycreate_transaction: Return transaction object spending coinbase txcreate_raw_transaction: Return raw transaction (hex string) spending coinbase txI am not committed to any of these function names, so I'll gladly take suggestions on there.
Additionally there are some related cleanups to feature_block.py tests, specifically removing the PreviousSpendableOutput object, which seems like an unnecessary layer given that every instance spends the 0 output.