Skip to content

Commit

Permalink
WIP: Fix bridges integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Dec 27, 2024
1 parent 8ce2796 commit 601970b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": { "GlobalConsensus": "Kusama" } } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Kusama" }] } }')" \
"$GLOBAL_CONSENSUS_KUSAMA_SOVEREIGN_ACCOUNT" \
$AHP_KSM_ED \
true
Expand Down Expand Up @@ -266,7 +266,7 @@ case "$1" in
"//Alice" \
1000 \
"ws://127.0.0.1:9010" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": { "GlobalConsensus": "Polkadot" } } }')" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Polkadot" }] } }')" \
"$GLOBAL_CONSENSUS_POLKADOT_SOVEREIGN_ACCOUNT" \
$AHK_DOT_ED \
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creds: config
asset-hub-kusama-collator-1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-polkadot-local 50000000000" within 120 seconds

# check that //Alice received at least 4.8 DOT on Kusama AH
asset-hub-kusama-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,48000000000,Polkadot" within 300 seconds
asset-hub-kusama-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with '{ "accountAddress": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "expectedAssetBalance": 48000000000, "expectedAssetId": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Polkadot" }] }}}' within 300 seconds

# check that the relayer //Charlie is rewarded by Kusama AH
bridge-hub-kusama-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000001,0x62687064,ThisChain,0" within 30 seconds
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creds: config
asset-hub-polkadot-collator-1: run {{ENV_PATH}}/helper.sh with "reserve-transfer-assets-from-asset-hub-kusama-local 5000000000000" within 120 seconds

# check that //Alice received at least 4.8 KSM on Polkadot AH
asset-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,4800000000000,Kusama" within 300 seconds
asset-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/wrapped-assets-balance.js with '{ "accountAddress": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "expectedAssetBalance": 4800000000000, "expectedAssetId": { "parents": 2, "interior": { "X1": [{ "GlobalConsensus": "Kusama" }] }}}' within 300 seconds

# check that the relayer //Charlie is rewarded by Polkadot AH
bridge-hub-polkadot-collator-1: js-script {{FRAMEWORK_PATH}}/js-helpers/relayer-rewards.js with "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,0x00000001,0x62686b73,ThisChain,0" within 30 seconds
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn bridge_hub_kusama_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
opened_bridges: Vec<(Location, InteriorLocation, Option<bp_messages::LegacyLaneId>)>,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
Expand Down Expand Up @@ -61,19 +62,12 @@ fn bridge_hub_kusama_genesis(
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"xcmOverBridgeHubPolkadot": XcmOverBridgeHubPolkadotConfig { opened_bridges, ..Default::default() },
// no need to pass anything to aura, in fact it will panic if we do. Session will take care
// of this. `aura: Default::default()`
})
}

pub fn bridge_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
bridge_hub_kusama_genesis(invulnerables(), testnet_accounts(), para_id)
}

fn bridge_hub_kusama_development_genesis(para_id: ParaId) -> serde_json::Value {
bridge_hub_kusama_local_testnet_genesis(para_id)
}

/// Provides the names of the predefined genesis configs for this runtime.
pub fn preset_names() -> Vec<PresetId> {
vec![PresetId::from("development"), PresetId::from("local_testnet")]
Expand All @@ -82,8 +76,22 @@ pub fn preset_names() -> Vec<PresetId> {
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok("development") => bridge_hub_kusama_development_genesis(1002.into()),
Ok("local_testnet") => bridge_hub_kusama_local_testnet_genesis(1002.into()),
Ok("development") => bridge_hub_kusama_genesis(
invulnerables(),
testnet_accounts(),
1002.into(),
vec![]
),
Ok("local_testnet") => bridge_hub_kusama_genesis(
invulnerables(),
testnet_accounts(),
1002.into(),
vec![(
Location::new(1, [Parachain(1000)]),
Junctions::from([GlobalConsensus(Polkadot), Parachain(1000)]),
Some(bp_messages::LegacyLaneId([0, 0, 0, 1])),
)],
),
_ => return None,
};
Some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ parameter_types! {

pub type RelayersForLegacyLaneIdsMessagesInstance = ();
/// Allows collect and claim rewards for relayers.
impl pallet_bridge_relayers::Config for Runtime {
impl pallet_bridge_relayers::Config<RelayersForLegacyLaneIdsMessagesInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Reward = Balance;
type PaymentProcedure = bp_relayers::PayRewardFromAccount<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn bridge_hub_polkadot_genesis(
invulnerables: Vec<(AccountId, AuraId)>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
opened_bridges: Vec<(Location, InteriorLocation, Option<bp_messages::LegacyLaneId>)>,
) -> serde_json::Value {
serde_json::json!({
"balances": BalancesConfig {
Expand Down Expand Up @@ -61,6 +62,7 @@ fn bridge_hub_polkadot_genesis(
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},
"xcmOverBridgeHubKusama": XcmOverBridgeHubKusamaConfig { opened_bridges, ..Default::default() },
"ethereumSystem": EthereumSystemConfig {
para_id: id,
asset_hub_para_id: polkadot_runtime_constants::system_parachain::ASSET_HUB_ID.into(),
Expand All @@ -71,14 +73,6 @@ fn bridge_hub_polkadot_genesis(
})
}

pub fn bridge_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
bridge_hub_polkadot_genesis(invulnerables(), testnet_accounts(), para_id)
}

fn bridge_hub_polkadot_development_genesis(para_id: ParaId) -> serde_json::Value {
bridge_hub_polkadot_local_testnet_genesis(para_id)
}

/// Provides the names of the predefined genesis configs for this runtime.
pub fn preset_names() -> Vec<PresetId> {
vec![PresetId::from("development"), PresetId::from("local_testnet")]
Expand All @@ -87,8 +81,19 @@ pub fn preset_names() -> Vec<PresetId> {
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
let patch = match id.try_into() {
Ok("development") => bridge_hub_polkadot_development_genesis(1002.into()),
Ok("local_testnet") => bridge_hub_polkadot_local_testnet_genesis(1002.into()),
Ok("development") => {
bridge_hub_polkadot_genesis(invulnerables(), testnet_accounts(), 1002.into(), vec![])
},
Ok("local_testnet") => bridge_hub_polkadot_genesis(
invulnerables(),
testnet_accounts(),
1002.into(),
vec![(
Location::new(1, [Parachain(1000)]),
Junctions::from([GlobalConsensus(Kusama), Parachain(1000)]),
Some(bp_messages::LegacyLaneId([0, 0, 0, 1])),
)],
),
_ => return None,
};
Some(
Expand Down

0 comments on commit 601970b

Please sign in to comment.