A project template for the EOS contract.
- Generate contract file:
*.wasm
*.abi
- Native unit tests with Google Test
- Integration tests with cucumber-js
name | version |
---|---|
cmake | 3.10+ |
GNU Make | 4.1+ |
g++ | 7+ |
eos.cdt | 1.5.0 |
*docker | 18.06.0-ce |
*docker-compose | 1.22.0 |
* is for running integration test
-
Stander C++ sources
./include/
: C++ headers./cpp/
: C++ imlementation./test/
: unit test with Google Test
Don't place source files which use
#include <eosiolib/*>
in these folders -
EOS contract
./contract/
: EOS C++ files
-
Integration test
./integration_test/
-
Script
./clean_build.sh
:- clean folder
./build/*
- Build native excutable binary at
./build/mylib_test
with unit test - Build and output
./build/MyContract.abi
and./build/MyContract.wasm
- clean folder
-
Run
clean_build.sh
bash clean_build.sh
-
Or, run in pre-build docker image
docker run -it --rm --workdir $PWD --volume $PWD:$PWD yarencheng/eoscdt-docker bash clean_build.sh
-
Output
./build/MyContract.abi
./build/MyContract.wasm
Here will execute unit test in the ./test
folder. See Google Test for the detail
-
Run
test.sh
bash test.sh
-
Or, run in pre-build docker image
docker run -it --rm --workdir $PWD --volume $PWD:$PWD yarencheng/eoscdt-docker bash test.sh
Here use cucumber for testing. It is a famous BDD testing framework.
-
Put contract file in
./integration_test
. For example:./integration_testMyContract.wasm
./integration_testMyContract.abi
-
Modify the contract path to be used. See before_all.js
BeforeAll(function () { // ... // deploy contract cleos.setContract("myaccount", "./", "MyContract.wasm", "MyContract.abi") })
-
Run
docker-compose
.docker-compose \ --file integration_test/docker-compose.yaml \ up \ --exit-code-from=conntract_test \ --abort-on-container-exit \ --force-recreate \ --build
It will:
- Run
keosd
in a container - Run
nodeos
in a container - Deploy contract to testnet
- Run test with
cucumuber-js
- Run
- Test with googletest
- Build *.WASM file
- integration test flow