Skip to content

Implement settxfee method and test #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GideonBature
Copy link
Contributor

The JSON-RPC method settxfee does return a type. We want to test this to catch any changes in behavior in future Core versions.

This PR adds a client function that errors if the return value is anything other than the type it returns, along with an integration test that calls this function.

Ref: #116

() => {
impl Client {
pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<SetTxFee> {
let fee_rate_btc_kvb = fee_rate.to_sat_per_vb_floor() as f64 / 100_000.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct and drinks on me because you found an API hole in rust-bitcoin. See rust-bitcoin/rust-bitcoin#4688 if you are interested.

#[test]
fn wallet__set_tx_fee() {
let node = Node::with_wallet(Wallet::Default, &[]);
let fee_rate = FeeRate::from_sat_per_vb(2).expect("fee_rate");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have to rebase anyways can you change this to

Suggested change
let fee_rate = FeeRate::from_sat_per_vb(2).expect("fee_rate");
let fee_rate = FeeRate::from_sat_per_vb(2).expect("2 sat/vb is valid");

The idea being the expect message is basically a comment to those reading the code and is never going to be hit at runtime.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebase mate.

Reviewed: ab928fa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants