Skip to content

Commit

Permalink
Fix deprecated inbound fixtures (#1011)
Browse files Browse the repository at this point in the history
* Fix inbound queue tests

* Update rust toolchain to 1.71

* Upgrade rust-toolchain to 1.73.0

* Fix for clippy
  • Loading branch information
yrong authored Nov 20, 2023
1 parent ae1358f commit 75dbf3f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
22 changes: 10 additions & 12 deletions parachain/pallets/inbound-queue/src/benchmarking/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,28 @@ pub struct InboundQueueTest {
pub fn make_create_message() -> InboundQueueTest {
InboundQueueTest{
execution_header: CompactExecutionHeader{
parent_hash: hex!("9e2078694f20148b48e938a5b35a4cca79e19a05b7f27c7b3daae11a2ab57524").into(),
block_number: 55,
state_root: hex!("74865f49fe887e1b9df502282b1e99ccf563861a0ed58e9e541d966207d11f3f").into(),
receipts_root: hex!("0115ab735d37c5e4cdb0374d8bb547c6dd6ccaa996d996d1eabc5399a719219e").into(),
parent_hash: hex!("8f69b84ec2fe39b299005cf30e855a2bcdd997dd1e5f79777271160015db6ae3").into(),
block_number: 188,
state_root: hex!("3f744f5e0322312fbcd6ea06e4e3db6cf8ff8a6258ee4f621df57165c3964806").into(),
receipts_root: hex!("b4e733e6a4545303220f9954b9e895ecf31e5d6fe1557f27a0254a01132f38a7").into(),
},
message: Message {
event_log: Log {
address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(),
topics: vec![
hex!("5066fbba677e15936860e04088ca4cad3acd4c19706962196a5346f1457f7169").into(),
hex!("00000000000000000000000000000000000000000000000000000000000003e8").into(),
hex!("afad3c9777134532ae230b4fad334eef2e0dacbb965920412a7eaa59b07d640f").into(),
hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(),
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into(),
hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(),
],
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").into(),
},
proof: Proof {
block_hash: hex!("5f465744c166e9d10dc0031942a59ff82b640053253da517a1b576afdadb0363").into(),
block_hash: hex!("7ce27351fff56e7f0f28774766ad46dcf9c05e5cc5cf2c1914de08b34da3d0c9").into(),
tx_index: 0,
data: (vec![
hex!("0115ab735d37c5e4cdb0374d8bb547c6dd6ccaa996d996d1eabc5399a719219e").to_vec(),
hex!("caf5ee6beba6a6db5e2a0714a98f65ac4365c4a24e56ce033f19c7f8a2abb06a").to_vec(),
hex!("b4e733e6a4545303220f9954b9e895ecf31e5d6fe1557f27a0254a01132f38a7").to_vec(),
], vec![
hex!("5e2a0714a98f65ac4365c4a24e56ce033f19c7f8a2abb06a8080808080808080").to_vec(),
hex!("000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").to_vec(),
hex!("f9026d822080b9026702f9026301830150dfb9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90158f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df8fc94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b88000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").to_vec(),
]),
},
},
Expand Down
33 changes: 15 additions & 18 deletions parachain/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub struct MockChannelLookup;
impl ChannelLookup for MockChannelLookup {
fn lookup(channel_id: ChannelId) -> Option<Channel> {
if channel_id !=
hex!("00000000000000000000000000000000000000000000000000000000000003e8").into()
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into()
{
return None
}
Expand Down Expand Up @@ -247,11 +247,11 @@ fn mock_event_log() -> Log {
// gateway address
address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(),
topics: vec![
hex!("5066fbba677e15936860e04088ca4cad3acd4c19706962196a5346f1457f7169").into(),
hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(),
// channel id
hex!("00000000000000000000000000000000000000000000000000000000000003e8").into(),
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into(),
// message id
hex!("afad3c9777134532ae230b4fad334eef2e0dacbb965920412a7eaa59b07d640f").into(),
hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(),
],
// Nonce + Payload
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").into(),
Expand All @@ -260,16 +260,13 @@ fn mock_event_log() -> Log {

fn mock_event_log_invalid_channel() -> Log {
Log {
// gateway address
address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(),
topics: vec![
hex!("5066fbba677e15936860e04088ca4cad3acd4c19706962196a5346f1457f7169").into(),
// channel id
hex!("00000000000000000000000000000000000000000000000000000000000003e9").into(),
// message id
hex!("afad3c9777134532ae230b4fad334eef2e0dacbb965920412a7eaa59b07d640f").into(),
hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(),
// invalid channel id
hex!("0000000000000000000000000000000000000000000000000000000000000000").into(),
hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(),
],
// Nonce + Payload
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").into(),
}
}
Expand All @@ -279,11 +276,11 @@ fn mock_event_log_invalid_gateway() -> Log {
// gateway address
address: H160::zero(),
topics: vec![
hex!("5066fbba677e15936860e04088ca4cad3acd4c19706962196a5346f1457f7169").into(),
hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(),
// channel id
hex!("00000000000000000000000000000000000000000000000000000000000003e8").into(),
hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into(),
// message id
hex!("afad3c9777134532ae230b4fad334eef2e0dacbb965920412a7eaa59b07d640f").into(),
hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(),
],
// Nonce + Payload
data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001e000f000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d0000").into(),
Expand Down Expand Up @@ -315,12 +312,12 @@ fn test_submit_happy_path() {
};
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));
expect_events(vec![InboundQueueEvent::MessageReceived {
channel_id: hex!("00000000000000000000000000000000000000000000000000000000000003e8")
channel_id: hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539")
.into(),
nonce: 1,
message_id: [
3, 29, 43, 131, 7, 80, 47, 2, 238, 64, 45, 200, 64, 1, 46, 74, 121, 211, 8, 178,
198, 26, 230, 13, 180, 78, 164, 58, 22, 133, 206, 83,
168, 12, 232, 40, 69, 197, 207, 74, 203, 65, 199, 240, 164, 52, 244, 217, 62, 156,
107, 237, 117, 203, 233, 78, 251, 233, 31, 54, 155, 124, 204, 201,
],
}
.into()]);
Expand Down Expand Up @@ -402,7 +399,7 @@ fn test_submit_with_invalid_nonce() {
assert_ok!(InboundQueue::submit(origin.clone(), message.clone()));

let nonce: u64 = <Nonce<Test>>::get(ChannelId::from(hex!(
"00000000000000000000000000000000000000000000000000000000000003e8"
"c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539"
)));
assert_eq!(nonce, 1);

Expand Down
2 changes: 1 addition & 1 deletion parachain/primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn derive_channel_id_for_sibling(para_id: ParaId) -> ChannelId {
let para_id: u32 = para_id.into();
let para_id_bytes: [u8; 4] = para_id.to_be_bytes();
let prefix: [u8; 4] = *b"para";
let preimage: Vec<u8> = prefix.into_iter().chain(para_id_bytes.into_iter()).collect();
let preimage: Vec<u8> = prefix.into_iter().chain(para_id_bytes).collect();
keccak_256(&preimage).into()
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/rust-lang/rustup/issues/2686
# The auto-installation behaviour in rustup will likely be removed:
# https://github.com/rust-lang/rustup/issues/1397
channel = "1.70.0"
channel = "1.73.0"
components = [
"clippy",
"rust-analyzer",
Expand Down

0 comments on commit 75dbf3f

Please sign in to comment.