Skip to content

Commit 2caf9a4

Browse files
committed
Avoid a test panic that's easy to trigger
1 parent 3f15d2d commit 2caf9a4

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Diff for: crates/sp-domains-fraud-proof/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn benchmark_bundle_with_evm_tx(
3939
mut alice: EvmDomainNode,
4040
mut ferdie: MockConsensusNode,
4141
) -> (Vec<Vec<u8>>, StorageProof) {
42-
let account_infos = (1..tx_to_create)
42+
let account_infos = (0..tx_to_create)
4343
.map(|i| address_build(i as u128))
4444
.collect::<Vec<AccountInfo>>();
4545

@@ -606,7 +606,7 @@ async fn test_evm_domain_block_fee() {
606606
// Create more accounts and fund these accounts
607607
let tx_to_create = 3;
608608
let account_infos = (0..tx_to_create)
609-
.map(|i| address_build(i as u128 + 1))
609+
.map(|i| address_build(i as u128))
610610
.collect::<Vec<AccountInfo>>();
611611
let alice_balance = alice.free_balance(Alice.to_account_id());
612612
for (i, account_info) in account_infos.iter().enumerate() {

Diff for: crates/sp-domains/src/test_ethereum_tx.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ pub struct AccountInfo {
2626
}
2727

2828
/// Returns an AccountInfo struct with a deterministic address and private key.
29-
/// Seed zero produces an invalid private key.
30-
pub fn address_build(seed: u128) -> AccountInfo {
29+
/// Seed zero produces an invalid private key, so we add one to the supplied seed.
30+
pub fn address_build(mut seed: u128) -> AccountInfo {
31+
seed += 1;
32+
3133
let mut seed_bytes = [0u8; 32];
3234
seed_bytes[0..16].copy_from_slice(&seed.to_be_bytes());
3335
let private_key = H256::from_slice(&seed_bytes);

Diff for: domains/client/domain-operator/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ async fn test_evm_domain_create_contracts_with_allow_list() {
290290
// Create more accounts and fund these accounts
291291
let tx_to_create = 5;
292292
let account_infos = (0..tx_to_create)
293-
.map(|i| address_build(i as u128 + 1))
293+
.map(|i| address_build(i as u128))
294294
.collect::<Vec<AccountInfo>>();
295295
let alice_balance = alice.free_balance(Alice.to_account_id());
296296
for (i, account_info) in account_infos.iter().enumerate() {
@@ -4710,7 +4710,7 @@ async fn test_domain_sudo_calls() {
47104710
// once the call is executed in the domain, list will be updated.
47114711
let accounts_to_create = 4;
47124712
let account_infos = (0..accounts_to_create)
4713-
.map(|i| address_build(i as u128 + 1))
4713+
.map(|i| address_build(i as u128))
47144714
.collect::<Vec<AccountInfo>>();
47154715

47164716
// Start with a redundant set to make sure the test framework works.

0 commit comments

Comments
 (0)