Bitshala / BitcoinCore-PR-Review-Club

Bitcoin Core PR Review Organising repo
10 stars 2 forks source link

Review (test: refactor: introduce and use calculate_input_weight helper #29777) #57

Closed naiyoma closed 2 months ago

naiyoma commented 5 months ago

Session Details

Notes

Currently, the transaction input weight is calculated manually as follows:

input_weight = ((len_prevout_txid + len_prevout_index + len_sequence + len_scriptsig) * WITNESS_SCALE_FACTOR) + len_scriptwitness This method is replicated in the test cases found in test/functional/wallet_send.pyand test/functional/rpc_psbt.py. The proposed solution involves using a helper function calculate_input_weight and calling it at the respective call sites.

Questions

Learning

transaction weight tests

QureshiFaisal commented 5 months ago

Concept ACK Approach ACK tACK 6d91cb7

I tested calculate_input_weight helper function for both the call sites in test/functional/wallet_send.py and test/functional/rpc_psbt.py respectively.

The PR introduces a helper function to calculate input_weight at two different call sites and thereby prevents code duplication.

Another call site where this helper function could be used is test/functional/wallet_fundrawtransaction.py , the reason for not covering it could be that the method of calculating input_weight and the data available to do so differ.

stratospher commented 2 months ago

thank you for hosting!