referrerpolicy=no-referrer-when-downgrade

snowbridge_test_utils/
mock_outbound_queue.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
3
4use crate::FAILING_NONCE;
5use snowbridge_core::reward::{AddTip, AddTipError};
6use snowbridge_outbound_queue_primitives::{
7	v1::{Fee, Message as MessageV1, SendMessage as SendMessageV1},
8	v2::{Message, SendMessage},
9	SendMessageFeeProvider,
10};
11use sp_core::H256;
12
13pub struct MockOkOutboundQueue;
14impl SendMessage for MockOkOutboundQueue {
15	type Ticket = ();
16
17	fn validate(
18		_: &Message,
19	) -> Result<Self::Ticket, snowbridge_outbound_queue_primitives::SendError> {
20		Ok(())
21	}
22
23	fn deliver(_: Self::Ticket) -> Result<H256, snowbridge_outbound_queue_primitives::SendError> {
24		Ok(H256::zero())
25	}
26}
27
28impl SendMessageFeeProvider for MockOkOutboundQueue {
29	type Balance = u128;
30
31	fn local_fee() -> Self::Balance {
32		0
33	}
34}
35
36impl AddTip for MockOkOutboundQueue {
37	fn add_tip(nonce: u64, _amount: u128) -> Result<(), AddTipError> {
38		if nonce == FAILING_NONCE {
39			return Err(AddTipError::NonceConsumed)
40		}
41		Ok(())
42	}
43}
44
45pub struct MockOkOutboundQueueV1;
46impl SendMessageV1 for MockOkOutboundQueueV1 {
47	type Ticket = ();
48
49	fn validate(
50		_: &MessageV1,
51	) -> Result<
52		(Self::Ticket, Fee<<Self as SendMessageFeeProvider>::Balance>),
53		snowbridge_outbound_queue_primitives::SendError,
54	> {
55		Ok(((), Fee::from((0, 0))))
56	}
57
58	fn deliver(_: Self::Ticket) -> Result<H256, snowbridge_outbound_queue_primitives::SendError> {
59		Ok(H256::zero())
60	}
61}
62
63impl SendMessageFeeProvider for MockOkOutboundQueueV1 {
64	type Balance = u128;
65
66	fn local_fee() -> Self::Balance {
67		0
68	}
69}