Skip to content

Commit b780da5

Browse files
Add more checks to verify slashing logic at a corresponding runtime test (#1620)
Add more checks to verify slashin logic at a corresponding runtime test
1 parent 57d1447 commit b780da5

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ const INIT_BALANCE: u128 = 10u128.pow(18 + 6);
1515
/// Build test externalities from the custom genesis.
1616
/// Using this call requires manual assertions on the genesis init logic.
1717
fn new_test_ext_with() -> sp_io::TestExternalities {
18-
let authorities = [authority_keys("Alice"), authority_keys("Bioauth-1")];
18+
let authorities = [
19+
authority_keys("Alice"),
20+
authority_keys("Bioauth-1"),
21+
authority_keys("FixedValidatorsSet-1"),
22+
];
1923
let bootnodes = vec![account_id("Alice")];
24+
let fixed_validators_set = vec![account_id("FixedValidatorsSet-1")];
2025

2126
let endowed_accounts = [account_id("Alice"), account_id("Bob")];
2227
let pot_accounts = vec![FeesPot::account_id()];
@@ -78,6 +83,9 @@ fn new_test_ext_with() -> sp_io::TestExternalities {
7883
.unwrap(),
7984
..Default::default()
8085
},
86+
fixed_validators_set: FixedValidatorsSetConfig {
87+
validators: fixed_validators_set.try_into().unwrap(),
88+
},
8189
evm: EVMConfig {
8290
accounts: {
8391
let init_genesis_account = fp_evm::GenesisAccount {
@@ -118,13 +126,18 @@ fn works() {
118126
// Build the state from the config.
119127
new_test_ext_with().execute_with(move || {
120128
// Check test preconditions.
129+
assert_eq!(Bootnodes::bootnodes(), vec![account_id("Alice")]);
121130
assert_eq!(
122131
Bioauth::active_authentications(),
123132
vec![pallet_bioauth::Authentication {
124133
public_key: account_id("Bioauth-1"),
125134
expires_at: 1000,
126135
}]
127136
);
137+
assert_eq!(
138+
FixedValidatorsSet::validators(),
139+
vec![account_id("FixedValidatorsSet-1")]
140+
);
128141

129142
// Report unresponsiveness offence.
130143
HumanodeOffences::report_offence(
@@ -146,6 +159,11 @@ fn works() {
146159
.unwrap();
147160

148161
// Assert state changes.
162+
assert_eq!(Bootnodes::bootnodes(), vec![account_id("Alice")]);
149163
assert!(Bioauth::active_authentications().is_empty());
164+
assert_eq!(
165+
FixedValidatorsSet::validators(),
166+
vec![account_id("FixedValidatorsSet-1")]
167+
);
150168
})
151169
}

0 commit comments

Comments
 (0)