-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Location conversion tests for relay and parachains #487
Location conversion tests for relay and parachains #487
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversions are the same for all system parachains, so this test could be a macro to dedup the code, but I don't know where we would put that macro or if it's worth the effort. I'm fine with the duplicated code too.
Please see the other comments.
// DescribeTerminus | ||
TestCase { | ||
description: "DescribeTerminus Parent", | ||
location: Location::new(1, Here), | ||
expected_account_id_str: "5GyWtDJP7qaipWRGr4KJ6VUDxRXf4jDnPW6KPTeCekHfqZkD", | ||
}, | ||
TestCase { | ||
description: "DescribeTerminus Sibling", | ||
location: Location::new(1, [Parachain(1111)]), | ||
expected_account_id_str: "5EC5GfEFm9XEBYjXzxb1VseMHsG2VhPeGTGWF9H8tYZnGsSk", | ||
}, | ||
// 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", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent and Sibling (parachain) locations do not make sense for a Relay chain.
All of these should be replaced with Child (parachain) locations.
(DescribeTerminus Child, DescribePalletTerminal Child, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// DescribeTerminus | ||
TestCase { | ||
description: "DescribeTerminus Parent", | ||
location: Location::new(1, Here), | ||
expected_account_id_str: "5GyWtDJP7qaipWRGr4KJ6VUDxRXf4jDnPW6KPTeCekHfqZkD", | ||
}, | ||
TestCase { | ||
description: "DescribeTerminus Sibling", | ||
location: Location::new(1, [Parachain(1111)]), | ||
expected_account_id_str: "5EC5GfEFm9XEBYjXzxb1VseMHsG2VhPeGTGWF9H8tYZnGsSk", | ||
}, | ||
// 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", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent and Sibling (parachain) locations do not make sense for a Relay chain.
All of these should be replaced with Child (parachain) locations.
(DescribeTerminus Child, DescribePalletTerminal Child, etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
// DescribeAccountKey20Terminal | ||
TestCase { | ||
description: "DescribeAccountKey20Terminal Parent", | ||
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for these AccountKey20
s:
location: Location::new(1, [AccountKey20 { network: None, key: [0u8; 20] }]), | |
location: Location::new(1, [bob_20.clone()]), |
with
let bob_20 = AccountKey20 { network: None, key: [123u8; 20] }
(notice I also suggested using non-zero keys)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☑️
Out of curiosity, what edge-case you want to avoid by eliminating zero keys?
bot fmt |
I don't feel like writing macros just yet, still want to get used to Rust. |
Review required! Latest push from author must always be reviewed |
expected_account_id_str: &'static str, | ||
} | ||
|
||
let test_cases = vec![ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the test-cases not defined in a shared crate? They seem to be copy&pasted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a subtle difference among these tests -- DescribeAccountId32Terminal is different in many of the cases.
If I were to refactor the tests I'd rather rewrite those into macros, as Adrian suggested a few comments before. I'll leave it as a follow-up for myself once I fully onboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you're talking about people folder specifically, though I would not do it for a single folder...
/merge |
Enabled Available commands
For more information see the documentation |
db4bb53
into
polkadot-fellows:main
Added location convertion tests.
Polkadot sdk PR
Fixes #488