Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('mocking mechanism works', async () => {
const doppelganger = new Doppelganger(Counter.interface);
await doppelganger.deploy(wallet);
const capContract = await deployContract(
wallet,
{
abi: Cap.interface,
evm: {
bytecode: {
object: Cap.bytecode,
},
},
},
[doppelganger.address],
);
await doppelganger.read.returns(5);
const ret1 = await expect(capContract.read()).to.be.eventually.fulfilled;
expect(ret1.toNumber()).to.be.equal(5);
const setupContext = async noInit => {
const provider = createMockProvider()
const wallets = getWallets(provider)
const [owner, partner1, partner2, weddingStub, other] = wallets
const wngMaster = await deployContract(owner, Wedding)
const wmrMaster = await deployContract(owner, WeddingManager)
const wmrMasterStub = await deployContract(owner, WeddingManagerStub)
const wngEmitterStub = await deployContract(owner, WeddingEventEmitterStub)
const wmrProxy = await deployContract(owner, UpgradeableProxy, [
wmrMaster.address
])
const wmr = new Contract(wmrProxy.address, WeddingManager.abi, owner)
if (!noInit) {
wmr.initialize(wngMaster.address, { gasLimit })
}
return {
provider,
wallets,
owner,
partner1,
partner2,
const setupContext = async noInit => {
const provider = createMockProvider()
const wallets = getWallets(provider)
const [owner, partner1, partner2, weddingStub, other] = wallets
const wngMaster = await deployContract(owner, Wedding)
const wmrMaster = await deployContract(owner, WeddingManager)
const wmrMasterStub = await deployContract(owner, WeddingManagerStub)
const wngEmitterStub = await deployContract(owner, WeddingEventEmitterStub)
const wmrProxy = await deployContract(owner, UpgradeableProxy, [
wmrMaster.address
])
const wmr = new Contract(wmrProxy.address, WeddingManager.abi, owner)
if (!noInit) {
wmr.initialize(wngMaster.address, { gasLimit })
}
return {
provider,
wallets,
owner,
partner1,
before(async () => {
await sdk.contracts.getMasterInstance("WalletMultisig", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
});
beforeEach(async () => {
proxyContract = await deployContract(wallet, Proxy, [
walletContract.address,
walletContract.interface.functions.initialize.encode([
[
addrToKey(user1.address),
],
[
'0x0000000000000000000000000000000000000000000000000000000000000007',
],
1,
1,
])
]);
proxyAsWallet = new ethers.Contract(proxyContract.address, Wallet.abi, provider);
await wallet.sendTransaction({to: proxyAsWallet.address, value: eth(1)});
});
before(async () => {
walletContract = await deployContract(wallet, Wallet, []);
targetContract = await deployContract(wallet, Target, []);
});
before(async () => {
await sdk.contracts.getMasterInstance("WalletMultisigRefundOutOfOrder", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
tokenContract = await deployContract(wallet, Token, []);
});
before(async () => {
walletContract = await deployContract(wallet, Wallet, []);
targetContract = await deployContract(wallet, Target, []);
});
before(async () => {
walletContract = await sdk.contracts.getMasterInstance("WalletOwnable", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));
});
async deploy(wallet: Wallet) {
this.contractInstance = await deployContract(wallet, DoppelgangerContract);
}
}