From f38ac2e95fca11b88402d593d00488740eb95161 Mon Sep 17 00:00:00 2001 From: Alastair Holmes Date: Thu, 15 Feb 2024 16:16:45 +0100 Subject: [PATCH 1/3] correct json snapshots --- ...witnessing__state_chain__tests__handle_deposit_calls-2.snap | 3 ++- ...witnessing__state_chain__tests__handle_deposit_calls-3.snap | 3 ++- ...witnessing__state_chain__tests__handle_deposit_calls-4.snap | 3 ++- ...__witnessing__state_chain__tests__handle_deposit_calls.snap | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-2.snap b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-2.snap index 6a2aa971ef..2bc2890ef3 100644 --- a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-2.snap +++ b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-2.snap @@ -1,5 +1,6 @@ --- source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs +assertion_line: 487 expression: "store.storage.get(format!(\"deposit:Polkadot:{}\", format!\n (\"0x{}\", hex ::\n encode(polkadot_account_id.aliased_ref()))).as_str()).unwrap()" --- -[{"amount":"0x64","asset":"DOT","deposit_chain_block_height":1}] +[{"amount":"0x64","asset":{"asset":"DOT","chain":"Polkadot"},"deposit_chain_block_height":1}] diff --git a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-3.snap b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-3.snap index 32de04a380..aafc0683b6 100644 --- a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-3.snap +++ b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-3.snap @@ -1,5 +1,6 @@ --- source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs +assertion_line: 497 expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str2.to_lowercase()).as_str()).unwrap()" --- -[{"amount":"0x64","asset":"ETH","deposit_chain_block_height":1}] +[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}] diff --git a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-4.snap b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-4.snap index 7df5c26271..242c6f9a20 100644 --- a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-4.snap +++ b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls-4.snap @@ -1,5 +1,6 @@ --- source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs +assertion_line: 521 expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str1.to_lowercase()).as_str()).unwrap()" --- -[{"amount":"0x64","asset":"ETH","deposit_chain_block_height":1},{"amount":"0x1e8480","asset":"ETH","deposit_chain_block_height":1}] +[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1},{"amount":"0x1e8480","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}] diff --git a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls.snap b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls.snap index ec4a4cf844..fa3c0c426d 100644 --- a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls.snap +++ b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/snapshots/chainflip_ingress_egress_tracker__witnessing__state_chain__tests__handle_deposit_calls.snap @@ -1,5 +1,6 @@ --- source: api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs +assertion_line: 483 expression: "store.storage.get(format!(\"deposit:Ethereum:{}\",\n eth_address_str1.to_lowercase()).as_str()).unwrap()" --- -[{"amount":"0x64","asset":"ETH","deposit_chain_block_height":1}] +[{"amount":"0x64","asset":{"asset":"ETH","chain":"Ethereum"},"deposit_chain_block_height":1}] From 1d65cab32d7fb5cb6253ca951e4528d1eddd1b7c Mon Sep 17 00:00:00 2001 From: Alastair Holmes Date: Thu, 15 Feb 2024 16:35:21 +0100 Subject: [PATCH 2/3] enable all tests --- .cargo/config.toml | 6 +++--- api/bin/chainflip-cli/src/settings.rs | 2 ++ state-chain/pallets/cf-governance/README.md | 8 ++++---- utilities/src/with_std/task_scope.rs | 15 +++++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 46120b8d72..7de152d9f2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,9 +9,9 @@ CF_TEST_CONFIG_ROOT = { value = "engine/config/testing", relative = true } # `rustup completions --help` to find out how to set this up. [alias] -cf-test = "test --lib --features runtime-benchmarks,try-runtime" -cf-test-ci = "test --release --lib --features runtime-benchmarks,slow-tests,try-runtime" -cf-test-cfe = "test --lib --package chainflip-engine --package multisig" +cf-test = "test --features runtime-benchmarks,try-runtime" +cf-test-ci = "test --release --features runtime-benchmarks,slow-tests,try-runtime" +cf-test-cfe = "test --package chainflip-engine --package multisig" cf-clippy = "clippy --all-targets --features runtime-benchmarks,try-runtime,runtime-integration-tests,slow-tests -- -D warnings -A deprecated" cf-clippy-ci = "clippy --all-targets --features runtime-benchmarks,try-runtime,runtime-integration-tests,slow-tests -- -D warnings -A deprecated" diff --git a/api/bin/chainflip-cli/src/settings.rs b/api/bin/chainflip-cli/src/settings.rs index f925304316..4940d0d241 100644 --- a/api/bin/chainflip-cli/src/settings.rs +++ b/api/bin/chainflip-cli/src/settings.rs @@ -279,6 +279,7 @@ mod tests { } #[test] + #[ignore = "Requires config file at root"] fn init_default_config() { set_test_env(); @@ -294,6 +295,7 @@ mod tests { } #[test] + #[ignore = "Requires config file at default root"] fn test_all_command_line_options() { // Fill the options with test values that will pass the parsing/validation. // The test values need to be different from the default values set during `set_defaults()` diff --git a/state-chain/pallets/cf-governance/README.md b/state-chain/pallets/cf-governance/README.md index 083ebab7ee..c5ba092dc6 100644 --- a/state-chain/pallets/cf-governance/README.md +++ b/state-chain/pallets/cf-governance/README.md @@ -24,20 +24,20 @@ Every Proposal has an expiry date. If a Proposal is not able to raise enough App ## Usage -To secure an extrinsic via Governance, implement the following trait. +To secure an extrinsic via Governance, add the following to your pallet's Config. -```rust +```rust(ignore) type EnsureGovernance: EnsureOrigin<::Origin>; ``` You must also configure the EnsureGovernance struct for your pallet in the runtime configuration: -```rust +```rust(ignore) type EnsureGovernance = pallet_cf_governance::EnsureGovernance; ``` To ensure extrinsics you need to make use of the EnsureGovernance struct. Pass the calling origin like in this example to ensure an extrinsic is only executable via the Governance origin: -```rust +```rust(ignore) T::EnsureGovernance::ensure_origin(origin)?; ``` diff --git a/utilities/src/with_std/task_scope.rs b/utilities/src/with_std/task_scope.rs index d4f14ed0a6..402b7ae9a3 100644 --- a/utilities/src/with_std/task_scope.rs +++ b/utilities/src/with_std/task_scope.rs @@ -34,7 +34,7 @@ //! task_scope system has no method to force spawn_blocking tasks to end/cancel, so they must handle //! exiting themselves. For example: //! -//! ```rust +//! ```rust(ignore) //! { //! let (sender, receiver) = std::sync::mpsc::channel(10); //! @@ -68,7 +68,7 @@ //! If you don't do the above when an error occurs the scope will not ever exit, and will wait for //! the spawn_blocking to exit forever i.e. if the spawn_blocking was like this instead: //! -//! ```rust +//! ```rust(ignore) //! { //! scope.spawn_blocking(|| { //! loop { @@ -309,15 +309,22 @@ pub struct Scope<'env, Error: Debug + Send + 'static> { /// Without invariance, this would compile fine but be unsound: /// /// ```compile_fail,E0373 + /// use utilities::task_scope::task_scope; + /// use futures::FutureExt; + /// /// let mut a = 1; - /// task_scope(|scope| { + /// task_scope::<(), (), _>(|scope| async move { /// scope.spawn(async { /// a += 1; + /// Ok(()) /// }); /// scope.spawn(async { /// a += 1; // might run concurrently to other spawn + /// Ok(()) /// }); - /// }); + /// + /// Ok(()) + /// }.boxed()); /// ``` _phantom: std::marker::PhantomData<&'env mut &'env ()>, } From e4433aef8bdda348677fb97f2506f53d71794268 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 15 Feb 2024 16:58:04 +0100 Subject: [PATCH 3/3] clippy --- utilities/src/with_std/task_scope.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/src/with_std/task_scope.rs b/utilities/src/with_std/task_scope.rs index 402b7ae9a3..e99d63f59b 100644 --- a/utilities/src/with_std/task_scope.rs +++ b/utilities/src/with_std/task_scope.rs @@ -316,14 +316,14 @@ pub struct Scope<'env, Error: Debug + Send + 'static> { /// task_scope::<(), (), _>(|scope| async move { /// scope.spawn(async { /// a += 1; - /// Ok(()) + /// Ok(()) /// }); /// scope.spawn(async { /// a += 1; // might run concurrently to other spawn - /// Ok(()) + /// Ok(()) /// }); /// - /// Ok(()) + /// Ok(()) /// }.boxed()); /// ``` _phantom: std::marker::PhantomData<&'env mut &'env ()>,