mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 15:41:02 +00:00
Remove test dependecies on specific relay clients (#2898)
This commit is contained in:
committed by
Bastian Köcher
parent
4aa9594dd3
commit
f6e48f654b
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
#![cfg(any(feature = "test-helpers", test))]
|
#![cfg(any(feature = "test-helpers", test))]
|
||||||
|
|
||||||
use crate::{Chain, ChainWithBalances};
|
use crate::{Chain, ChainWithBalances, ChainWithMessages};
|
||||||
|
use bp_messages::{ChainWithMessages as ChainWithMessagesBase, MessageNonce};
|
||||||
use bp_runtime::ChainId;
|
use bp_runtime::ChainId;
|
||||||
use frame_support::weights::Weight;
|
use frame_support::weights::Weight;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -44,7 +45,7 @@ impl bp_runtime::Chain for TestChain {
|
|||||||
type Signature = sp_runtime::testing::TestSignature;
|
type Signature = sp_runtime::testing::TestSignature;
|
||||||
|
|
||||||
fn max_extrinsic_size() -> u32 {
|
fn max_extrinsic_size() -> u32 {
|
||||||
unreachable!()
|
100000
|
||||||
}
|
}
|
||||||
|
|
||||||
fn max_extrinsic_weight() -> Weight {
|
fn max_extrinsic_weight() -> Weight {
|
||||||
@@ -69,6 +70,18 @@ impl ChainWithBalances for TestChain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChainWithMessagesBase for TestChain {
|
||||||
|
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = "Test";
|
||||||
|
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 0;
|
||||||
|
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChainWithMessages for TestChain {
|
||||||
|
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = None;
|
||||||
|
const TO_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = "TestMessagesDetailsMethod";
|
||||||
|
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = "TestFromMessagesDetailsMethod";
|
||||||
|
}
|
||||||
|
|
||||||
/// Primitives-level parachain that may be used in tests.
|
/// Primitives-level parachain that may be used in tests.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct TestParachainBase;
|
pub struct TestParachainBase;
|
||||||
|
|||||||
@@ -58,6 +58,4 @@ sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "mas
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bp-rococo = { path = "../../chains/chain-rococo" }
|
bp-rococo = { path = "../../chains/chain-rococo" }
|
||||||
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
||||||
relay-bridge-hub-rococo-client = { path = "../../relay-clients/client-bridge-hub-rococo" }
|
relay-substrate-client = { path = "../client-substrate", features = ["test-helpers"] }
|
||||||
relay-bridge-hub-westend-client = { path = "../../relay-clients/client-bridge-hub-westend" }
|
|
||||||
relay-rococo-client = { path = "../../relay-clients/client-rococo" }
|
|
||||||
|
|||||||
@@ -554,9 +554,7 @@ fn split_msgs_to_refine<Source: Chain + ChainWithMessages, Target: Chain>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bp_runtime::Chain as ChainBase;
|
use relay_substrate_client::test_chain::TestChain;
|
||||||
use relay_bridge_hub_rococo_client::BridgeHubRococo;
|
|
||||||
use relay_bridge_hub_westend_client::BridgeHubWestend;
|
|
||||||
|
|
||||||
fn message_details_from_rpc(
|
fn message_details_from_rpc(
|
||||||
nonces: RangeInclusive<MessageNonce>,
|
nonces: RangeInclusive<MessageNonce>,
|
||||||
@@ -573,19 +571,13 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn validate_out_msgs_details_succeeds_if_no_messages_are_missing() {
|
fn validate_out_msgs_details_succeeds_if_no_messages_are_missing() {
|
||||||
assert!(validate_out_msgs_details::<BridgeHubRococo>(
|
assert!(validate_out_msgs_details::<TestChain>(&message_details_from_rpc(1..=3), 1..=3,)
|
||||||
&message_details_from_rpc(1..=3),
|
|
||||||
1..=3,
|
|
||||||
)
|
|
||||||
.is_ok());
|
.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn validate_out_msgs_details_succeeds_if_head_messages_are_missing() {
|
fn validate_out_msgs_details_succeeds_if_head_messages_are_missing() {
|
||||||
assert!(validate_out_msgs_details::<BridgeHubRococo>(
|
assert!(validate_out_msgs_details::<TestChain>(&message_details_from_rpc(2..=3), 1..=3,)
|
||||||
&message_details_from_rpc(2..=3),
|
|
||||||
1..=3,
|
|
||||||
)
|
|
||||||
.is_ok())
|
.is_ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,7 +586,7 @@ mod tests {
|
|||||||
let mut message_details_from_rpc = message_details_from_rpc(1..=3);
|
let mut message_details_from_rpc = message_details_from_rpc(1..=3);
|
||||||
message_details_from_rpc.remove(1);
|
message_details_from_rpc.remove(1);
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
validate_out_msgs_details::<BridgeHubRococo>(&message_details_from_rpc, 1..=3,),
|
validate_out_msgs_details::<TestChain>(&message_details_from_rpc, 1..=3,),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -602,7 +594,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn validate_out_msgs_details_map_fails_if_tail_messages_are_missing() {
|
fn validate_out_msgs_details_map_fails_if_tail_messages_are_missing() {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
validate_out_msgs_details::<BridgeHubRococo>(&message_details_from_rpc(1..=2), 1..=3,),
|
validate_out_msgs_details::<TestChain>(&message_details_from_rpc(1..=2), 1..=3,),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -610,7 +602,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn validate_out_msgs_details_fails_if_all_messages_are_missing() {
|
fn validate_out_msgs_details_fails_if_all_messages_are_missing() {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
validate_out_msgs_details::<BridgeHubRococo>(&[], 1..=3),
|
validate_out_msgs_details::<TestChain>(&[], 1..=3),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -618,7 +610,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn validate_out_msgs_details_fails_if_more_messages_than_nonces() {
|
fn validate_out_msgs_details_fails_if_more_messages_than_nonces() {
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
validate_out_msgs_details::<BridgeHubRococo>(&message_details_from_rpc(1..=5), 2..=5,),
|
validate_out_msgs_details::<TestChain>(&message_details_from_rpc(1..=5), 2..=5,),
|
||||||
Err(SubstrateError::Custom(_))
|
Err(SubstrateError::Custom(_))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -644,10 +636,8 @@ mod tests {
|
|||||||
msgs_to_refine.push((payload, out_msg_details));
|
msgs_to_refine.push((payload, out_msg_details));
|
||||||
}
|
}
|
||||||
|
|
||||||
let maybe_batches = split_msgs_to_refine::<BridgeHubRococo, BridgeHubWestend>(
|
let maybe_batches =
|
||||||
Default::default(),
|
split_msgs_to_refine::<TestChain, TestChain>(Default::default(), msgs_to_refine);
|
||||||
msgs_to_refine,
|
|
||||||
);
|
|
||||||
match expected_batches {
|
match expected_batches {
|
||||||
Ok(expected_batches) => {
|
Ok(expected_batches) => {
|
||||||
let batches = maybe_batches.unwrap();
|
let batches = maybe_batches.unwrap();
|
||||||
@@ -669,7 +659,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_msgs_to_refine() {
|
fn test_split_msgs_to_refine() {
|
||||||
let max_extrinsic_size = BridgeHubRococo::max_extrinsic_size() as usize;
|
let max_extrinsic_size = 100000;
|
||||||
|
|
||||||
// Check that an error is returned when one of the messages is too big.
|
// Check that an error is returned when one of the messages is too big.
|
||||||
check_split_msgs_to_refine(vec![max_extrinsic_size], Err(()));
|
check_split_msgs_to_refine(vec![max_extrinsic_size], Err(()));
|
||||||
|
|||||||
@@ -526,8 +526,7 @@ fn on_demand_headers_relay_name<SourceChain: Chain, TargetChain: Chain>() -> Str
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use relay_substrate_client::test_chain::TestChain;
|
||||||
type TestChain = relay_rococo_client::Rococo;
|
|
||||||
|
|
||||||
const AT_SOURCE: Option<bp_rococo::BlockNumber> = Some(10);
|
const AT_SOURCE: Option<bp_rococo::BlockNumber> = Some(10);
|
||||||
const AT_TARGET: Option<bp_rococo::BlockNumber> = Some(1);
|
const AT_TARGET: Option<bp_rococo::BlockNumber> = Some(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user