0.0.0-f17ea1b2 • Published 3 years ago

foundry-mock-generator v0.0.0-f17ea1b2

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
3 years ago

Foundry Mock Generator is the solidity mocking library. It's a plugin for foundry that can be used to create mock Solidity contracts able to mock variables and external calls.

Features

  • Get rid of your folder of "mock" contracts and just use foundry.
  • Keep your tests simple with a easy mock functions.
  • Mock up external calls and variables in a beautiful and orderly fashion.

Installation

You can install the tool via yarn:

yarn add foundry-mock-generator@<latest-canary>

Basic Usage

To generate the mock contracts all you have to do is run:

yarn foundry-mock-generation --contractsDir <path/to/contracts> --outDir <path/to/foundry/out> --genDir <path/to/generate/contracts>

Note: --genDir default path is solidity/test/mock-contracts Note: --outDir default path is out

1) To use the mock contracts in your tests just import them.

import { MockMyContractName } from '/path/to/mock-contracts/MockMyContractName.sol'

2) To mock a function or variable e.g.:

/// Deploy mock contract
mock_myContract = new MockMyContractname(...);
/// Mock myFuncName function, when called with `arg1`, `arg2` to return `return1`
mock_myContract.mock_myFuncName(arg1, arg2, return1);
/// Mock myVarName variable, to return `return1`
mock_myContract.mock_myVarName(return1);

Contributors

Maintained with love by Wonderland. Made possible by viewers like you.

0.0.0-0e94d7c2

2 years ago

0.0.0-9fc5abde

2 years ago

1.0.1

3 years ago

0.0.0-c0c7dc8c

3 years ago

0.0.0-de291b63

3 years ago

0.0.0-680f534c

3 years ago

0.0.0-f17ea1b2

3 years ago

0.0.0-164419cb

3 years ago

0.0.0-3ac2bedf

3 years ago

0.0.0-7c0aeac9

3 years ago

0.0.0-8e1bf920

3 years ago

0.0.0-daefa94a

3 years ago

0.0.0-88d8ced7

3 years ago