Skip to content

Commit

Permalink
TestTxEnv::spawn_accounts should ignore internal addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
james-chf committed Oct 26, 2022
1 parent 836a6de commit b1f7ee1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/src/vm_host_env/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,20 @@ impl TestTxEnv {
);
}

/// Fake accounts existence by initializating their VP storage.
/// Fake accounts' existence by initializing their VP storage.
/// This is needed for accounts that are being modified by a tx test to
/// pass account existence check in `tx_write` function.
/// pass account existence check in `tx_write` function. Any
/// [`Address::Internal`] passed in are ignored, as those should not have
/// wasm VPs in storage.
pub fn spawn_accounts(
&mut self,
addresses: impl IntoIterator<Item = impl Borrow<Address>>,
) {
let addresses: Vec<Address> = addresses
.into_iter()
.map(|a| a.borrow().to_owned())
.filter(|a| !matches!(a, Address::Internal(_)))
.collect();
for address in addresses {
let key = Key::validity_predicate(address.borrow());
let vp_code = vec![];
Expand Down

0 comments on commit b1f7ee1

Please sign in to comment.