"relays/bin-substrate/Cargo.toml" did not exist on "509ef6dcfb4ea31501266d19a7baf750768931f9"
Newer
Older
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
Svyatoslav Nikolsky
committed
vec![(ParaId(PARA_ID), ParaHashAtSource::Some(PARA_0_HASH))]
.into_iter()
.collect(),
vec![(
ParaId(PARA_ID),
Some(BestParaHeadHash { at_relay_block_number: 20, head_hash: PARA_1_HASH })
)]
.into_iter()
.collect(),
HeaderId(10, Default::default()),
),
Vec::<ParaId>::new(),
);
}
#[test]
fn parachain_is_not_updated_if_hash_is_the_same_at_next_relay_block() {
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
Svyatoslav Nikolsky
committed
vec![(ParaId(PARA_ID), ParaHashAtSource::Some(PARA_0_HASH))]
.into_iter()
.collect(),
vec![(
ParaId(PARA_ID),
Some(BestParaHeadHash { at_relay_block_number: 0, head_hash: PARA_0_HASH })
)]
.into_iter()
.collect(),
HeaderId(10, Default::default()),
),
Vec::<ParaId>::new(),
);
}
#[test]
fn parachain_is_updated_after_offboarding() {
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
Svyatoslav Nikolsky
committed
vec![(ParaId(PARA_ID), ParaHashAtSource::None)].into_iter().collect(),
vec![(
ParaId(PARA_ID),
Some(BestParaHeadHash {
at_relay_block_number: 0,
head_hash: Default::default(),
})
)]
.into_iter()
.collect(),
HeaderId(10, Default::default()),
),
vec![ParaId(PARA_ID)],
);
}
#[test]
fn parachain_is_updated_after_onboarding() {
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
Svyatoslav Nikolsky
committed
vec![(ParaId(PARA_ID), ParaHashAtSource::Some(PARA_0_HASH))]
.into_iter()
.collect(),
vec![(ParaId(PARA_ID), None)].into_iter().collect(),
HeaderId(10, Default::default()),
),
vec![ParaId(PARA_ID)],
);
}
#[test]
fn parachain_is_updated_if_newer_head_is_known() {
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
Svyatoslav Nikolsky
committed
vec![(ParaId(PARA_ID), ParaHashAtSource::Some(PARA_1_HASH))]
.into_iter()
.collect(),
vec![(
ParaId(PARA_ID),
Some(BestParaHeadHash { at_relay_block_number: 0, head_hash: PARA_0_HASH })
)]
.into_iter()
.collect(),
HeaderId(10, Default::default()),
),
vec![ParaId(PARA_ID)],
);
}
Svyatoslav Nikolsky
committed
#[test]
fn parachain_is_not_updated_if_source_head_is_unavailable() {
assert_eq!(
select_parachains_to_update::<TestParachainsPipeline>(
vec![(ParaId(PARA_ID), ParaHashAtSource::Unavailable)].into_iter().collect(),
vec![(
ParaId(PARA_ID),
Some(BestParaHeadHash { at_relay_block_number: 0, head_hash: PARA_0_HASH })
)]
.into_iter()
.collect(),
HeaderId(10, Default::default()),
),
vec![],
);
}
#[test]
fn is_update_required_works() {
let mut sync_params = ParachainSyncParams {
parachains: vec![ParaId(PARA_ID), ParaId(PARA_1_ID)],
strategy: ParachainSyncStrategy::Any,
stall_timeout: Duration::from_secs(60),
};
Svyatoslav Nikolsky
committed
assert!(!is_update_required(&sync_params, &[]));
assert!(is_update_required(&sync_params, &[ParaId(PARA_ID)]));
assert!(is_update_required(&sync_params, &[ParaId(PARA_ID), ParaId(PARA_1_ID)]));
sync_params.strategy = ParachainSyncStrategy::All;
Svyatoslav Nikolsky
committed
assert!(!is_update_required(&sync_params, &[]));
assert!(!is_update_required(&sync_params, &[ParaId(PARA_ID)]));
assert!(is_update_required(&sync_params, &[ParaId(PARA_ID), ParaId(PARA_1_ID)]));