Skip to content

Commit

Permalink
cleanup some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
girazoki committed Jan 10, 2025
1 parent 018dd75 commit 034d3d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,10 @@ impl ExtBuilder {
.unwrap();

snowbridge_pallet_system::GenesisConfig::<Runtime> {
// 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down Expand Up @@ -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);

Expand Down
70 changes: 0 additions & 70 deletions chains/orchestrator-relays/runtime/dancelight/src/tests/slashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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 = <Runtime as pallet_external_validator_slashes::Config>::QueuedSlashesProcessedPerBlock::get();
Expand Down Expand Up @@ -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 = <Runtime as pallet_external_validator_slashes::Config>::QueuedSlashesProcessedPerBlock::get();
Expand Down

0 comments on commit 034d3d1

Please sign in to comment.