I've got the integration tests using the simulator working on my main contract, and I have a second contract which does cross contracts call to it.
Can I create simulation test which loads both contracts and runs cross contract calls?
I started to try this and it would seem that I might be able deploy two contracts such as:
use near_sdk_sim::{call, init_simulator, deploy, UserAccount, ContractAccount};
use contract1::Contract1Contract;
use contract2::Contract2Contract; // <-- would need to do something different since contract2 is in a separate package
pub fn init() -> (UserAccount,
ContractAccount<Contract1Contract>,
ContractAccount<Contract1Contract>) {
let root = init_simulator(None);
let contract1 : ContractAccount<Contract1Contract> = deploy!(
contract: Contract1Contract,
contract_id: "contract1".to_string(),
bytes: &CONTRACT1_WASM_BYTES,
signer_account: root,
);
let contract2 : ContractAccount<Contract2Contract> = deploy!(
contract: Contract1Contract,
contract_id: "contract2".to_string(),
bytes: &CONTRACT2_WASM_BYTES,
signer_account: root,
);
(root, contract1, contract2)
}
I realized since the two contracts are in different packages I wasn't sure how to import the structure for contract2 one into the integration tests for contract1.
Is there a way to do this and/or and example to look at?
Does the simulator even support this? (i.e. deploying two contracts in the same test)