Skip to content

Commit

Permalink
Fix sibling location
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Dec 20, 2023
1 parent 8d14e0b commit 71d7dbd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
7 changes: 3 additions & 4 deletions parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ where
SendError::Unroutable
})?;

// local_sub is relative to the relaychain. No conversion needed.
let local_sub_location: MultiLocation = local_sub.into();
let agent_id = match AgentHashedDescription::convert_location(&local_sub_location) {
let source_location: MultiLocation = MultiLocation { parents: 1, interior: local_sub };
let agent_id = match AgentHashedDescription::convert_location(&source_location) {
Some(id) => id,
None => {
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{local_sub_location:?}'");
log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{source_location:?}'");
return Err(SendError::Unroutable)
},
};
Expand Down
34 changes: 32 additions & 2 deletions parachain/primitives/router/src/outbound/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use frame_support::parameter_types;
use hex_literal::hex;
use snowbridge_core::outbound::{Fee, SendError, SendMessageFeeProvider};
use snowbridge_core::{
outbound::{Fee, SendError, SendMessageFeeProvider},
DescribeHere,
};

use xcm::v3::prelude::SendError as XcmSendError;
use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription};

pub type AgentIdOf = HashedDescription<H256, DescribeFamily<DescribeAllTerminal>>;
pub type AgentIdOf = HashedDescription<H256, (DescribeHere, DescribeFamily<DescribeAllTerminal>)>;

use super::*;

Expand Down Expand Up @@ -1035,3 +1038,30 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_
let result = converter.convert();
assert_eq!(result.err(), Some(XcmConverterError::BeneficiaryResolutionFailed));
}

#[test]
fn test_describe_asset_hub() {
let legacy_location: MultiLocation =
MultiLocation { parents: 0, interior: X1(Parachain(1000)) };
let legacy_agent_id = AgentIdOf::convert_location(&legacy_location).unwrap();
assert_eq!(
legacy_agent_id,
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4").into()
);
let location: MultiLocation = MultiLocation { parents: 1, interior: X1(Parachain(1000)) };
let agent_id = AgentIdOf::convert_location(&location).unwrap();
assert_eq!(
agent_id,
hex!("81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79").into()
)
}

#[test]
fn test_describe_here() {
let location: MultiLocation = MultiLocation { parents: 0, interior: Here };
let agent_id = AgentIdOf::convert_location(&location).unwrap();
assert_eq!(
agent_id,
hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into()
)
}
2 changes: 1 addition & 1 deletion web/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export BRIDGE_HUB_AGENT_ID="${BRIDGE_HUB_AGENT_ID:-0x03170a2e7597b7b7e3d84c05391
assethub_ws_url="${ASSET_HUB_WS_URL:-ws://127.0.0.1:12144}"
assethub_seed="${ASSET_HUB_SEED:-//Alice}"
export ASSET_HUB_PARAID="${ASSET_HUB_PARAID:-1000}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79}"

export ASSET_HUB_CHANNEL_ID="0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539"
export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3"
Expand Down

0 comments on commit 71d7dbd

Please sign in to comment.