Skip to content

Latest commit

 

History

History
93 lines (58 loc) · 1.93 KB

README.md

File metadata and controls

93 lines (58 loc) · 1.93 KB

Solidity Test Generator (Proof of Concept)

Solidity test generator is a tool that generates Truffle compatible JavaScript tests for a smart contract written in Solidity language. This tool is a PoC and is not reliable with large scale smart contracts.

Requirements

  • Mythril Classic with test input generation module:

https://github.com/pauliax/mythril-classic/

  • Solidity compilator (solc), recommended version: 0.4.25

  • NodeJS & npm

  • node-gyp:

npm install -g node-gyp
  • Python 2.7, on Windows can be installed by running this command:
npm install --global --production windows-build-tools
  • Install dependencies after cloning this repo:
npm install

Recommended

  • Add Myth and solc to environment variables

  • Ubuntu 18.0.4 (also works on WSL)

  • Truffle 4:

npm install -g truffle@4
  • Add truffle-assertions to your Truffle project:
npm install truffle-assertions
npm install --save-dev solidity-coverage

You can run solidity-coverage by running this command:

./node_modules/.bin/solidity-coverage

Run

  • Run Mythril Classic on smart contract and place generated txs.json file to data folder:
./myth -v 4 -xo jsonv2 <PATH_TO_THE_SMART_CONTRACT> -m test_input_generator
  • Run Solidity compilator with --abi flag on the same smart contract:
solc --abi <PATH_TO_THE_SMART_CONTRACT>
  • Run Solidity test generator:
node index

Generated test file is placed in generated-tests directory. You need to manually move this file to your Truffle project. Also, do not forget to install truffle-assertions package. Run the tests:

truffle test

Sometimes generated tests fail so you need to manually review them and fix or comment them out.

Limitations

TBA