referrerpolicy=no-referrer-when-downgrade

pallet_revive/
test_utils.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Shared utilities for testing contracts.
19//! This is not part of the tests module because it is made public for other crates to use.
20
21pub mod builder;
22
23pub use sp_runtime::AccountId32;
24
25use crate::{BalanceOf, Config};
26use frame_support::weights::Weight;
27use hex_literal::hex;
28use sp_core::H160;
29
30const fn ee_suffix(mut account: [u8; 32]) -> AccountId32 {
31	let mut i = 20;
32	while i < 32 {
33		account[i] = 0xee;
34		i += 1;
35	}
36	AccountId32::new(account)
37}
38
39const fn ee_extend(address: [u8; 20]) -> AccountId32 {
40	let mut account = [0xEEu8; 32];
41	let mut i = 0;
42	while i < 20 {
43		account[i] = address[i];
44		i += 1;
45	}
46	AccountId32::new(account)
47}
48
49// All those accounts ids end in `ee` which means they don't
50// need a stateful mapping and their address is derived
51// by truncation without a hash applied/
52
53pub const ALICE: AccountId32 = ee_suffix([1u8; 32]);
54pub const ALICE_ADDR: H160 = H160([1u8; 20]);
55pub const ALICE_FALLBACK: AccountId32 = ALICE;
56
57pub const BOB: AccountId32 = ee_suffix([2u8; 32]);
58pub const BOB_ADDR: H160 = H160([2u8; 20]);
59pub const BOB_FALLBACK: AccountId32 = BOB;
60
61pub const CHARLIE: AccountId32 = ee_suffix([3u8; 32]);
62pub const CHARLIE_ADDR: H160 = H160([3u8; 20]);
63pub const CHARLIE_FALLBACK: AccountId32 = CHARLIE;
64
65pub const DJANGO: AccountId32 = ee_suffix([4u8; 32]);
66pub const DJANGO_ADDR: H160 = H160([4u8; 20]);
67pub const DJANGO_FALLBACK: AccountId32 = DJANGO;
68
69/// Eve is a non ee account and hence needs a stateful mapping and its
70/// address is derived by hashing to avoid truncating public keys.
71pub const EVE: AccountId32 = AccountId32::new([5u8; 32]);
72pub const EVE_ADDR: H160 = H160(hex!("e21eecd6e51cbcda5b0c5207ae87e605839e70ef"));
73pub const EVE_FALLBACK: AccountId32 = ee_extend(EVE_ADDR.0);
74
75pub const GAS_LIMIT: Weight = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024);
76
77pub fn deposit_limit<T: Config>() -> BalanceOf<T> {
78	10_000_000u32.into()
79}