Skip to content

Commit

Permalink
changed some tests for weights v2 (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Feb 7, 2023
1 parent c438b9f commit 8fd346e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions modules/messages/src/weights_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>() {
// verify `receive_messages_delivery_proof` weight components
assert_ne!(W::receive_messages_delivery_proof_overhead(), Weight::zero());
assert_ne!(W::storage_proof_size_overhead(1), Weight::zero());

// verify `receive_message_proof` weight
let receive_messages_proof_weight =
W::receive_messages_proof_weight(&PreComputedSize(1), 10, Weight::from_ref_time(0));
assert_ne!(receive_messages_proof_weight.ref_time(), 0);
assert_ne!(receive_messages_proof_weight.proof_size(), 0);

// verify `receive_message_proof` weight
let receive_messages_delivery_proof_weight = W::receive_messages_delivery_proof_weight(
&PreComputedSize(1),
&UnrewardedRelayersState::default(),
);
assert_ne!(receive_messages_delivery_proof_weight.ref_time(), 0);
assert_ne!(receive_messages_delivery_proof_weight.proof_size(), 0);
}

/// Ensure that we're able to receive maximal (by-size and by-weight) message from other chain.
Expand Down
2 changes: 1 addition & 1 deletion relays/lib-substrate-relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }

[dev-dependencies]
bp-millau = { path = "../../primitives/chain-millau" }
bp-rialto = { path = "../../primitives/chain-rialto" }
bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" }
bp-rococo = { path = "../../primitives/chain-rococo" }
bp-wococo = { path = "../../primitives/chain-wococo" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
16 changes: 7 additions & 9 deletions relays/lib-substrate-relay/src/messages_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,14 @@ mod tests {
pallet_bridge_messages::weights::BridgeWeight<rialto_runtime::Runtime>;

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

0 comments on commit 8fd346e

Please sign in to comment.