Skip to content
lib.rs 65.5 KiB
Newer Older
			AccountId,
			TestMessagesProof,
			TestMessagesDeliveryProof,
		>::receive_messages_delivery_proof {
			proof: message_delivery_proof,
			relayers_state: unrewarded_relayer_state,
		};
		assert_eq!(
			direct_receive_messages_delivery_proof_call.encode(),
			indirect_receive_messages_delivery_proof_call.encode()
		);
	}

	generate_owned_bridge_module_tests!(
		MessagesOperatingMode::Basic(BasicOperatingMode::Normal),
		MessagesOperatingMode::Basic(BasicOperatingMode::Halted)
	);
	#[test]
	fn inbound_storage_extra_proof_size_bytes_works() {
		fn relayer_entry() -> UnrewardedRelayer<TestRelayer> {
			UnrewardedRelayer { relayer: 42u64, messages: DeliveredMessages { begin: 0, end: 100 } }
		}
		fn storage(relayer_entries: usize) -> RuntimeInboundLaneStorage<TestRuntime, ()> {
			RuntimeInboundLaneStorage {
				lane_id: Default::default(),
				cached_data: Some(InboundLaneData {
					relayers: vec![relayer_entry(); relayer_entries].into_iter().collect(),
		let max_entries = crate::mock::MaxUnrewardedRelayerEntriesAtInboundLane::get() as usize;

		// when we have exactly `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers
		assert_eq!(storage(max_entries).extra_proof_size_bytes(), 0);

		// when we have less than `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers
		assert_eq!(
			storage(max_entries - 1).extra_proof_size_bytes(),
			relayer_entry().encode().len() as u64
			storage(max_entries - 2).extra_proof_size_bytes(),
			2 * relayer_entry().encode().len() as u64
		);

		// when we have more than `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers
		// (shall not happen in practice)
		assert_eq!(storage(max_entries + 1).extra_proof_size_bytes(), 0);
	#[test]
	fn maybe_outbound_lanes_count_returns_correct_value() {
		assert_eq!(
			MaybeOutboundLanesCount::<TestRuntime, ()>::get(),
			Some(mock::ActiveOutboundLanes::get().len() as u32)
		);
	}