Godmode for Test
This library provides a truffle framework friendly api that allows developers to use the "Godmode Ganache" within the javascript testing environment provided in the truffle framework. The library also precompiles Godmode contracts for popular defi projects such as MakerDao, Uniswap, and Compound. It provides an easy way to modify the state of the projects through a set of API.
When using this library, you would need to run the Godmode ganache as well.
To see a sample project that uses this library, see this repo:
Repositories of the Hackathon Project
This project is built by Martinet Lee for ETHGlobal Hack The Money 2020, it consists of the following repositories:
Installation
npm install godmode-for-test
Setting it up in the test environment
In the javascript test file, import the library through:
const GM = ;
Initialize it with the provider, which should be the "Godmode Ganache".
The first argument indicates the network name -- use mainnet
if you want to use precompile contracts.
let GODMODE = "development" "ws://localhost:8545";
General Interaction
await GODMODE;
Variable explanation:
targetContract
is the deployed contract, for example:- the
hasOwnerShipContract
inhasOwnerShipContract = await HasOwnerShip.new({ from: Alice });
.
- the
replacementContractArtifact
is the contract artifact produced by truffle, for example:- the
HasOwnerShipInstrumented
inconst HasOwnerShipInstrumented = artifacts.require("HasOwnerShipInstrumented");
- the
function_In_RC
is the function that was defined in the replacementContractArtifact.
Precompiles
IMPORTANT: this only works on mainnet fork
MakerDao
Dai
- mint Dai to an address:
await GODMODE.mintDai(Bob, 10000);
Uniswap
- Enable Fee collection in UniswapV2:
await GODMODE.uniswapV2Factory_setFeeTo(Bob);
Compound
- Give the address cTokens:
await GODMODE.CToken_giveAddrTokens("0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e", Bob, 100);