Skip to content

Commit 6f6a816

Browse files
Properly init genesis with bridge accounts for some tests mods
1 parent 613e324 commit 6f6a816

File tree

2 files changed

+66
-30
lines changed

2 files changed

+66
-30
lines changed

crates/humanode-runtime/src/tests/currency_swap.rs

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,34 @@ const INIT_BALANCE: Balance = 10u128.pow(18 + 6);
2121
fn new_test_ext_with() -> sp_io::TestExternalities {
2222
let authorities = vec![authority_keys("Alice")];
2323
let bootnodes = vec![account_id("Alice")];
24+
2425
let endowed_accounts = vec![account_id("Alice"), account_id("Bob")];
26+
let pot_accounts = vec![TreasuryPot::account_id(), FeesPot::account_id()];
27+
2528
let evm_endowed_accounts = vec![evm_account_id("EvmAlice"), evm_account_id("EvmBob")];
2629
// Build test genesis.
2730
let config = GenesisConfig {
2831
balances: BalancesConfig {
2932
balances: {
30-
let pot_accounts = vec![
31-
TreasuryPot::account_id(),
32-
FeesPot::account_id(),
33-
NativeToEvmSwapBridgePot::account_id(),
34-
];
33+
let pot_accounts = pot_accounts.clone();
3534
endowed_accounts
3635
.iter()
3736
.cloned()
3837
.chain(pot_accounts.into_iter())
3938
.map(|k| (k, INIT_BALANCE))
40-
.chain([(
41-
TokenClaimsPot::account_id(),
42-
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
43-
)])
39+
.chain(
40+
[(
41+
TokenClaimsPot::account_id(),
42+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
43+
),
44+
(
45+
NativeToEvmSwapBridgePot::account_id(),
46+
INIT_BALANCE * evm_endowed_accounts.len() as u128 +
47+
// Own bridge pot minimum balance.
48+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
49+
)]
50+
.into_iter(),
51+
)
4452
.collect()
4553
},
4654
},
@@ -69,8 +77,6 @@ fn new_test_ext_with() -> sp_io::TestExternalities {
6977
},
7078
evm: EVMConfig {
7179
accounts: {
72-
let evm_pot_accounts = vec![EvmToNativeSwapBridgePot::account_id()];
73-
7480
let init_genesis_account = fp_evm::GenesisAccount {
7581
balance: INIT_BALANCE.into(),
7682
code: Default::default(),
@@ -80,8 +86,24 @@ fn new_test_ext_with() -> sp_io::TestExternalities {
8086

8187
evm_endowed_accounts
8288
.into_iter()
83-
.chain(evm_pot_accounts.into_iter())
8489
.map(|k| (k, init_genesis_account.clone()))
90+
.chain(
91+
[(
92+
EvmToNativeSwapBridgePot::account_id(),
93+
fp_evm::GenesisAccount {
94+
balance: (INIT_BALANCE * (endowed_accounts.len() + pot_accounts.len()) as u128 +
95+
// Own bridge pot minimum balance.
96+
<EvmBalances as frame_support::traits::Currency<EvmAccountId>>::minimum_balance() +
97+
// `TokenClaimsPot` minimum balance.
98+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance()
99+
).into(),
100+
code: Default::default(),
101+
nonce: Default::default(),
102+
storage: Default::default(),
103+
},
104+
)]
105+
.into_iter(),
106+
)
85107
.collect()
86108
},
87109
},

crates/humanode-runtime/src/tests/fees.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Tests to verify the fee prices.
22
3+
// Allow simple integer arithmetic in tests.
4+
#![allow(clippy::integer_arithmetic)]
5+
36
use super::*;
47
use crate::dev_utils::*;
58
use crate::opaque::SessionKeys;
@@ -13,24 +16,28 @@ fn new_test_ext_with() -> sp_io::TestExternalities {
1316
let authorities = vec![authority_keys("Alice")];
1417
let bootnodes = vec![account_id("Alice")];
1518
let endowed_accounts = vec![account_id("Alice"), account_id("Bob")];
19+
let pot_accounts = vec![TreasuryPot::account_id(), FeesPot::account_id()];
1620
// Build test genesis.
1721
let config = GenesisConfig {
1822
balances: BalancesConfig {
1923
balances: {
20-
let pot_accounts = vec![
21-
TreasuryPot::account_id(),
22-
FeesPot::account_id(),
23-
NativeToEvmSwapBridgePot::account_id(),
24-
];
24+
let pot_accounts = pot_accounts.clone();
2525
endowed_accounts
2626
.iter()
2727
.cloned()
2828
.chain(pot_accounts.into_iter())
2929
.map(|k| (k, INIT_BALANCE))
30-
.chain([(
31-
TokenClaimsPot::account_id(),
32-
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
33-
)])
30+
.chain(
31+
[(
32+
TokenClaimsPot::account_id(),
33+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
34+
),
35+
(
36+
NativeToEvmSwapBridgePot::account_id(),
37+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance(),
38+
)]
39+
.into_iter(),
40+
)
3441
.collect()
3542
},
3643
},
@@ -59,15 +66,22 @@ fn new_test_ext_with() -> sp_io::TestExternalities {
5966
},
6067
evm: EVMConfig {
6168
accounts: {
62-
let evm_pot_accounts = vec![(
63-
EvmToNativeSwapBridgePot::account_id(),
64-
fp_evm::GenesisAccount {
65-
balance: INIT_BALANCE.into(),
66-
code: Default::default(),
67-
nonce: Default::default(),
68-
storage: Default::default(),
69-
},
70-
)];
69+
let evm_pot_accounts =
70+
vec![(
71+
EvmToNativeSwapBridgePot::account_id(),
72+
fp_evm::GenesisAccount {
73+
balance: (INIT_BALANCE * (endowed_accounts.len() + pot_accounts.len()) as u128 +
74+
// Own bridge pot minimum balance.
75+
<EvmBalances as frame_support::traits::Currency<EvmAccountId>>::minimum_balance() +
76+
// `TokenClaimsPot` minimum balance.
77+
<Balances as frame_support::traits::Currency<AccountId>>::minimum_balance()
78+
)
79+
.into(),
80+
code: Default::default(),
81+
nonce: Default::default(),
82+
storage: Default::default(),
83+
},
84+
)];
7185

7286
evm_pot_accounts.into_iter().collect()
7387
},

0 commit comments

Comments
 (0)