diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 13295dde..b7ef3a77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,11 @@ jobs: if [ "${{ matrix.msrv }}" = "true" ]; then rustup component add clippy; fi - name: Check formatting if: matrix.check-fmt - run: rustup component add rustfmt && cargo fmt --all -- --check + run: | + rustup component add rustfmt + cargo fmt --all -- --check + # e2e-tests is excluded from the workspace and must be checked separately + cargo fmt --manifest-path e2e-tests/Cargo.toml --all -- --check - name: Pin packages to allow for MSRV if: matrix.msrv run: | diff --git a/.github/workflows/cron-weekly-rustfmt.yml b/.github/workflows/cron-weekly-rustfmt.yml index 9e54ab9f..ec5b69b6 100644 --- a/.github/workflows/cron-weekly-rustfmt.yml +++ b/.github/workflows/cron-weekly-rustfmt.yml @@ -19,7 +19,7 @@ jobs: components: rustfmt - name: Run Nightly rustfmt # Run the formatter and manually remove trailing whitespace. - run: cargo +nightly fmt && git ls-files -- '*.rs' -z | xargs sed -E -i'' -e 's/[[:space:]]+$//' + run: cargo +nightly fmt && cargo +nightly fmt --manifest-path e2e-tests/Cargo.toml && git ls-files -- '*.rs' -z | xargs sed -E -i'' -e 's/[[:space:]]+$//' - name: Get the current date run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Create Pull Request diff --git a/CLAUDE.md b/CLAUDE.md index 49fb0361..f819ff18 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,6 +14,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for build commands, testing, code style, ## Development Rules - Always ensure tests pass and lints are fixed before committing -- Run `cargo fmt --all` after every code change +- Run `cargo fmt --all` and `cargo fmt --manifest-path e2e-tests/Cargo.toml --all` after every code change. + The `e2e-tests` crate is excluded from the workspace, so it must be formatted separately. - Never add new dependencies unless explicitly requested - Please always disclose the use of any AI tools in commit messages and PR descriptions diff --git a/e2e-tests/src/lib.rs b/e2e-tests/src/lib.rs index a3cc8545..18946894 100644 --- a/e2e-tests/src/lib.rs +++ b/e2e-tests/src/lib.rs @@ -139,8 +139,12 @@ pub enum ChainSource { rpc_password: String, rest_address: Option, }, - Electrum { server_url: String }, - Esplora { server_url: String }, + Electrum { + server_url: String, + }, + Esplora { + server_url: String, + }, } impl ChainSource { @@ -793,9 +797,7 @@ pub async fn setup_funded_channel( .open_channel(OpenChannelRequest { node_pubkey: server_b.node_id().to_string(), address: format!("127.0.0.1:{}", server_b.p2p_port), - amount: Some(open_channel_request::Amount::ChannelAmountSats( - channel_amount_sats, - )), + amount: Some(open_channel_request::Amount::ChannelAmountSats(channel_amount_sats)), push_to_counterparty_msat: None, channel_config: None, announce_channel: true, diff --git a/e2e-tests/tests/e2e.rs b/e2e-tests/tests/e2e.rs index 1b7001f3..c3a9f374 100644 --- a/e2e-tests/tests/e2e.rs +++ b/e2e-tests/tests/e2e.rs @@ -501,13 +501,7 @@ async fn open_channel_via_cli(channel_amount: &str) { let addr = format!("127.0.0.1:{}", server_b.p2p_port); let output = run_cli( &server_a, - &[ - "open-channel", - server_b.node_id(), - &addr, - channel_amount, - "--announce-channel", - ], + &["open-channel", server_b.node_id(), &addr, channel_amount, "--announce-channel"], ); assert!(!output["user_channel_id"].as_str().unwrap().is_empty()); } @@ -544,9 +538,7 @@ async fn test_subscribe_events_channel_state_lifecycle_pending_ready_closed() { .open_channel(OpenChannelRequest { node_pubkey: server_b.node_id().to_string(), address: format!("127.0.0.1:{}", server_b.p2p_port), - amount: Some(open_channel_request::Amount::ChannelAmountSats( - 100_000, - )), + amount: Some(open_channel_request::Amount::ChannelAmountSats(100_000)), push_to_counterparty_msat: None, channel_config: None, announce_channel: true, @@ -574,7 +566,10 @@ async fn test_subscribe_events_channel_state_lifecycle_pending_ready_closed() { assert!(pending_a.reason.is_none()); assert_eq!(pending_a.closure_initiator, ChannelClosureInitiator::Unspecified as i32); assert!(pending_a.former_temporary_channel_id.as_deref().is_some_and(|id| !id.is_empty())); - assert_ne!(pending_a.former_temporary_channel_id.as_deref(), Some(pending_a.channel_id.as_str())); + assert_ne!( + pending_a.former_temporary_channel_id.as_deref(), + Some(pending_a.channel_id.as_str()) + ); let pending_b = wait_for_event(&mut events_b, |e| { matches!( @@ -712,9 +707,7 @@ async fn test_subscribe_events_channel_state_lifecycle_pending_ready_force_close .open_channel(OpenChannelRequest { node_pubkey: server_b.node_id().to_string(), address: format!("127.0.0.1:{}", server_b.p2p_port), - amount: Some(open_channel_request::Amount::ChannelAmountSats( - 100_000, - )), + amount: Some(open_channel_request::Amount::ChannelAmountSats(100_000)), push_to_counterparty_msat: None, channel_config: None, announce_channel: true, @@ -742,7 +735,10 @@ async fn test_subscribe_events_channel_state_lifecycle_pending_ready_force_close assert!(pending_a.reason.is_none()); assert_eq!(pending_a.closure_initiator, ChannelClosureInitiator::Unspecified as i32); assert!(pending_a.former_temporary_channel_id.as_deref().is_some_and(|id| !id.is_empty())); - assert_ne!(pending_a.former_temporary_channel_id.as_deref(), Some(pending_a.channel_id.as_str())); + assert_ne!( + pending_a.former_temporary_channel_id.as_deref(), + Some(pending_a.channel_id.as_str()) + ); let pending_b = wait_for_event(&mut events_b, |e| { matches!( @@ -1335,14 +1331,11 @@ async fn splice_in_via_cli(splice_amount: &str) { let mut events_a = server_a.client().subscribe_events().await.unwrap(); - let output = run_cli( - &server_a, - &["splice-in", &user_channel_id, server_b.node_id(), splice_amount], - ); + let output = + run_cli(&server_a, &["splice-in", &user_channel_id, server_b.node_id(), splice_amount]); assert!(output.is_object()); - let event_a = - wait_for_event(&mut events_a, |e| matches!(e, Event::SpliceNegotiated(_))).await; + let event_a = wait_for_event(&mut events_a, |e| matches!(e, Event::SpliceNegotiated(_))).await; match &event_a.event { Some(Event::SpliceNegotiated(splice_negotiated)) => { assert_eq!(splice_negotiated.user_channel_id, user_channel_id); @@ -1884,10 +1877,7 @@ async fn test_hodl_invoice_fail() { panic!("expected PaymentFailed"); }; assert!(!failed.payment.as_ref().unwrap().payment_id.is_empty()); - assert_eq!( - failed.reason, - Some(PaymentFailureReason::RecipientRejected as i32) - ); + assert_eq!(failed.reason, Some(PaymentFailureReason::RecipientRejected as i32)); } #[tokio::test]