Unverified Commit 9ccd6bb5 authored by Sergey Pepyakin's avatar Sergey Pepyakin Committed by GitHub
Browse files

Add tests that check the value of MQCs (#2351)



* DMP

* HRMP

* Update runtime/parachains/src/dmp.rs

Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
parent 7aa88e36
Pipeline #122635 passed with stages
in 28 minutes and 29 seconds
......@@ -226,6 +226,7 @@ impl<T: Config> Module<T> {
#[cfg(test)]
mod tests {
use super::*;
use hex_literal::hex;
use primitives::v1::BlockNumber;
use frame_support::StorageValue;
use frame_support::traits::{OnFinalize, OnInitialize};
......@@ -322,6 +323,25 @@ mod tests {
});
}
#[test]
fn dmp_mqc_head_fixture() {
let a = ParaId::from(2000);
new_test_ext(default_genesis_config()).execute_with(|| {
run_to_block(2, None);
assert!(Dmp::dmq_mqc_head(a).is_zero());
queue_downward_message(a, vec![1, 2, 3]).unwrap();
run_to_block(3, None);
queue_downward_message(a, vec![4, 5, 6]).unwrap();
assert_eq!(
Dmp::dmq_mqc_head(a),
hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into(),
);
});
}
#[test]
fn check_processed_downward_messages() {
let a = ParaId::from(1312);
......
......@@ -1536,6 +1536,43 @@ mod tests {
});
}
#[test]
fn hrmp_mqc_head_fixture() {
let para_a = 2000.into();
let para_b = 2024.into();
let mut genesis = GenesisConfigBuilder::default();
genesis.hrmp_channel_max_message_size = 20;
genesis.hrmp_channel_max_total_size = 20;
new_test_ext(genesis.build()).execute_with(|| {
register_parachain(para_a);
register_parachain(para_b);
run_to_block(1, Some(vec![1]));
Hrmp::init_open_channel(para_a, para_b, 2, 20).unwrap();
Hrmp::accept_open_channel(para_b, para_a).unwrap();
run_to_block(2, Some(vec![2]));
let _ = Hrmp::queue_outbound_hrmp(para_a, vec![OutboundHrmpMessage {
recipient: para_b,
data: vec![1, 2, 3],
}]);
run_to_block(3, None);
let _ = Hrmp::queue_outbound_hrmp(para_a, vec![OutboundHrmpMessage {
recipient: para_b,
data: vec![4, 5, 6],
}]);
assert_eq!(
Hrmp::hrmp_mqc_heads(para_b),
vec![
(para_a, hex_literal::hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into()),
],
);
});
}
#[test]
fn accept_incoming_request_and_offboard() {
let para_a = 32.into();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment