Skip to content

Commit

Permalink
👷‍♀️ Add a test for deep.equal matcher (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzadp committed Jul 28, 2022
1 parent b329845 commit c513a49
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
24 changes: 23 additions & 1 deletion waffle-chai/test/contracts/Matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const MATCHERS_SOURCE = `
counter += 1;
require(false, "Require cause");
}
function getTuple() external view returns (address, uint96) {
return (0xb319771f2dB6113a745bCDEEa63ec939Bf726207, 9771);
}
}
`;

Expand Down Expand Up @@ -131,8 +135,26 @@ export const MATCHERS_ABI = [
outputs: [],
stateMutability: 'nonpayable',
type: 'function'
},
{
inputs: [],
name: 'getTuple',
outputs: [
{
internalType: 'address',
name: '',
type: 'address'
},
{
internalType: 'uint96',
name: '',
type: 'uint96'
}
],
stateMutability: 'view',
type: 'function'
}
];

// eslint-disable-next-line max-len
export const MATCHERS_BYTECODE = '608060405234801561001057600080fd5b50610671806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c8063af9b573911610071578063af9b5739146100e0578063afc874d2146100ea578063b217ca11146100f4578063be3e2e60146100fe578063eacf8a5714610108578063fff78f9c14610112576100a9565b806301236db4146100ae5780632f576f20146100b8578063841caf38146100c25780639817185d146100cc578063a6f34dcb146100d6575b600080fd5b6100b661011c565b005b6100c0610170565b005b6100ca610172565b005b6100d461019c565b005b6100de6101b2565b005b6100e861020e565b005b6100f2610249565b005b6100fc610284565b005b61010661029f565b005b6101106102e2565b005b61011a610325565b005b600160008082825461012e9190610453565b925050819055506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610167906103c2565b60405180910390fd5b565b60016000808282546101849190610453565b92505081905550600061019a576101996104e4565b5b565b6000808160016101ac91906104a9565b90505050565b60016000808282546101c49190610453565b92505081905550600061020c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610203906103e2565b60405180910390fd5b565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024090610402565b60405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161027b906103c2565b60405180910390fd5b60016000808282546102969190610453565b92505081905550565b60016102e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d790610422565b60405180910390fd5b565b6000610323576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031a906103e2565b60405180910390fd5b565b6000610334576103336104e4565b5b565b6000610343600c83610442565b915061034e82610571565b602082019050919050565b6000610366600d83610442565b91506103718261059a565b602082019050919050565b6000610389602283610442565b9150610394826105c3565b604082019050919050565b60006103ac601083610442565b91506103b782610612565b602082019050919050565b600060208201905081810360008301526103db81610336565b9050919050565b600060208201905081810360008301526103fb81610359565b9050919050565b6000602082019050818103600083015261041b8161037c565b9050919050565b6000602082019050818103600083015261043b8161039f565b9050919050565b600082825260208201905092915050565b600061045e826104da565b9150610469836104da565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561049e5761049d610513565b5b828201905092915050565b60006104b4826104da565b91506104bf836104da565b9250826104cf576104ce610542565b5b828204905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f5265766572742063617573650000000000000000000000000000000000000000600082015250565b7f5265717569726520636175736500000000000000000000000000000000000000600082015250565b7f52657665727420636175736520287769746820636f6d706c657820726561736f60008201527f6e29000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6576657220746f206265207365656e0000000000000000000000000000000060008201525056fea26469706673582212200d6f653037fb208b2c580e808f575116267849837dff0eb0b0e67eb37bed45f464736f6c63430008070033';
export const MATCHERS_BYTECODE = '608060405234801561001057600080fd5b5061074f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063afc874d211610071578063afc874d2146100f5578063b217ca11146100ff578063be3e2e6014610109578063d51033db14610113578063eacf8a5714610132578063fff78f9c1461013c576100b4565b806301236db4146100b95780632f576f20146100c3578063841caf38146100cd5780639817185d146100d7578063a6f34dcb146100e1578063af9b5739146100eb575b600080fd5b6100c1610146565b005b6100cb61019a565b005b6100d561019c565b005b6100df6101c6565b005b6100e96101dc565b005b6100f3610238565b005b6100fd610273565b005b6101076102ae565b005b6101116102c9565b005b61011b61030c565b60405161012992919061042d565b60405180910390f35b61013a61032f565b005b610144610372565b005b600160008082825461015891906104e7565b925050819055506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161019190610456565b60405180910390fd5b565b60016000808282546101ae91906104e7565b9250508190555060006101c4576101c36105c2565b5b565b6000808160016101d6919061053d565b90505050565b60016000808282546101ee91906104e7565b925050819055506000610236576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161022d90610476565b60405180910390fd5b565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161026a90610496565b60405180910390fd5b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a590610456565b60405180910390fd5b60016000808282546102c091906104e7565b92505081905550565b600161030a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610301906104b6565b60405180910390fd5b565b60008073b319771f2db6113a745bcdeea63ec939bf72620761262b915091509091565b6000610370576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036790610476565b60405180910390fd5b565b6000610381576103806105c2565b5b565b61038c8161056e565b82525050565b600061039f600c836104d6565b91506103aa8261064f565b602082019050919050565b60006103c2600d836104d6565b91506103cd82610678565b602082019050919050565b60006103e56022836104d6565b91506103f0826106a1565b604082019050919050565b60006104086010836104d6565b9150610413826106f0565b602082019050919050565b610427816105aa565b82525050565b60006040820190506104426000830185610383565b61044f602083018461041e565b9392505050565b6000602082019050818103600083015261046f81610392565b9050919050565b6000602082019050818103600083015261048f816103b5565b9050919050565b600060208201905081810360008301526104af816103d8565b9050919050565b600060208201905081810360008301526104cf816103fb565b9050919050565b600082825260208201905092915050565b60006104f2826105a0565b91506104fd836105a0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610532576105316105f1565b5b828201905092915050565b6000610548826105a0565b9150610553836105a0565b92508261056357610562610620565b5b828204905092915050565b600061057982610580565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006bffffffffffffffffffffffff82169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f5265766572742063617573650000000000000000000000000000000000000000600082015250565b7f5265717569726520636175736500000000000000000000000000000000000000600082015250565b7f52657665727420636175736520287769746820636f6d706c657820726561736f60008201527f6e29000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6576657220746f206265207365656e0000000000000000000000000000000060008201525056fea26469706673582212200bc6f3499904916061bbdb525ce93269283b2bd2db9354c695c2134d66ede48364736f6c63430008070033';
23 changes: 22 additions & 1 deletion waffle-chai/test/matchers/misc.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import {MockProvider} from '@ethereum-waffle/provider';
import {expect, AssertionError} from 'chai';
import {ethers} from 'ethers';
import {BigNumber, ContractFactory, ethers} from 'ethers';
import {MATCHERS_ABI, MATCHERS_BYTECODE} from '../contracts/Matchers';

describe('UNIT: Miscellaneous', () => {
let provider: MockProvider;

before(async () => {
provider = new MockProvider();
});

const setup = async () => {
const [deployer] = provider.getWallets();

const factory = new ContractFactory(MATCHERS_ABI, MATCHERS_BYTECODE, deployer);
return {contract: await factory.deploy()};
};

describe('Proper address', () => {
it('Expect to be proper address', async () => {
expect('0x28FAA621c3348823D6c6548981a19716bcDc740e').to.be.properAddress;
Expand Down Expand Up @@ -96,5 +111,11 @@ describe('UNIT: Miscellaneous', () => {
expect(list).to.have.lengthOf.at.most(one.mul(3));
expect(() => expect(list).to.have.lengthOf.at.most(one)).to.throw;
});

it('deep.equal works', async () => {
const {contract} = await setup();
const tuple = await contract.getTuple();
expect(tuple).to.deep.equal(['0xb319771f2dB6113a745bCDEEa63ec939Bf726207', BigNumber.from(9771)]);
});
});
});

0 comments on commit c513a49

Please sign in to comment.