Skip to content

Commit

Permalink
Fix query arg in proposal_from_test_vector
Browse files Browse the repository at this point in the history
    The previous `query` used `?` to separate between pairs while it
    should be `&` as per the `url_fromencoded` crate.
  • Loading branch information
jbesraa committed Nov 28, 2023
1 parent 630efb3 commit aa2ee69
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions payjoin/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ mod test {
}
}

fn proposal_from_test_vector() -> Result<UncheckedProposal, RequestError> {
fn proposal_from_test_vector(min_feerate: Option<u64>) -> Result<UncheckedProposal, RequestError> {
// OriginalPSBT Test Vector from BIP
// | InputScriptType | Orginal PSBT Fee rate | maxadditionalfeecontribution | additionalfeeoutputindex|
// |-----------------|-----------------------|------------------------------|-------------------------|
Expand All @@ -850,16 +850,16 @@ mod test {

let body = original_psbt.as_bytes();
let headers = MockHeaders::new(body.len() as u64);
UncheckedProposal::from_request(
body,
"?maxadditionalfeecontribution=182?additionalfeeoutputindex=0",
headers,
)
let min_feerate_param = format!("minfeerate={}", min_feerate.unwrap_or(0));
let query = format!(
"maxadditionalfeecontribution=182&additionalfeeoutputindex=0&{}", min_feerate_param
);
UncheckedProposal::from_request(body, &query, headers)
}

#[test]
fn can_get_proposal_from_request() {
let proposal = proposal_from_test_vector();
let proposal = proposal_from_test_vector(None);
assert!(proposal.is_ok(), "OriginalPSBT should be a valid request");
}

Expand All @@ -869,7 +869,7 @@ mod test {

use bitcoin::{Address, Network};

let proposal = proposal_from_test_vector().unwrap();
let proposal = proposal_from_test_vector(None).unwrap();
let mut payjoin = proposal
.assume_interactive_receiver()
.check_inputs_not_owned(|_| Ok(false))
Expand Down

0 comments on commit aa2ee69

Please sign in to comment.