Skip to content

Commit

Permalink
refactored system-parachain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
x3c41a committed Oct 23, 2024
1 parent e381820 commit ce255ad
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 90 deletions.
24 changes: 12 additions & 12 deletions system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,12 @@ fn treasury_pallet_account_not_none() {

#[test]
fn location_conversion_works() {
let alice_32 = AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -746,10 +752,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
Expand All @@ -759,27 +762,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
24 changes: 12 additions & 12 deletions system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,12 @@ fn change_xcm_bridge_hub_ethereum_base_fee_by_governance_works() {

#[test]
fn location_conversion_works() {
let alice_32 = AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -770,10 +776,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
Expand All @@ -783,27 +786,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
24 changes: 12 additions & 12 deletions system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ fn treasury_pallet_account_not_none() {

#[test]
fn location_conversion_works() {
let alice_32 = xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -407,10 +413,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5EueAXd4h8u75nSbFdDJbC29cmi4Uo1YJssqEL9idvindxFL",
},
Expand All @@ -420,27 +423,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5Dmbuiq48fU4iW58FKYqoGbbfxFHjbAeGLMtjFg6NNCw3ssr",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
24 changes: 12 additions & 12 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ fn treasury_pallet_account_not_none() {

#[test]
fn location_conversion_works() {
let alice_32 = xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -408,10 +414,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5EueAXd4h8u75nSbFdDJbC29cmi4Uo1YJssqEL9idvindxFL",
},
Expand All @@ -421,27 +424,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(Alice).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5Dmbuiq48fU4iW58FKYqoGbbfxFHjbAeGLMtjFg6NNCw3ssr",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const ALICE: [u8; 32] = [1u8; 32];

#[test]
fn location_conversion_works() {
let alice_32 = xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -59,7 +65,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[AccountId32 { network: None, id: AccountId::from(ALICE).into() }],
[alice_32.clone()],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
Expand All @@ -69,24 +75,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
alice_32.clone(),
],
),
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
24 changes: 12 additions & 12 deletions system-parachains/coretime/coretime-kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ fn timeslice_period_is_sane() {

#[test]
fn location_conversion_works() {
let alice_32 = AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -151,10 +157,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
Expand All @@ -164,27 +167,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
24 changes: 12 additions & 12 deletions system-parachains/coretime/coretime-polkadot/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ fn timeslice_period_is_sane() {

#[test]
fn location_conversion_works() {
let alice_32 = AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
};
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] };

// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
Expand Down Expand Up @@ -151,10 +157,7 @@ fn location_conversion_works() {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[xcm::prelude::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
}],
[alice_32.clone()],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
Expand All @@ -164,27 +167,24 @@ fn location_conversion_works() {
1,
[
Parachain(1111),
Junction::AccountId32 {
network: None,
id: polkadot_core_primitives::AccountId::from(ALICE).into(),
},
alice_32.clone(),
],
),
expected_account_id_str: "5DGRXLYwWGce7wvm14vX1Ms4Vf118FSWQbJkyQigY2pfm6bg",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Parent",
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]),
expected_account_id_str: "5F5Ec11567pa919wJkX6VHtv2ZXS5W698YCW35EdEbrg14cg",
location: Location::new(1, [bob_20.clone()]),
expected_account_id_str: "5CJeW9bdeos6EmaEofTUiNrvyVobMBfWbdQvhTe6UciGjH2n",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
[Parachain(1111), bob_20.clone()],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
expected_account_id_str: "5CE6V5AKH8H4rg2aq5KMbvaVUDMumHKVPPQEEDMHPy3GmJQp",
},
// DescribeTreasuryVoiceTerminal
TestCase {
Expand Down
Loading

0 comments on commit ce255ad

Please sign in to comment.