How to use the ethereum-waffle.createMockProvider function in ethereum-waffle

To help you get started, we’ve selected a few ethereum-waffle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Amxx / KitsuneWallet-ERC1836 / kitsune-sdk / examples / 000_deploy-and-upgrade.js View on Github external
(async () => {

	const provider = createMockProvider();
	const [ relayer, user1, user2, user3 ] = getWallets(provider);
	await provider.ready;

	const sdk = new SDK(provider, relayer);

	// ------------------------ Check master deployments ------------------------
	// for (let master of Object.keys(sdk.contracts.ABIS).filter(name => name !== "Proxy"))
	// {
	// 	let instance = await sdk.contracts.getMasterInstance(master);
	// 	console.log(`${master} is available on chain '${name}' (${chainId}).`)
	// 	console.log(`→ ${instance['address']}`);
	// 	console.log(`---`);
	// }

	// ------------------------------ create proxy ------------------------------
	let proxy = null;
github Amxx / KitsuneWallet-ERC1836 / examples / 000_deploy-and-upgrade.js View on Github external
const { ethers } = require('ethers');
const { createMockProvider, getWallets, solidity} = require('ethereum-waffle');
const { Sdk }    = require('../sdk/sdk.js');

ethers.errors.setLogLevel('error');

const provider = createMockProvider();
const [ relayer, user1, user2, user3 ] = getWallets(provider);

provider.ready.then(async () => {

	const sdk = new Sdk(provider, relayer);

	// ------------------------ Check master deployments ------------------------
	// for (let master of Object.keys(sdk.contracts.ABIS).filter(name => name !== "Proxy"))
	// {
	// 	let instance = await sdk.contracts.getMasterInstance(master);
	// 	console.log(`${master} is available on chain '${name}' (${chainId}).`)
	// 	console.log(`→ ${instance['address']}`);
	// 	console.log(`---`);
	// }

	// ------------------------------ create proxy ------------------------------
github EthWorks / Doppelganger / test / units / doppelganger_contract.ts View on Github external
describe('Doppelganger - Contract', () => {
  const provider = createMockProvider();
  const [wallet] = getWallets(provider);
  let contract: Contract;

  beforeEach(async () => {
    contract = await deployContract(wallet, DoppelgangerContract);
  });

  describe('mocking mechanism', () => {
    let pretender: Contract;
    const readSignature = '0x57de26a4';

    beforeEach(async () => {
      pretender = new Contract(contract.address, Counter.interface, wallet);
    });

    it('returns preprogrammed return values for mocked functions', async () => {
github EthWorks / Doppelganger / test / integrations / proxied.ts View on Github external
describe('Doppelganger - Integration (called by other contract)', () => {
  const provider = createMockProvider();
  const [wallet] = getWallets(provider);

  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],
github EthWorks / Doppelganger / test / integrations / direct.ts View on Github external
describe('Doppelganger - Integration (called directly)', () => {
  const provider = createMockProvider();
  const [wallet] = getWallets(provider);

  it('mocking mechanism works', async () => {
    const doppelganger = new Doppelganger(Counter.interface);
    await doppelganger.deploy(wallet);
    await doppelganger.read.returns(45291);
    const contract = doppelganger.pretendedContract(wallet);

    const ret = await expect(contract.read()).to.be.eventually.fulfilled;
    expect(ret.toNumber()).to.be.equal(45291);
  });
});
github TovarishFin / crypto-weddings-contracts / test / helpers / general.js View on Github external
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 })
  }
github Amxx / KitsuneWallet-ERC1836 / test / wallets / WalletMultisigRefund.js View on Github external
describe('Wallet', () => {

	const provider = createMockProvider();
	const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
	const sdk = new SDK(provider, relayer);

	before(async () => {
		await sdk.contracts.getMasterInstance("WalletMultisigRefund", { allowDeploy: true });
		targetContract = await deployContract(wallet, Target, []);
		tokenContract  = await deployContract(wallet, Token,  []);
	});

	beforeEach(async () => {
		proxy = await sdk.contracts.deployProxy(
			"WalletMultisigRefund",
			[
				[
					sdk.utils.addrToKey(user1.address),
				],
github Amxx / KitsuneWallet-ERC1836 / test / wallets / WalletMultisigRefundOutOfOrder.js View on Github external
describe('Wallet', () => {

	const provider = createMockProvider();
	const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
	const sdk = new SDK(provider, relayer);

	before(async () => {
		await sdk.contracts.getMasterInstance("WalletMultisigRefundOutOfOrder", { allowDeploy: true });
		targetContract = await deployContract(wallet, Target, []);
		tokenContract  = await deployContract(wallet, Token,  []);
	});

	beforeEach(async () => {
		proxy = await sdk.contracts.deployProxy(
			"WalletMultisigRefundOutOfOrder",
			[
				[
					sdk.utils.addrToKey(user1.address),
				],
github Amxx / KitsuneWallet-ERC1836 / test / wallets / WalletMultisig.js View on Github external
describe('Wallet', () => {

	const provider = createMockProvider();
	const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
	const sdk = new SDK(provider, relayer);

	before(async () => {
		await sdk.contracts.getMasterInstance("WalletMultisig", { allowDeploy: true });
		targetContract = await deployContract(wallet, Target, []);
	});

	beforeEach(async () => {
		proxy = await sdk.contracts.deployProxy(
			"WalletMultisig",
			[
				[
					sdk.utils.addrToKey(user1.address),
				],
				[
github Amxx / KitsuneWallet-ERC1836 / kitsune-sdk / examples / 100_deploy-and-upgrade.ts View on Github external
(async () => {

	const provider = createMockProvider();
	const [ wallet ] = getWallets(provider);

	var sdk = new SDK(provider, wallet)

	var proxy = await sdk.contracts.deployProxy(
		"WalletOwnable",
		[ wallet.address ],
		{ deploy: { enable: true } }
	);
	console.log(`proxy          : ${proxy.address}`               );
	console.log(`implementation : ${await proxy.implementation()}`);
	console.log(`owner          : ${await proxy.owner()}`         );
	console.log("");

	proxy = await sdk.contracts.upgradeProxy(
		proxy,

ethereum-waffle

Sweeter, faster and simpler than truffle.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis