Skip to content

Commit

Permalink
feat: test utils and abi code generator (#1013)
Browse files Browse the repository at this point in the history
* test: add test utils

* test: fix userdoc vs. devdoc interpretation

* test: starting to add fund setup helpers

* test: policy prototyping

* test: more fund setup utils

* test: resolve promises for convenience

* test: add capability to easily deploy contracts

* test: add codegen step to travis.yml

* test: organize imports

* test: code formatting

* test: add typecheck command

* test: ignore code formatting for generated code

* test: add test snapshots and unit testing utils

* test: remove static method

* test: cleanup

* test: finish general walkthrough example

* test: cleanup

* test: remove generated code from git

* test: refactor on top of crestproject

* test: restructure directories

* test: new command for new tests

* test: fix yarn.lock

* test: fix test preset

* fix: test imports

* test: use tx var for convenience and test readability

* test: update crestproject dependency

* test: add WIP of new kyberAdapter unit test suite and KyberTakeOrder util

* test: add WIP of new valueInterpreter unit test suite and prices util

* test: upgrade crestproject

* test: upgrade crestproject and implement simplifications

* test: update valueInterpreter unit test suite and prices util

* test: add WIP for shares unit test suite

* test: add WIP for vault unit test suite

* test: upgrade to latest crestproject version

* feat: update crestproject

* test: add event assertions

* test: update kyberAdapter test with boilerplate for forwarding

* test: add snapshot utils for infrastructural components

* test: update registry unit test to use new snapshot helpers

* test: update IIntegrationAdapter type

* test: renaming and cleanup

* test: add WIP for engine unit test suite

* test: add deployment script

* test: fix imports

* test: refactor tests

* test: add more deployment utils

* chore: fix PolicyManagerFactory in deployment script

* test: update kyberAdapter test

* test: add IERC20 to contracts

* test: remove console logs

* chore: add token approval to requestShares

* test: fix event parsing in fund setup

* test: update kyberAdapter test with new tests and to handle fund creation

* test: fix kyber adapter test

* test: refactor kyber adapter test

* test: better argument names

* test: refactor cleaner usage of ethers imports

* test: add a test to check expected incoming asset amount reverts

* test: add tests for trading back and forth

* test: remove old tests and refactor and cleanup repo

* chore: fix readme

* chore: directory cleanup

* test: fixing tests

* fix: prettier ignore path

* fix: ignore ganache-core

* fix: use caret dependencies

* test: use different jest matchers

* chore: add DS_Store to gitignore

* test: add a base contract for mock integratees, and a kyber mock integratee implementation

* fix: fix spdx license warnings

* test: use new integratee mock

* fix: crestproject history tracking

* test: upgrade nomiclabs buidler

* test: rename directory

* fix: move openzeppelin contracts do dependencies

* feat: add linting to travis

Co-authored-by: Sean Casey <[email protected]>
Co-authored-by: luongnt95 <[email protected]>
  • Loading branch information
3 people authored Jul 31, 2020
1 parent c31ea3a commit fb5c31c
Show file tree
Hide file tree
Showing 115 changed files with 5,476 additions and 17,507 deletions.
29 changes: 0 additions & 29 deletions .editorconfig

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ node_modules/

# ignore built code
build/
tests/contracts/build/
tests/contracts/codegen/

# ignore system files
.DS_Store
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore generated contracts
/tests/contracts/codegen
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 80,
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"bracketSpacing": true
}
12 changes: 0 additions & 12 deletions .solhint.json

This file was deleted.

32 changes: 18 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
language: node_js
sudo: required
os:
- linux
dist: bionic
services:
- docker

node_js:
- '12'
- '13'
- '14'

install: yarn --frozen-lockfile
script:
- node --version
- yarn --version
- yarn build
- yarn test
- yarn typecheck
- yarn lint

notifications:
email:
on_failure: change

cache:
yarn: true
directories:
- node_modules
install:
- yarn install
before_script:
- yarn devchain > ganache.log &
- until curl 127.0.0.1:8545 -X POST --data '{"method":"net_listening"}' >/dev/null 2>&1; do :; done
script:
- yarn compile
- yarn deploy
- yarn test
after_failure:
- cat ganache.log
9 changes: 4 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ As an open source project, we will consider changes to the code base from the co
The main branch that development work occurs on is the `develop` branch. It is usually encouraged to branch from there, and make pull requests back to `develop` when the change is made.

When making a pull request, please:

- follow the "Git Branching Model" outlined in this document
- follow the "Styleguide" outlined in this document
- add tests that cover newly introduced code
Expand All @@ -22,12 +23,14 @@ Please always make PRs into the `develop` branch.
We follow this [Git branching model](http://nvie.com/posts/a-successful-git-branching-model/).

Each branch name should be prefixed with either `feature/`, `fix/`, `refactor/`, or `chore/` depending on the type of work that is being done:

- `feature/my-branch` (for code that adds functionality)
- `fix/my-branch` (for fixing existing code)
- `refactor/my-branch` (for refactoring production code)
- `chore/my-branch` (for updating linters, documentation, etc)

The branch name should end with the Github issue number (where applicable):

- e.g., `feature/my-feature-#123` refers to issue #123.

## Styleguide
Expand All @@ -45,13 +48,9 @@ Using a linter is not a substitute for understanding the style guide, however, s

We use [solhint](https://github.com/protofire/solhint) for linting Solidity code. We extend solhint's [recommended rules](https://github.com/protofire/solhint/blob/master/docs/rules.md) with a few of our own, which can be found in `.solhint.json`.

#### ESLint

We will soon be implementing [ESLint](https://eslint.org/) for the javascript (e.g., tests, deployment scripts, utils) in the repo.

### Solidity

Please adhere to the recommended [official Solidity style guide for v0.6.1](https://solidity.readthedocs.io/en/v0.6.1/style-guide.html), in addition to the following styling choices:
Please adhere to the recommended [official Solidity style guide for v0.6.8](https://solidity.readthedocs.io/en/v0.6.8/style-guide.html), in addition to the following styling choices:

#### Namespacing

Expand Down
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ Melon is blockchain software that seeks to enable participants to set up, manage
The Melon protocol is a set of rules for how digital assets can be spent once held in a Melon smart-contract, or a Melon investment fund.
These rules are meant to protect the investor and fund manager from malevolent behaviour of each other, even when both parties remain private.

### Contract addresses

For the addresses of the latest deployed contracts, check out the `deployments/latest` directory on the `master` branch.

## Install

### Prerequisites
Expand All @@ -27,22 +23,12 @@ yarn install
## Compile contracts

```sh
yarn compile
yarn build
```

## Test

After the above "Compile contracts" step, follow the instructions below.

The tests are meant to be run on a ganache fork of mainnet.

```sh
# first terminal
export MAINNET_NODE_URL=https://mainnet.infura.io/v3/<infura id>
yarn devchain

# in a second terminal
yarn deploy
yarn test
```

Expand Down
2 changes: 2 additions & 0 deletions buidler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file simply exists to allow using the buidler evm.
module.exports = {};
75 changes: 0 additions & 75 deletions config.js

This file was deleted.

18 changes: 0 additions & 18 deletions contracts/dependencies/Migrations.sol

This file was deleted.

19 changes: 0 additions & 19 deletions contracts/dependencies/token/PreminedToken.sol

This file was deleted.

1 change: 1 addition & 0 deletions contracts/fund/hub/SpokeCallee.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "./ISpoke.sol";
Expand Down
1 change: 1 addition & 0 deletions contracts/fund/policies/utils/AddressListPolicyMixin.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "../../../dependencies/libs/EnumerableSet.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "./PolicyBase.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "./PolicyBase.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "./PolicyBase.sol";
Expand Down
1 change: 1 addition & 0 deletions contracts/fund/policies/utils/PolicyBase.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.8;

import "../../../registry/Registry.sol";
Expand Down
53 changes: 0 additions & 53 deletions contracts/testing/BadERC20Token.sol

This file was deleted.

Loading

0 comments on commit fb5c31c

Please sign in to comment.