From 034d3d1f799109f7f9cf465f2658fe3d0482127c Mon Sep 17 00:00:00 2001 From: girazoki Date: Fri, 10 Jan 2025 14:46:34 +0100 Subject: [PATCH] cleanup some tests --- .../dancelight/src/tests/common/mod.rs | 4 ++ .../src/tests/external_validators_tests.rs | 27 ------- .../runtime/dancelight/src/tests/slashes.rs | 70 ------------------- 3 files changed, 4 insertions(+), 97 deletions(-) diff --git a/chains/orchestrator-relays/runtime/dancelight/src/tests/common/mod.rs b/chains/orchestrator-relays/runtime/dancelight/src/tests/common/mod.rs index c29fc5bc7..9ee7ed2b9 100644 --- a/chains/orchestrator-relays/runtime/dancelight/src/tests/common/mod.rs +++ b/chains/orchestrator-relays/runtime/dancelight/src/tests/common/mod.rs @@ -677,6 +677,10 @@ impl ExtBuilder { .unwrap(); snowbridge_pallet_system::GenesisConfig:: { + // This is irrelevant, we can put any number here + // as long as it is a non-used para id + para_id: 1000u32.into(), + asset_hub_para_id: 1001u32.into(), ..Default::default() } .assimilate_storage(&mut t) diff --git a/chains/orchestrator-relays/runtime/dancelight/src/tests/external_validators_tests.rs b/chains/orchestrator-relays/runtime/dancelight/src/tests/external_validators_tests.rs index 2316e4949..5ed05c02e 100644 --- a/chains/orchestrator-relays/runtime/dancelight/src/tests/external_validators_tests.rs +++ b/chains/orchestrator-relays/runtime/dancelight/src/tests/external_validators_tests.rs @@ -23,10 +23,6 @@ use { }, frame_support::{assert_ok, traits::fungible::Mutate}, pallet_external_validators::Forcing, - parity_scale_codec::Encode, - snowbridge_core::{Channel, PRIMARY_GOVERNANCE_CHANNEL}, - sp_core::H256, - sp_io::hashing::twox_64, std::{collections::HashMap, ops::RangeInclusive}, }; @@ -710,29 +706,6 @@ fn external_validators_rewards_sends_message_on_era_end() { // SessionsPerEra depends on fast-runtime feature, this test should pass regardless let sessions_per_era = SessionsPerEra::get(); - let channel_id = PRIMARY_GOVERNANCE_CHANNEL.encode(); - - // Insert PRIMARY_GOVERNANCE_CHANNEL channel id into storage. - let mut combined_channel_id_key = Vec::new(); - let hashed_key = twox_64(&channel_id); - - combined_channel_id_key.extend_from_slice(&hashed_key); - combined_channel_id_key.extend_from_slice(PRIMARY_GOVERNANCE_CHANNEL.as_ref()); - - let mut full_storage_key = Vec::new(); - full_storage_key.extend_from_slice(&frame_support::storage::storage_prefix( - b"EthereumSystem", - b"Channels", - )); - full_storage_key.extend_from_slice(&combined_channel_id_key); - - let channel = Channel { - agent_id: H256::default(), - para_id: 1000u32.into(), - }; - - frame_support::storage::unhashed::put(&full_storage_key, &channel); - // This will call on_era_end for era 0 run_to_session(sessions_per_era); diff --git a/chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs b/chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs index 9f1e38f88..7409175f5 100644 --- a/chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs +++ b/chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs @@ -357,9 +357,6 @@ fn test_slashes_cannot_be_cancelled_after_defer_period() { }); } -use parity_scale_codec::Encode; -use snowbridge_core::{Channel, PRIMARY_GOVERNANCE_CHANNEL}; -use sp_core::twox_64; #[test] fn test_slashes_are_sent_to_ethereum() { sp_tracing::try_init_simple(); @@ -374,29 +371,6 @@ fn test_slashes_are_sent_to_ethereum() { .build() .execute_with(|| { run_to_block(2); - let channel_id = PRIMARY_GOVERNANCE_CHANNEL.encode(); - - // Insert PRIMARY_GOVERNANCE_CHANNEL channel id into storage. - let mut combined_channel_id_key = Vec::new(); - let hashed_key = twox_64(&channel_id); - - combined_channel_id_key.extend_from_slice(&hashed_key); - combined_channel_id_key.extend_from_slice(PRIMARY_GOVERNANCE_CHANNEL.as_ref()); - - let mut full_storage_key = Vec::new(); - full_storage_key.extend_from_slice(&frame_support::storage::storage_prefix( - b"EthereumSystem", - b"Channels", - )); - full_storage_key.extend_from_slice(&combined_channel_id_key); - - let channel = Channel { - agent_id: H256::default(), - para_id: 1000u32.into(), - }; - - frame_support::storage::unhashed::put(&full_storage_key, &channel); - assert_ok!(ExternalValidators::remove_whitelisted( RuntimeOrigin::root(), AccountId::from(ALICE) @@ -486,28 +460,6 @@ fn test_slashes_are_sent_to_ethereum_accumulatedly() { .build() .execute_with(|| { run_to_block(2); - let channel_id = PRIMARY_GOVERNANCE_CHANNEL.encode(); - - // Insert PRIMARY_GOVERNANCE_CHANNEL channel id into storage. - let mut combined_channel_id_key = Vec::new(); - let hashed_key = twox_64(&channel_id); - - combined_channel_id_key.extend_from_slice(&hashed_key); - combined_channel_id_key.extend_from_slice(PRIMARY_GOVERNANCE_CHANNEL.as_ref()); - - let mut full_storage_key = Vec::new(); - full_storage_key.extend_from_slice(&frame_support::storage::storage_prefix( - b"EthereumSystem", - b"Channels", - )); - full_storage_key.extend_from_slice(&combined_channel_id_key); - - let channel = Channel { - agent_id: H256::default(), - para_id: 1000u32.into(), - }; - - frame_support::storage::unhashed::put(&full_storage_key, &channel); // We can inject arbitraqry slashes for arbitary accounts with root let page_limit: u32 = ::QueuedSlashesProcessedPerBlock::get(); @@ -628,28 +580,6 @@ fn test_slashes_are_sent_to_ethereum_accumulate_until_next_era() { .build() .execute_with(|| { run_to_block(2); - let channel_id = PRIMARY_GOVERNANCE_CHANNEL.encode(); - - // Insert PRIMARY_GOVERNANCE_CHANNEL channel id into storage. - let mut combined_channel_id_key = Vec::new(); - let hashed_key = twox_64(&channel_id); - - combined_channel_id_key.extend_from_slice(&hashed_key); - combined_channel_id_key.extend_from_slice(PRIMARY_GOVERNANCE_CHANNEL.as_ref()); - - let mut full_storage_key = Vec::new(); - full_storage_key.extend_from_slice(&frame_support::storage::storage_prefix( - b"EthereumSystem", - b"Channels", - )); - full_storage_key.extend_from_slice(&combined_channel_id_key); - - let channel = Channel { - agent_id: H256::default(), - para_id: 1000u32.into(), - }; - - frame_support::storage::unhashed::put(&full_storage_key, &channel); // We can inject arbitraqry slashes for arbitary accounts with root let page_limit: u32 = ::QueuedSlashesProcessedPerBlock::get();