Skip to content

Commit

Permalink
Lint using cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 3, 2024
1 parent 395ab0a commit 4fd75a2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@ jobs:
run: cargo build --color always --all-targets --features _danger-local-https
- name: Check formatting (nightly only)
if: matrix.rust == 'nightly'
run: rustup component add rustfmt && cargo fmt --all -- --check
run: rustup component add rustfmt && cargo fmt --all -- --check\

Lint:
runs-on: ubuntu-latest
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
- name: "Install nightly toolchain"
uses: dtolnay/rust-toolchain@nightly
- name: "Use cache"
uses: Swatinem/rust-cache@v2
- name: "Install clippy"
run: rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu
- name: "Run linting"
run: bash contrib/lint.sh
12 changes: 6 additions & 6 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use crate::uri::Url;
/// Fetch the ohttp keys from the specified payjoin directory via proxy.
///
/// * `ohttp_relay`: The http CONNNECT method proxy to request the ohttp keys from a payjoin
/// directory. Proxying requests for ohttp keys ensures a client IP address is never revealed to
/// the payjoin directory.
/// directory. Proxying requests for ohttp keys ensures a client IP address is never revealed to
/// the payjoin directory.
///
/// * `payjoin_directory`: The payjoin directory from which to fetch the ohttp keys. This
/// directory stores and forwards payjoin client payloads.
/// directory stores and forwards payjoin client payloads.
#[cfg(not(feature = "_danger-local-https"))]
pub async fn fetch_ohttp_keys(
ohttp_relay: Url,
Expand All @@ -24,11 +24,11 @@ pub async fn fetch_ohttp_keys(
/// Fetch the ohttp keys from the specified payjoin directory via proxy.
///
/// * `ohttp_relay`: The http CONNNECT method proxy to request the ohttp keys from a payjoin
/// directory. Proxying requests for ohttp keys ensures a client IP address is never revealed to
/// the payjoin directory.
/// directory. Proxying requests for ohttp keys ensures a client IP address is never revealed to
/// the payjoin directory.
///
/// * `payjoin_directory`: The payjoin directory from which to fetch the ohttp keys. This
/// directory stores and forwards payjoin client payloads.
/// directory stores and forwards payjoin client payloads.
///
/// * `cert_der`: The DER-encoded certificate to use for local HTTPS connections.
#[cfg(feature = "_danger-local-https")]
Expand Down
6 changes: 3 additions & 3 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl From<payjoin::Uri<'static, NetworkChecked>> for Uri {
}

impl Uri {
pub fn from_str(uri: String) -> Result<Self, PayjoinError> {
pub fn parse(uri: String) -> Result<Self, PayjoinError> {
match payjoin::Uri::from_str(uri.as_str()) {
Ok(e) => Ok(e.assume_checked().into()),
Err(e) => Err(PayjoinError::PjParseError { message: e.to_string() }),
Expand Down Expand Up @@ -110,8 +110,8 @@ pub struct Url(payjoin::Url);
#[cfg_attr(feature = "uniffi", uniffi::export)]
impl Url {
#[cfg_attr(feature = "uniffi", uniffi::constructor)]
pub fn from_str(input: String) -> Result<Url, PayjoinError> {
match payjoin::Url::from_str(input.as_str()) {
pub fn parse(input: String) -> Result<Url, PayjoinError> {
match payjoin::Url::parse(input.as_str()) {
Ok(e) => Ok(Self(e)),
Err(e) => Err(PayjoinError::UnexpectedError { message: e.to_string() }),
}
Expand Down
6 changes: 3 additions & 3 deletions tests/bdk_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ mod v2 {
async fn v2_to_v2_full_cycle() {
let (cert, key) = local_cert_key();
let ohttp_relay_port = find_free_port();
let ohttp_relay = Url::from_str(format!("http://localhost:{}", ohttp_relay_port)).unwrap();
let ohttp_relay = Url::parse(format!("http://localhost:{}", ohttp_relay_port)).unwrap();
let directory_port = find_free_port();
let directory = Url::from_str(format!("https://localhost:{}", directory_port)).unwrap();
let directory = Url::parse(format!("https://localhost:{}", directory_port)).unwrap();
let gateway_origin = http::Uri::from_str(directory.as_string().as_str()).unwrap();
tokio::select!(
_ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"),
Expand Down Expand Up @@ -289,7 +289,7 @@ mod v2 {
// **********************
// Inside the Sender:
// Create a funded PSBT (not broadcasted) to address with amount given in the pj_uri
let pj_uri = Uri::from_str(pj_uri_string).unwrap().check_pj_supported().unwrap();
let pj_uri = Uri::parse(pj_uri_string).unwrap().check_pj_supported().unwrap();
let psbt = build_original_psbt(&sender, &pj_uri)?;
println!("\nOriginal sender psbt: {:#?}", psbt.to_string());

Expand Down

0 comments on commit 4fd75a2

Please sign in to comment.