How to use ethereum-waffle - 10 common examples

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 / 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 ------------------------------
	let proxy = null;
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 / 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 Amxx / KitsuneWallet-ERC1836 / test / fixtures / testInitialize.js View on Github external
describe('Initialize', async () => {

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

		it('Verify proxy initialization', async () => {
			expect(await proxy.owner()).to.eq(proxy.address);
			expect(await proxy.master()).to.eq((await sdk.contracts.getMasterInstance(name)).address);
			expect(await proxy.getManagementThreshold()).to.eq(1);
			expect(await proxy.getActionThreshold()).to.eq(1);
		});

		it('reintrance protection', async () => {
			await expect(proxy.connect(user1).initialize(
				[
					sdk.utils.addrToKey(user1.address),
				],
				[
					'0x0000000000000000000000000000000000000000000000000000000000000007',
				],
github Amxx / KitsuneWallet-ERC1836 / test / fixtures / testKeyManagement.js View on Github external
describe('Key Management', async () => {

		const [ wallet, relayer, user1, user2, user3 ] = getWallets(sdk.provider);
		const dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));

		it('getKey', async () => {
			expect(await proxy.functions['getKey(bytes32)'](sdk.utils.addrToKey(user1.address))).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000007');
			expect(await proxy.functions['getKey(bytes32)'](sdk.utils.addrToKey(user2.address))).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000000');
			expect(await proxy.functions['getKey(address)'](                    user1.address )).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000007');
			expect(await proxy.functions['getKey(address)'](                    user2.address )).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000000');
		});

		it('keyHasPurpose', async () => {
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000001')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000002')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000004')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000008')).to.be.eq(false);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000007')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000009')).to.be.eq(false);
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 Amxx / KitsuneWallet-ERC1836 / test / fixtures / testOutOfOrder.js View on Github external
describe('testOutOfOrder', async () => {

		const [ wallet, relayer, user1, user2, user3 ] = getWallets(sdk.provider);
		const dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));

		it('valid nonce', async () => {
			expect(await proxy.nonce()).to.be.eq(0);
			await expect(sdk.multisig.execute(
				proxy,
				[ user1 ],
				{ to: dest, nonce: 1 },
				{ options: { gasLimit: 1000000 } },
			)).to.emit(proxy, 'CallSuccess').withArgs(dest);
			expect(await proxy.nonce()).to.be.eq(1);
		});

		it('invalid nonce', async () => {
			expect(await proxy.nonce()).to.be.eq(0);
			await expect(sdk.multisig.execute(
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 / proxied.ts View on Github external
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);

ethereum-waffle

Sweeter, faster and simpler than truffle.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis