Skip to content

Commit

Permalink
Merge branch 'master' into libp2p
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkazu authored Oct 3, 2024
2 parents c2f1686 + 8614dc0 commit 25e12d1
Show file tree
Hide file tree
Showing 41 changed files with 2,261 additions and 421 deletions.
2 changes: 1 addition & 1 deletion .gitlab/pipeline/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ publish-rustdoc:
# This causes GitLab to exit immediately and marks this job failed.
# We don't want to mark the entire job failed if there's nothing to
# publish though, hence the `|| true`.
- git commit -m "___Updated docs for ${CI_COMMIT_REF_NAME}___" ||
- git commit --amend -m "___Updated docs" ||
echo "___Nothing to commit___"
- git push origin gh-pages --force
# artificial sleep to publish gh-pages
Expand Down
46 changes: 23 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 111 additions & 0 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ use frame_support::{
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_consensus_aura::SlotDuration;
use sp_core::crypto::Ss58Codec;
use sp_runtime::traits::MaybeEquivalence;
use std::convert::Into;
use testnet_parachains_constants::rococo::{consensus::*, currency::UNITS, fee::WeightToFee};
use xcm::latest::prelude::{Assets as XcmAssets, *};
use xcm_builder::WithLatestLocationConverter;
use xcm_executor::traits::{JustTry, WeightTrader};
use xcm_runtime_apis::conversions::LocationToAccountHelper;

const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
Expand Down Expand Up @@ -1355,3 +1357,112 @@ fn change_xcm_bridge_hub_ethereum_base_fee_by_governance_works() {
},
)
}

#[test]
fn location_conversion_works() {
// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
location: Location,
expected_account_id_str: &'static str,
}

let test_cases = vec![
// DescribeTerminus
TestCase {
description: "DescribeTerminus Parent",
location: Location::new(1, Here),
expected_account_id_str: "5Dt6dpkWPwLaH4BBCKJwjiWrFVAGyYk3tLUabvyn4v7KtESG",
},
TestCase {
description: "DescribeTerminus Sibling",
location: Location::new(1, [Parachain(1111)]),
expected_account_id_str: "5Eg2fnssmmJnF3z1iZ1NouAuzciDaaDQH7qURAy3w15jULDk",
},
// DescribePalletTerminal
TestCase {
description: "DescribePalletTerminal Parent",
location: Location::new(1, [PalletInstance(50)]),
expected_account_id_str: "5CnwemvaAXkWFVwibiCvf2EjqwiqBi29S5cLLydZLEaEw6jZ",
},
TestCase {
description: "DescribePalletTerminal Sibling",
location: Location::new(1, [Parachain(1111), PalletInstance(50)]),
expected_account_id_str: "5GFBgPjpEQPdaxEnFirUoa51u5erVx84twYxJVuBRAT2UP2g",
},
// DescribeAccountId32Terminal
TestCase {
description: "DescribeAccountId32Terminal Parent",
location: Location::new(
1,
[AccountId32 { network: None, id: AccountId::from(ALICE).into() }],
),
expected_account_id_str: "5DN5SGsuUG7PAqFL47J9meViwdnk9AdeSWKFkcHC45hEzVz4",
},
TestCase {
description: "DescribeAccountId32Terminal Sibling",
location: Location::new(
1,
[
Parachain(1111),
Junction::AccountId32 { network: None, id: AccountId::from(ALICE).into() },
],
),
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",
},
TestCase {
description: "DescribeAccountKey20Terminal Sibling",
location: Location::new(
1,
[Parachain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
),
expected_account_id_str: "5CB2FbUds2qvcJNhDiTbRZwiS3trAy6ydFGMSVutmYijpPAg",
},
// DescribeTreasuryVoiceTerminal
TestCase {
description: "DescribeTreasuryVoiceTerminal Parent",
location: Location::new(1, [Plurality { id: BodyId::Treasury, part: BodyPart::Voice }]),
expected_account_id_str: "5CUjnE2vgcUCuhxPwFoQ5r7p1DkhujgvMNDHaF2bLqRp4D5F",
},
TestCase {
description: "DescribeTreasuryVoiceTerminal Sibling",
location: Location::new(
1,
[Parachain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
),
expected_account_id_str: "5G6TDwaVgbWmhqRUKjBhRRnH4ry9L9cjRymUEmiRsLbSE4gB",
},
// DescribeBodyTerminal
TestCase {
description: "DescribeBodyTerminal Parent",
location: Location::new(1, [Plurality { id: BodyId::Unit, part: BodyPart::Voice }]),
expected_account_id_str: "5EBRMTBkDisEXsaN283SRbzx9Xf2PXwUxxFCJohSGo4jYe6B",
},
TestCase {
description: "DescribeBodyTerminal Sibling",
location: Location::new(
1,
[Parachain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
),
expected_account_id_str: "5DBoExvojy8tYnHgLL97phNH975CyT45PWTZEeGoBZfAyRMH",
},
];

for tc in test_cases {
let expected =
AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");

let got = LocationToAccountHelper::<AccountId, LocationToAccountId>::convert_location(
tc.location.into(),
)
.unwrap();

assert_eq!(got, expected, "{}", tc.description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter,
GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint,
MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
Expand Down Expand Up @@ -93,9 +93,8 @@ pub type LocationToAccountId = (
SiblingParachainConvertsVia<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign chain account alias into local accounts according to a hash of their standard
// description.
HashedDescription<AccountId, DescribeFamily<DescribePalletTerminal>>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
// Different global consensus parachain sovereign account.
// (Used for over-bridge transfers and reserve processing)
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
Expand Down
Loading

0 comments on commit 25e12d1

Please sign in to comment.