Skip to content

Commit 8fd346e

Browse files
authored
changed some tests for weights v2 (#1855)
1 parent c438b9f commit 8fd346e

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/messages/src/weights_ext.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>() {
4545
// verify `receive_messages_delivery_proof` weight components
4646
assert_ne!(W::receive_messages_delivery_proof_overhead(), Weight::zero());
4747
assert_ne!(W::storage_proof_size_overhead(1), Weight::zero());
48+
49+
// verify `receive_message_proof` weight
50+
let receive_messages_proof_weight =
51+
W::receive_messages_proof_weight(&PreComputedSize(1), 10, Weight::from_ref_time(0));
52+
assert_ne!(receive_messages_proof_weight.ref_time(), 0);
53+
assert_ne!(receive_messages_proof_weight.proof_size(), 0);
54+
55+
// verify `receive_message_proof` weight
56+
let receive_messages_delivery_proof_weight = W::receive_messages_delivery_proof_weight(
57+
&PreComputedSize(1),
58+
&UnrewardedRelayersState::default(),
59+
);
60+
assert_ne!(receive_messages_delivery_proof_weight.ref_time(), 0);
61+
assert_ne!(receive_messages_delivery_proof_weight.proof_size(), 0);
4862
}
4963

5064
/// Ensure that we're able to receive maximal (by-size and by-weight) message from other chain.

relays/lib-substrate-relay/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch
4848
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
4949

5050
[dev-dependencies]
51-
bp-millau = { path = "../../primitives/chain-millau" }
5251
bp-rialto = { path = "../../primitives/chain-rialto" }
52+
bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" }
5353
bp-rococo = { path = "../../primitives/chain-rococo" }
5454
bp-wococo = { path = "../../primitives/chain-wococo" }
5555
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }

relays/lib-substrate-relay/src/messages_lane.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,14 @@ mod tests {
487487
pallet_bridge_messages::weights::BridgeWeight<rialto_runtime::Runtime>;
488488

489489
#[test]
490-
fn select_delivery_transaction_limits_works() {
490+
fn select_delivery_transaction_limits_is_sane() {
491+
// we want to check the `proof_size` component here too. But for Rialto and Millau
492+
// it is set to `u64::MAX` (as for Polkadot and other relay/standalone chains).
493+
// So let's use RialtoParachain limits here - it has `proof_size` limit as all
494+
// Cumulus-based parachains do.
491495
let (max_count, max_weight) =
492496
select_delivery_transaction_limits::<RialtoToMillauMessagesWeights>(
493-
bp_millau::Millau::max_extrinsic_weight(),
497+
bp_rialto_parachain::RialtoParachain::max_extrinsic_weight(),
494498
bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
495499
);
496500
assert_eq!(
@@ -500,13 +504,7 @@ mod tests {
500504
// i.e. weight reserved for messages dispatch allows dispatch of non-trivial messages.
501505
//
502506
// Any significant change in this values should attract additional attention.
503-
//
504-
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - the `proof_size`
505-
// component is too large here!
506-
(
507-
1024,
508-
Weight::from_ref_time(216_600_106_667).set_proof_size(7_993_589_098_607_472_367)
509-
),
507+
(1024, Weight::from_parts(866_600_106_667, 2_271_915)),
510508
);
511509
}
512510
}

0 commit comments

Comments
 (0)