Skip to content

Commit

Permalink
Deconstruct Request in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould authored and jbesraa committed Jul 31, 2023
1 parent f0e26a1 commit bb888bb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions payjoin/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,21 @@ mod integration {
payjoin::bitcoin::Amount::from_sat(10000),
None,
);
let req = pj_uri.create_pj_request(psbt, pj_params).unwrap();
let body = req.body.as_slice();
let query = req.url.query().unwrap_or("");
let headers = HeaderMock::from_vec(&req.body);
let Request { body, url, context, .. } = pj_uri.create_pj_request(psbt, pj_params).unwrap();
let query = url.query().unwrap_or("");
let headers = HeaderMock::from_vec(&body);

// **********************
// Inside the Receiver:
// this data would transit from one party to another over the network in production
let response: _ = handle_pj_request(body, query, headers, receiver);
let response: _ = handle_pj_request(body.as_slice(), query, headers, receiver);
// this response would be returned as http response to the sender

// **********************
// Inside the Sender:
// Sender checks, signs, finalizes, extracts, and broadcasts
let checked_payjoin_proposal_psbt =
req.context.process_response(&mut response.as_bytes()).unwrap();
context.process_response(&mut response.as_bytes()).unwrap();
let payjoin_base64_string = base64::encode(&checked_payjoin_proposal_psbt.serialize());
let payjoin_psbt =
sender.wallet_process_psbt(&payjoin_base64_string, None, None, None).unwrap().psbt;
Expand Down

0 comments on commit bb888bb

Please sign in to comment.