Skip to content

Commit

Permalink
fix the test
Browse files Browse the repository at this point in the history
Signed-off-by: xermicus <[email protected]>
  • Loading branch information
xermicus committed Jun 3, 2024
1 parent 81321d7 commit a3f1502
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crates/integration/src/mock_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ impl State {
pub fn accounts(&self) -> &HashMap<Address, Account> {
&self.accounts
}

pub fn accounts_mut(&mut self) -> &mut HashMap<Address, Account> {
&mut self.accounts
}
}

fn link_host_functions(engine: &Engine) -> Linker<Transaction> {
Expand Down
7 changes: 5 additions & 2 deletions crates/integration/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,18 @@ fn balance() {
assert_eq!(expected, received);

let expected = U256::from(54589);
let (state, address) = State::new_deployed(Contract::call_constructor());
let (mut state, address) = State::new_deployed(Contract::value_balance_of(Default::default()));
state.accounts_mut().get_mut(&address).unwrap().value = expected;

let contract = Contract::value_balance_of(address);
let (_, output) = state
.transaction()
.with_default_account(&contract.pvm_runtime)
.calldata(contract.calldata)
.callvalue(expected)
.call();

assert_eq!(ReturnFlags::Success, output.flags);

let received = U256::from_be_slice(&output.data);
assert_eq!(expected, received)
}

0 comments on commit a3f1502

Please sign in to comment.