Skip to content

Commit

Permalink
Add integrity tests to rialto parachain runtiime (paritytech#2096)
Browse files Browse the repository at this point in the history
* add integrity tests to rialto-parachain runtime

* post cherry-pick fixes
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 363a8ac commit 25671f3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions bridges/bin/rialto-parachain/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master"

[dev-dependencies]
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
static_assertions = "1.1"

[features]
default = ['std']
Expand Down
61 changes: 61 additions & 0 deletions bridges/bin/rialto-parachain/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,64 @@ impl XcmBlobHauler for ToMillauXcmBlobHauler {
XCM_LANE
}
}

#[cfg(test)]
mod tests {
use super::*;
use crate::{MillauGrandpaInstance, Runtime, WithMillauMessagesInstance};
use bridge_runtime_common::{
assert_complete_bridge_types,
integrity::{
assert_complete_bridge_constants, check_message_lane_weights,
AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants,
AssertCompleteBridgeConstants,
},
};

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
check_message_lane_weights::<bp_rialto_parachain::RialtoParachain, Runtime>(
bp_millau::EXTRA_STORAGE_PROOF_SIZE,
bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
);
}

#[test]
fn ensure_bridge_integrity() {
assert_complete_bridge_types!(
runtime: Runtime,
with_bridged_chain_grandpa_instance: MillauGrandpaInstance,
with_bridged_chain_messages_instance: WithMillauMessagesInstance,
bridge: WithMillauMessageBridge,
this_chain: bp_rialto_parachain::RialtoParachain,
bridged_chain: bp_millau::Millau,
);

assert_complete_bridge_constants::<
Runtime,
MillauGrandpaInstance,
WithMillauMessagesInstance,
WithMillauMessageBridge,
>(AssertCompleteBridgeConstants {
this_chain_constants: AssertChainConstants {
block_length: bp_rialto_parachain::BlockLength::get(),
block_weights: bp_rialto_parachain::BlockWeights::get(),
},
messages_pallet_constants: AssertBridgeMessagesPalletConstants {
max_unrewarded_relayers_in_bridged_confirmation_tx:
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
max_unconfirmed_messages_in_bridged_confirmation_tx:
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
bridged_chain_id: bp_runtime::MILLAU_CHAIN_ID,
},
pallet_names: AssertBridgePalletNames {
with_this_chain_messages_pallet_name:
bp_rialto_parachain::WITH_RIALTO_PARACHAIN_MESSAGES_PALLET_NAME,
with_bridged_chain_grandpa_pallet_name: bp_millau::WITH_MILLAU_GRANDPA_PALLET_NAME,
with_bridged_chain_messages_pallet_name:
bp_millau::WITH_MILLAU_MESSAGES_PALLET_NAME,
},
});
}
}

0 comments on commit 25671f3

Please sign in to comment.