Skip to content
parachains_loop.rs 28.2 KiB
Newer Older
	fn parachain_is_updated_if_newer_head_is_known() {
		assert_eq!(
			select_parachains_to_update::<TestParachainsPipeline>(
				vec![(ParaId(PARA_ID), 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)],
		);
	}

	#[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),
		};

		assert_eq!(is_update_required(&sync_params, &[]), false);
		assert_eq!(is_update_required(&sync_params, &[ParaId(PARA_ID)]), true);
		assert_eq!(is_update_required(&sync_params, &[ParaId(PARA_ID), ParaId(PARA_1_ID)]), true);

		sync_params.strategy = ParachainSyncStrategy::All;
		assert_eq!(is_update_required(&sync_params, &[]), false);
		assert_eq!(is_update_required(&sync_params, &[ParaId(PARA_ID)]), false);
		assert_eq!(is_update_required(&sync_params, &[ParaId(PARA_ID), ParaId(PARA_1_ID)]), true);
	}
}