Skip to content

Commit

Permalink
EVM-IT: Mutate a seed every time accounts are created.
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Jan 20, 2023
1 parent f542ab8 commit d0203c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion testing/integration/src/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub struct Tester<B: Blockstore + 'static, E: Externs + 'static> {
pub executor: Option<IntegrationExecutor<B, E>>,
// State tree constructed before instantiating the Machine
pub state_tree: Option<StateTree<B>>,
/// Create accounts with determnistic keys..
accounts_rng_seed: u64,
}

impl<B, E> Tester<B, E>
Expand Down Expand Up @@ -92,6 +94,7 @@ where
state_tree: Some(state_tree),
accounts_code_cid,
placeholder_code_cid,
accounts_rng_seed: 8,
})
}

Expand All @@ -100,7 +103,8 @@ where
pub fn create_accounts<const N: usize>(&mut self) -> Result<[Account; N]> {
use rand::SeedableRng;

let rng = &mut rand_chacha::ChaCha8Rng::seed_from_u64(8);
let rng = &mut rand_chacha::ChaCha8Rng::seed_from_u64(self.accounts_rng_seed);
self.accounts_rng_seed += 1;

let mut ret: [Account; N] = [(0, Address::default()); N];
for account in ret.iter_mut().take(N) {
Expand Down
9 changes: 9 additions & 0 deletions testing/integration/tests/evm/features/SimpleCoin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ Feature: SimpleCoin
Given 1 random account
When account 1 creates a SimpleCoin contract
Then the balance of account 1 is 10000 coins

@two_deploys
Scenario: Two accounts deploy the same contract
Given 2 random accounts
When account 1 creates a SimpleCoin contract
And account 2 creates a SimpleCoin contract
# the suite queries the last deployed account
Then the balance of account 1 is 0 coins
And the balance of account 2 is 10000 coins

0 comments on commit d0203c0

Please sign in to comment.