Skip to content

Commit

Permalink
fix warnings for clippy --all-targets
Browse files Browse the repository at this point in the history
  • Loading branch information
spacebear21 committed Nov 8, 2024
1 parent b690879 commit 19f93d3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
20 changes: 10 additions & 10 deletions payjoin-cli/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ mod e2e {
.arg("--rpchost")
.arg(&receiver_rpchost)
.arg("--cookie-file")
.arg(&cookie_file)
.arg(cookie_file)
.arg("--db-path")
.arg(&receiver_db_path)
.arg("--ohttp-relay")
.arg(&mock_ohttp_relay)
.arg(mock_ohttp_relay)
.arg("receive")
.arg(RECEIVE_SATS)
.arg("--pj-directory")
.arg(&directory)
.arg(directory)
.arg("--ohttp-keys")
.arg(&ohttp_keys_path)
.stdout(Stdio::piped())
Expand All @@ -280,11 +280,11 @@ mod e2e {
.arg("--rpchost")
.arg(&sender_rpchost)
.arg("--cookie-file")
.arg(&cookie_file)
.arg(cookie_file)
.arg("--db-path")
.arg(&sender_db_path)
.arg("--ohttp-relay")
.arg(&mock_ohttp_relay)
.arg(mock_ohttp_relay)
.arg("send")
.arg(&bip21)
.arg("--fee-rate")
Expand All @@ -299,11 +299,11 @@ mod e2e {
.arg("--rpchost")
.arg(&receiver_rpchost)
.arg("--cookie-file")
.arg(&cookie_file)
.arg(cookie_file)
.arg("--db-path")
.arg(&receiver_db_path)
.arg("--ohttp-relay")
.arg(&mock_ohttp_relay)
.arg(mock_ohttp_relay)
.arg("resume")
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
Expand All @@ -315,11 +315,11 @@ mod e2e {
.arg("--rpchost")
.arg(&sender_rpchost)
.arg("--cookie-file")
.arg(&cookie_file)
.arg(cookie_file)
.arg("--db-path")
.arg(&sender_db_path)
.arg("--ohttp-relay")
.arg(&mock_ohttp_relay)
.arg(mock_ohttp_relay)
.arg("send")
.arg(&bip21)
.arg("--fee-rate")
Expand Down Expand Up @@ -479,7 +479,7 @@ mod e2e {
async fn init_directory(port: u16, local_cert_key: (Vec<u8>, Vec<u8>)) -> Result<()> {
let docker: Cli = Cli::default();
let timeout = Duration::from_secs(2);
let db = docker.run(Redis::default());
let db = docker.run(Redis);
let db_host = format!("127.0.0.1:{}", db.get_host_port_ipv4(6379));
println!("Database running on {}", db.get_host_port_ipv4(6379));
payjoin_directory::listen_tcp_with_tls(port, db_host, timeout, local_cert_key).await
Expand Down
5 changes: 2 additions & 3 deletions payjoin/src/send/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,7 @@ mod test {
})
.to_string();
match ctx.process_response(&mut known_json_error.as_bytes()) {
Err(ResponseError::WellKnown(WellKnownError::VersionUnsupported { .. })) =>
assert!(true),
Err(ResponseError::WellKnown(WellKnownError::VersionUnsupported { .. })) => (),
_ => panic!("Expected WellKnownError"),
}

Expand All @@ -1022,7 +1021,7 @@ mod test {
})
.to_string();
match ctx.process_response(&mut invalid_json_error.as_bytes()) {
Err(ResponseError::Validation(_)) => assert!(true),
Err(ResponseError::Validation(_)) => (),
_ => panic!("Expected unrecognized JSON error"),
}
}
Expand Down
8 changes: 4 additions & 4 deletions payjoin/src/uri/url_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ mod tests {

let ohttp_keys =
OhttpKeys::from_str("AQO6SMScPUqSo60A7MY6Ak2hDO0CGAxz7BLYp60syRu0gw").unwrap();
let _ = url.set_ohttp(Some(ohttp_keys.clone()));
url.set_ohttp(Some(ohttp_keys.clone()));
assert_eq!(url.fragment(), Some("ohttp=AQO6SMScPUqSo60A7MY6Ak2hDO0CGAxz7BLYp60syRu0gw"));

assert_eq!(url.ohttp(), Some(ohttp_keys));

let _ = url.set_ohttp(None);
url.set_ohttp(None);
assert_eq!(url.fragment(), None);
}

Expand All @@ -107,12 +107,12 @@ mod tests {

let exp_time =
std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(1720547781);
let _ = url.set_exp(Some(exp_time));
url.set_exp(Some(exp_time));
assert_eq!(url.fragment(), Some("exp=1720547781"));

assert_eq!(url.exp(), Some(exp_time));

let _ = url.set_exp(None);
url.set_exp(None);
assert_eq!(url.fragment(), None);
}

Expand Down
43 changes: 18 additions & 25 deletions payjoin/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ mod integration {
let port = find_free_port();
let directory = Url::parse(&format!("https://localhost:{}", port)).unwrap();
tokio::select!(
_ = init_directory(port, (cert.clone(), key)) => assert!(false, "Directory server is long running"),
_ = init_directory(port, (cert.clone(), key)) => panic!("Directory server is long running"),
res = try_request_with_bad_keys(directory, bad_ohttp_keys, cert) => {
assert_eq!(
res.unwrap().headers().get("content-type").unwrap(),
Expand Down Expand Up @@ -239,8 +239,8 @@ mod integration {
let directory = Url::parse(&format!("https://localhost:{}", directory_port)).unwrap();
let gateway_origin = http::Uri::from_str(directory.as_str()).unwrap();
tokio::select!(
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => assert!(false, "Directory server is long running"),
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => panic!("Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => panic!("Directory server is long running"),
res = do_expiration_tests(ohttp_relay, directory, cert) => assert!(res.is_ok(), "v2 send receive failed: {:#?}", res)
);

Expand Down Expand Up @@ -270,7 +270,7 @@ mod integration {
match session.extract_req() {
// Internal error types are private, so check against a string
Err(err) => assert!(err.to_string().contains("expired")),
_ => assert!(false, "Expired receive session should error"),
_ => panic!("Expired receive session should error"),
};
let pj_uri = session.pj_uri_builder().build();

Expand All @@ -290,7 +290,7 @@ mod integration {
match expired_req_ctx.extract_highest_version(directory.to_owned()) {
// Internal error types are private, so check against a string
Err(err) => assert!(err.to_string().contains("expired")),
_ => assert!(false, "Expired send session should error"),
_ => panic!("Expired send session should error"),
};
Ok(())
}
Expand All @@ -307,8 +307,8 @@ mod integration {
let directory = Url::parse(&format!("https://localhost:{}", directory_port)).unwrap();
let gateway_origin = http::Uri::from_str(directory.as_str()).unwrap();
tokio::select!(
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => assert!(false, "Directory server is long running"),
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => panic!("Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => panic!("Directory server is long running"),
res = do_v2_send_receive(ohttp_relay, directory, cert) => assert!(res.is_ok(), "v2 send receive failed: {:#?}", res)
);

Expand Down Expand Up @@ -443,8 +443,8 @@ mod integration {
let directory = Url::parse(&format!("https://localhost:{}", directory_port)).unwrap();
let gateway_origin = http::Uri::from_str(directory.as_str()).unwrap();
tokio::select!(
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => assert!(false, "Directory server is long running"),
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => panic!("Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => panic!("Directory server is long running"),
res = do_v2_send_receive(ohttp_relay, directory, cert) => assert!(res.is_ok(), "v2 send receive failed: {:#?}", res)
);

Expand Down Expand Up @@ -667,8 +667,8 @@ mod integration {
let directory = Url::parse(&format!("https://localhost:{}", directory_port)).unwrap();
let gateway_origin = http::Uri::from_str(directory.as_str()).unwrap();
tokio::select!(
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => assert!(false, "Directory server is long running"),
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => panic!("Ohttp relay is long running"),
_ = init_directory(directory_port, (cert.clone(), key)) => panic!("Directory server is long running"),
res = do_v1_to_v2(ohttp_relay, directory, cert) => assert!(res.is_ok()),
);

Expand Down Expand Up @@ -795,7 +795,7 @@ mod integration {
) -> Result<(), BoxError> {
let docker: Cli = Cli::default();
let timeout = Duration::from_secs(2);
let db = docker.run(Redis::default());
let db = docker.run(Redis);
let db_host = format!("127.0.0.1:{}", db.get_host_port_ipv4(6379));
println!("Database running on {}", db.get_host_port_ipv4(6379));
payjoin_directory::listen_tcp_with_tls(port, db_host, timeout, local_cert_key).await
Expand Down Expand Up @@ -853,7 +853,7 @@ mod integration {
let proposal = proposal
.check_inputs_not_owned(|input| {
let address =
bitcoin::Address::from_script(&input, bitcoin::Network::Regtest).unwrap();
bitcoin::Address::from_script(input, bitcoin::Network::Regtest).unwrap();
Ok(receiver.get_address_info(&address).unwrap().is_mine.unwrap())
})
.expect("Receiver should not own any of the inputs");
Expand All @@ -864,7 +864,7 @@ mod integration {
.unwrap()
.identify_receiver_outputs(|output_script| {
let address =
bitcoin::Address::from_script(&output_script, bitcoin::Network::Regtest)
bitcoin::Address::from_script(output_script, bitcoin::Network::Regtest)
.unwrap();
Ok(receiver.get_address_info(&address).unwrap().is_mine.unwrap())
})
Expand Down Expand Up @@ -892,7 +892,7 @@ mod integration {
let payjoin = payjoin.contribute_inputs(inputs).unwrap().commit_inputs();

// Sign and finalize the proposal PSBT
let payjoin_proposal = payjoin
payjoin
.finalize_proposal(
|psbt: &Psbt| {
Ok(receiver
Expand All @@ -902,17 +902,13 @@ mod integration {
None,
Some(true), // check that the receiver properly clears keypaths
)
.map(|res: WalletProcessPsbtResult| {
let psbt = Psbt::from_str(&res.psbt).unwrap();
return psbt;
})
.map(|res: WalletProcessPsbtResult| Psbt::from_str(&res.psbt).unwrap())
.unwrap())
},
Some(FeeRate::BROADCAST_MIN),
FeeRate::from_sat_per_vb_unchecked(2),
)
.unwrap();
payjoin_proposal
.unwrap()
}

fn http_agent(cert_der: Vec<u8>) -> Result<Client, BoxError> {
Expand Down Expand Up @@ -1328,10 +1324,7 @@ mod integration {
None,
Some(true), // check that the receiver properly clears keypaths
)
.map(|res: WalletProcessPsbtResult| {
let psbt = Psbt::from_str(&res.psbt).unwrap();
psbt
})
.map(|res: WalletProcessPsbtResult| Psbt::from_str(&res.psbt).unwrap())
.unwrap())
},
Some(FeeRate::BROADCAST_MIN),
Expand Down

0 comments on commit 19f93d3

Please sign in to comment.