diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4f5164f..f36e5b01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v3.3.0 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.63 + components: clippy,rustfmt + - uses: Swatinem/rust-cache@v2.2.1 - name: Check formatting diff --git a/dprint.json b/dprint.json index 18c300b2..8f18b0bf 100644 --- a/dprint.json +++ b/dprint.json @@ -3,22 +3,16 @@ "projectType": "openSource", "incremental": true, "markdown": {}, - "rustfmt": { - "edition": 2021, - "condense_wildcard_suffixes": true, - "format_macro_matchers": true, - "imports_granularity": "Module", - "use_field_init_shorthand": true, - "format_code_in_doc_comments": true, - "normalize_comments": true, - "wrap_comments": true, - "overflow_delimited_expr": true + "exec": { + "associations": "**/*.{rs}", + "rustfmt": "rustfmt --edition 2021", + "rustfmt.associations": "**/*.rs" }, "includes": ["**/*.{md}", "**/*.{toml}", "**/*.{rs}"], "excludes": ["target/"], "plugins": [ "https://plugins.dprint.dev/markdown-0.13.1.wasm", "https://github.com/thomaseizinger/dprint-plugin-cargo-toml/releases/download/0.1.0/cargo-toml-0.1.0.wasm", - "https://plugins.dprint.dev/rustfmt-0.6.1.exe-plugin@99b89a0599fd3a63e597e03436862157901f3facae2f0c2fbd0b9f656cdbc2a5" + "https://plugins.dprint.dev/exec-0.3.5.json@d687dda57be0fe9a0088ccdaefa5147649ff24127d8b3ea227536c68ee7abeab" ] } diff --git a/monero-rpc/src/monerod.rs b/monero-rpc/src/monerod.rs index 830aafdb..c2cde67c 100644 --- a/monero-rpc/src/monerod.rs +++ b/monero-rpc/src/monerod.rs @@ -47,9 +47,10 @@ impl Client { } pub async fn get_o_indexes(&self, txid: Hash) -> Result { - self.binary_request(self.get_o_indexes_bin_url.clone(), GetOIndexesPayload { - txid, - }) + self.binary_request( + self.get_o_indexes_bin_url.clone(), + GetOIndexesPayload { txid }, + ) .await } diff --git a/swap/src/bitcoin/cancel.rs b/swap/src/bitcoin/cancel.rs index 354b0c00..35b6b197 100644 --- a/swap/src/bitcoin/cancel.rs +++ b/swap/src/bitcoin/cancel.rs @@ -210,14 +210,20 @@ impl TxCancel { }; // The order in which these are inserted doesn't matter - satisfier.insert(A, ::bitcoin::EcdsaSig { - sig: sig_a.into(), - hash_ty: EcdsaSighashType::All, - }); - satisfier.insert(B, ::bitcoin::EcdsaSig { - sig: sig_b.into(), - hash_ty: EcdsaSighashType::All, - }); + satisfier.insert( + A, + ::bitcoin::EcdsaSig { + sig: sig_a.into(), + hash_ty: EcdsaSighashType::All, + }, + ); + satisfier.insert( + B, + ::bitcoin::EcdsaSig { + sig: sig_b.into(), + hash_ty: EcdsaSighashType::All, + }, + ); satisfier }; diff --git a/swap/src/bitcoin/punish.rs b/swap/src/bitcoin/punish.rs index df7a1367..247c904f 100644 --- a/swap/src/bitcoin/punish.rs +++ b/swap/src/bitcoin/punish.rs @@ -65,14 +65,20 @@ impl TxPunish { let B = B.try_into()?; // The order in which these are inserted doesn't matter - satisfier.insert(A, ::bitcoin::EcdsaSig { - sig: sig_a.into(), - hash_ty: EcdsaSighashType::All, - }); - satisfier.insert(B, ::bitcoin::EcdsaSig { - sig: sig_b.into(), - hash_ty: EcdsaSighashType::All, - }); + satisfier.insert( + A, + ::bitcoin::EcdsaSig { + sig: sig_a.into(), + hash_ty: EcdsaSighashType::All, + }, + ); + satisfier.insert( + B, + ::bitcoin::EcdsaSig { + sig: sig_b.into(), + hash_ty: EcdsaSighashType::All, + }, + ); satisfier }; diff --git a/swap/src/bitcoin/redeem.rs b/swap/src/bitcoin/redeem.rs index d94f03d9..e91c25ee 100644 --- a/swap/src/bitcoin/redeem.rs +++ b/swap/src/bitcoin/redeem.rs @@ -87,14 +87,20 @@ impl TxRedeem { }; // The order in which these are inserted doesn't matter - satisfier.insert(A, ::bitcoin::EcdsaSig { - sig: sig_a.into(), - hash_ty: EcdsaSighashType::All, - }); - satisfier.insert(B, ::bitcoin::EcdsaSig { - sig: sig_b.into(), - hash_ty: EcdsaSighashType::All, - }); + satisfier.insert( + A, + ::bitcoin::EcdsaSig { + sig: sig_a.into(), + hash_ty: EcdsaSighashType::All, + }, + ); + satisfier.insert( + B, + ::bitcoin::EcdsaSig { + sig: sig_b.into(), + hash_ty: EcdsaSighashType::All, + }, + ); satisfier }; diff --git a/swap/src/bitcoin/refund.rs b/swap/src/bitcoin/refund.rs index 55aa6c25..a73dd0e3 100644 --- a/swap/src/bitcoin/refund.rs +++ b/swap/src/bitcoin/refund.rs @@ -70,14 +70,20 @@ impl TxRefund { }; // The order in which these are inserted doesn't matter - satisfier.insert(A, ::bitcoin::EcdsaSig { - sig: sig_a.into(), - hash_ty: EcdsaSighashType::All, - }); - satisfier.insert(B, ::bitcoin::EcdsaSig { - sig: sig_b.into(), - hash_ty: EcdsaSighashType::All, - }); + satisfier.insert( + A, + ::bitcoin::EcdsaSig { + sig: sig_a.into(), + hash_ty: EcdsaSighashType::All, + }, + ); + satisfier.insert( + B, + ::bitcoin::EcdsaSig { + sig: sig_b.into(), + hash_ty: EcdsaSighashType::All, + }, + ); satisfier }; diff --git a/swap/src/cli/list_sellers.rs b/swap/src/cli/list_sellers.rs index 95a52386..381c561f 100644 --- a/swap/src/cli/list_sellers.rs +++ b/swap/src/cli/list_sellers.rs @@ -350,23 +350,26 @@ mod tests { list.sort(); - assert_eq!(list, vec![ - Seller { - multiaddr: "/ip4/127.0.0.1/tcp/5678".parse().unwrap(), - status: Status::Online(BidQuote { - price: Default::default(), - min_quantity: Default::default(), - max_quantity: Default::default(), - }) - }, - Seller { - multiaddr: Multiaddr::empty(), - status: Status::Unreachable - }, - Seller { - multiaddr: "/ip4/127.0.0.1/tcp/1234".parse().unwrap(), - status: Status::Unreachable - }, - ]) + assert_eq!( + list, + vec![ + Seller { + multiaddr: "/ip4/127.0.0.1/tcp/5678".parse().unwrap(), + status: Status::Online(BidQuote { + price: Default::default(), + min_quantity: Default::default(), + max_quantity: Default::default(), + }) + }, + Seller { + multiaddr: Multiaddr::empty(), + status: Status::Unreachable + }, + Seller { + multiaddr: "/ip4/127.0.0.1/tcp/1234".parse().unwrap(), + status: Status::Unreachable + }, + ] + ) } } diff --git a/swap/src/network/swap_setup/bob.rs b/swap/src/network/swap_setup/bob.rs index 18972319..bee70c24 100644 --- a/swap/src/network/swap_setup/bob.rs +++ b/swap/src/network/swap_setup/bob.rs @@ -155,13 +155,16 @@ impl ProtocolsHandler for Handler { let env_config = self.env_config; let protocol = tokio::time::timeout(self.timeout, async move { - write_cbor_message(&mut substream, SpotPriceRequest { - btc: info.btc, - blockchain_network: BlockchainNetwork { - bitcoin: env_config.bitcoin_network, - monero: env_config.monero_network, + write_cbor_message( + &mut substream, + SpotPriceRequest { + btc: info.btc, + blockchain_network: BlockchainNetwork { + bitcoin: env_config.bitcoin_network, + monero: env_config.monero_network, + }, }, - }) + ) .await?; let xmr = Result::from(read_cbor_message::(&mut substream).await?)?; diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index 9dcf3f46..b34e0326 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -184,29 +184,32 @@ impl State0 { let v = self.v_a + msg.v_b; - Ok((msg.swap_id, State1 { - a: self.a, - B: msg.B, - s_a: self.s_a, - S_a_monero: self.S_a_monero, - S_a_bitcoin: self.S_a_bitcoin, - S_b_monero: msg.S_b_monero, - S_b_bitcoin: msg.S_b_bitcoin, - v, - v_a: self.v_a, - dleq_proof_s_a: self.dleq_proof_s_a, - btc: self.btc, - xmr: self.xmr, - cancel_timelock: self.cancel_timelock, - punish_timelock: self.punish_timelock, - refund_address: msg.refund_address, - redeem_address: self.redeem_address, - punish_address: self.punish_address, - tx_redeem_fee: self.tx_redeem_fee, - tx_punish_fee: self.tx_punish_fee, - tx_refund_fee: msg.tx_refund_fee, - tx_cancel_fee: msg.tx_cancel_fee, - })) + Ok(( + msg.swap_id, + State1 { + a: self.a, + B: msg.B, + s_a: self.s_a, + S_a_monero: self.S_a_monero, + S_a_bitcoin: self.S_a_bitcoin, + S_b_monero: msg.S_b_monero, + S_b_bitcoin: msg.S_b_bitcoin, + v, + v_a: self.v_a, + dleq_proof_s_a: self.dleq_proof_s_a, + btc: self.btc, + xmr: self.xmr, + cancel_timelock: self.cancel_timelock, + punish_timelock: self.punish_timelock, + refund_address: msg.refund_address, + redeem_address: self.redeem_address, + punish_address: self.punish_address, + tx_redeem_fee: self.tx_redeem_fee, + tx_punish_fee: self.tx_punish_fee, + tx_refund_fee: msg.tx_refund_fee, + tx_cancel_fee: msg.tx_cancel_fee, + }, + )) } } diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index 74afcc83..e10ce19e 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -158,13 +158,16 @@ async fn init_containers(cli: &Cli) -> (Monero, Containers<'_>) { .await .unwrap(); - (monero, Containers { - bitcoind_url, - bitcoind, - monerod_container, - monero_wallet_rpc_containers, - electrs, - }) + ( + monero, + Containers { + bitcoind_url, + bitcoind, + monerod_container, + monero_wallet_rpc_containers, + electrs, + }, + ) } async fn init_bitcoind_container(