Skip to content

Commit

Permalink
fix experimental-ump-signals tests (paritytech#6214)
Browse files Browse the repository at this point in the history
Resolves paritytech#6200

Also sets the feature on the rococo-parachain. Will be useful for
zombienet testing
  • Loading branch information
alindima authored and mordamax committed Oct 29, 2024
1 parent 0e4bcce commit 2d03832
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 10 deletions.
127 changes: 118 additions & 9 deletions cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use frame_support::{assert_ok, parameter_types, weights::Weight};
use frame_system::RawOrigin;
use hex_literal::hex;
use rand::Rng;
#[cfg(feature = "experimental-ump-signals")]
use relay_chain::vstaging::{UMPSignal, UMP_SEPARATOR};
use relay_chain::HrmpChannelId;
use sp_core::H256;

Expand Down Expand Up @@ -583,7 +585,25 @@ fn send_upward_message_num_per_candidate() {
},
|| {
let v = UpwardMessages::<Test>::get();
assert_eq!(v, vec![b"Mr F was here".to_vec()]);
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
v,
vec![
b"Mr F was here".to_vec(),
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(1),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert_eq!(v, vec![b"Mr F was here".to_vec()]);
}
},
)
.add_with_post_test(
Expand All @@ -594,7 +614,25 @@ fn send_upward_message_num_per_candidate() {
},
|| {
let v = UpwardMessages::<Test>::get();
assert_eq!(v, vec![b"message 2".to_vec()]);
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
v,
vec![
b"message 2".to_vec(),
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(2),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert_eq!(v, vec![b"message 2".to_vec()]);
}
},
);
}
Expand All @@ -620,15 +658,50 @@ fn send_upward_message_relay_bottleneck() {
|| {
// The message won't be sent because there is already one message in queue.
let v = UpwardMessages::<Test>::get();
assert!(v.is_empty());
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
v,
vec![
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(1),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert!(v.is_empty());
}
},
)
.add_with_post_test(
2,
|| { /* do nothing within block */ },
|| {
let v = UpwardMessages::<Test>::get();
assert_eq!(v, vec![vec![0u8; 8]]);
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
v,
vec![
vec![0u8; 8],
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(2),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert_eq!(v, vec![vec![0u8; 8]]);
}
},
);
}
Expand Down Expand Up @@ -1172,7 +1245,25 @@ fn ump_fee_factor_increases_and_decreases() {
|| {
// Factor decreases in `on_finalize`, but only if we are below the threshold
let messages = UpwardMessages::<Test>::get();
assert_eq!(messages, vec![b"Test".to_vec()]);
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
messages,
vec![
b"Test".to_vec(),
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(1),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert_eq!(messages, vec![b"Test".to_vec()]);
}
assert_eq!(
UpwardDeliveryFeeFactor::<Test>::get(),
FixedU128::from_rational(105, 100)
Expand All @@ -1186,10 +1277,28 @@ fn ump_fee_factor_increases_and_decreases() {
},
|| {
let messages = UpwardMessages::<Test>::get();
assert_eq!(
messages,
vec![b"This message will be enough to increase the fee factor".to_vec(),]
);
#[cfg(feature = "experimental-ump-signals")]
{
assert_eq!(
messages,
vec![
b"This message will be enough to increase the fee factor".to_vec(),
UMP_SEPARATOR,
UMPSignal::SelectCore(
CoreSelector(2),
ClaimQueueOffset(DEFAULT_CLAIM_QUEUE_OFFSET)
)
.encode()
]
);
}
#[cfg(not(feature = "experimental-ump-signals"))]
{
assert_eq!(
messages,
vec![b"This message will be enough to increase the fee factor".to_vec()]
);
}
// Now the delivery fee factor is decreased, since we are below the threshold
assert_eq!(UpwardDeliveryFeeFactor::<Test>::get(), FixedU128::from_u32(1));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ polkadot-runtime-common = { workspace = true }
# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
pallet-message-queue = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true, features = ["experimental-ump-signals"] }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-ping = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions prdoc/pr_6214.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
crates:
- name: cumulus-pallet-parachain-system
bump: none
- name: rococo-parachain-runtime
bump: none

0 comments on commit 2d03832

Please sign in to comment.