Skip to content
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

fix experimental-ump-signals tests #6214

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who's Mr. F? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a mystery :D

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
Loading