forked from octopus-network/substrate-ibc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock.rs
97 lines (85 loc) · 2.47 KB
/
mock.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use crate::{ChannelOrder, Module, ModuleCallbacks, Packet, Trait};
use sp_core::H256;
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
};
use frame_system as system;
impl_outer_origin! {
pub enum Origin for Test {}
}
// Configure a mock runtime to test the pallet.
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin;
type Call = ();
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type MaximumExtrinsicWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type PalletInfo = ();
type AccountData = ();
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
pub struct ModuleCallbacksImpl;
impl ModuleCallbacks for ModuleCallbacksImpl {
fn on_chan_open_try(
index: usize,
order: ChannelOrder,
connection_hops: Vec<H256>,
port_identifier: Vec<u8>,
channel_identifier: H256,
counterparty_port_identifier: Vec<u8>,
counterparty_channel_identifier: H256,
version: Vec<u8>,
counterparty_version: Vec<u8>,
) {
unimplemented!()
}
fn on_chan_open_ack(
index: usize,
port_identifier: Vec<u8>,
channel_identifier: H256,
version: Vec<u8>,
) {
unimplemented!()
}
fn on_chan_open_confirm(index: usize, port_identifier: Vec<u8>, channel_identifier: H256) {
unimplemented!()
}
fn on_recv_packet(index: usize, packet: Packet) {
unimplemented!()
}
}
impl Trait for Test {
type Event = ();
type ModuleCallbacks = ModuleCallbacksImpl;
}
pub type IbcModule = Module<Test>;
// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
}