@clrfund/waffle-mock-contract
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

@clrfund/waffle-mock-contract

Library for mocking smart contract dependencies during unit testing.

This library was cloned from @ethereum-waffle/waffle-mock-contract and modified to use ethers v6 and hardhat environment. This library will not be actively updated, it is only used in the Clr.fund project unit testing. As soon as the Waffle team release an updated version with ethers v6 support, this library will be archived.

Installation

yarn add --dev @clrfund/waffle-mock-contract
npm install --save-dev @clrfund/waffle-mock-contract

Usage

Create an instance of a mock contract providing the ABI/interface of the smart contract you want to mock:

const {deployMockContract} = require('@clrfund/waffle-mock-contract');

...

const mockContract = await deployMockContract(wallet, contractAbi);

Mock contract can now be passed into other contracts by using the target attribute.

   const anotherContract = await otherContract.doSomethingInteresting(mockContract.target);

Return values for mocked functions can be set using:

await mockContract.mock.<nameOfMethod>.returns(<value>)

Readme

Keywords

none

Package Sidebar

Install

npm i @clrfund/waffle-mock-contract

Weekly Downloads

9

Version

0.0.11

License

MIT

Unpacked Size

1.22 MB

Total Files

97

Last publish

Collaborators

  • yuetlooo
  • auryn_macmillan