1.0.1 • Published 9 months ago

foundry-mock-generator v1.0.1

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
9 months 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>

Add a running script on your package.json

"mock-gen": "node node_modules/foundry-mock-generator/dist/run.js mock-gen"

Basic Usage

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

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

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

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

9 months ago

0.0.0-9fc5abde

9 months ago

1.0.1

11 months ago

0.0.0-c0c7dc8c

11 months ago

0.0.0-de291b63

11 months ago

0.0.0-680f534c

12 months ago

0.0.0-f17ea1b2

12 months ago

0.0.0-164419cb

12 months ago

0.0.0-3ac2bedf

12 months ago

0.0.0-7c0aeac9

12 months ago

0.0.0-8e1bf920

12 months ago

0.0.0-daefa94a

12 months ago

0.0.0-88d8ced7

12 months ago