Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONT MERGE] unify coverage #265

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
260 changes: 260 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
version: 2.1
jobs:
tests:
docker:
# specify the version you desire here
- image: circleci/node:10.23.0
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/

working_directory: ~/repo

steps:
- run:
|
sudo apt-get install libudev-dev
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout

- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update

- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

# # Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm i

- save_cache:
paths:
- compound-protocol/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/package.json" }}

- save_cache:
paths:
- compound-protocol/scenario/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- run:
name: Run tests
command: yarn test #triggers truffle test

coverage:
docker:
# specify the version you desire here
- image: circleci/node:10.23.0
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/

working_directory: ~/repo

steps:
- run:
|
sudo apt-get install libudev-dev
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: sudo npm i

- save_cache:
paths:
- compound-protocol/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/package.json" }}

- save_cache:
paths:
- compound-protocol/scenario/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- run:
name: Run coverage
command: yarn prepare && yarn coverage #triggers coverage

# coverage-WPM:
# docker:
# # specify the version you desire here
# - image: circleci/node:10.23.0
# # Specify service dependencies here if necessary
# # CircleCI maintains a library of pre-built images
# # documented at https://circleci.com/docs/2.0/circleci-images/

# working_directory: ~/repo

# steps:
# - run:
# |
# sudo apt-get install libudev-dev
# sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
# sudo chmod +x /usr/local/bin/solc
# - checkout
# - run:
# name: "Pull Submodules"
# command: |
# git submodule init
# git submodule update
# - restore_cache:
# keys:
# - v1-dependencies-{{ checksum "compound-protocol/package.json" }}
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-

# - restore_cache:
# keys:
# - v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-

# # Download and cache dependencies
# - restore_cache:
# keys:
# - v1-dependencies-{{ checksum "package.json" }}
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-

# - run: sudo npm i

# - save_cache:
# paths:
# - compound-protocol/node_modules
# key: v1-dependencies-{{ checksum "compound-protocol/package.json" }}

# - save_cache:
# paths:
# - compound-protocol/scenario/node_modules
# key: v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}

# - save_cache:
# paths:
# - node_modules
# key: v1-dependencies-{{ checksum "package.json" }}

# - run:
# name: Run coverage
# command: yarn prepare && yarn coverage-WPM #triggers coverage for whitePaperModel tests

deploy-ready:
docker:
# specify the version you desire here
- image: circleci/node:10.23.0
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/

working_directory: ~/repo

steps:
- run:
|
sudo apt-get install libudev-dev
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.16/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update
- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- restore_cache:
keys:
- v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: sudo npm i

- save_cache:
paths:
- compound-protocol/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/package.json" }}

- save_cache:
paths:
- compound-protocol/scenario/node_modules
key: v1-dependencies-{{ checksum "compound-protocol/scenario/package.json" }}

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- run:
name: truffle contract size
command: yarn prepare && yarn contract-size

workflows:
version: 2.1
build:
jobs:
- coverage
- tests
- deploy-ready

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"clean-snapshot": "rimraf snapshots/whitePaperModel && rimraf snapshots/scriptFlywheel && rimraf snapshots/coverage",
"coverage-WPM": "FILE=coverage npm run clean-snapshot && FILE=coverage npm run unzip-snapshot && npm run copy-coverage-files-WPM && npm run exec-coverage-WPM",
"copy-coverage-files-WPM": "cp snapshots/config/coverage/whitePaperModel.json ./compound-protocol/networks/development.json",
"exec-coverage-WPM": "node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage --file 'test/whitePaperModel/**/*.ts' --network coverage",
"coverage-SFW": "FILE=coverage npm run clean-snapshot && FILE=coverage npm run unzip-snapshot && npm run copy-coverage-files-SFW && npm run exec-coverage-SFW",
"exec-coverage-WPM": "node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage --file 'test/whitePaperModel/**/*.ts' --network coverage",
"coverage": "FILE=coverage npm run clean-snapshot && FILE=coverage npm run unzip-snapshot && npm run exec-coverage",
"copy-coverage-files-SFW": "cp snapshots/config/coverage/scriptFlywheel.json ./compound-protocol/networks/development.json",
"exec-coverage-SFW": "yarn prepare && node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage --file 'test/scriptFlywheel/**/*.ts' --network coverage",
"exec-coverage": "yarn prepare && node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage --network coverage",
"coverage-setup": "node_modules/.bin/testrpc-sc -p 8546 --gasLimit 0x1fffffffffffff --gasPrice 1 --defaultBalanceEther 1000000000 --allowUnlimitedContractSize true",
"lint": "npx solium -d contracts/",
"ganache": "ganache-cli --gasLimit 0x1fffffffffffff --gasPrice 20000000 --defaultBalanceEther 1000000000 --allowUnlimitedContractSize true --mnemonic “begin vessel olive rocket pink distance admit foam lizard type fault enjoy”",
Expand Down
39 changes: 38 additions & 1 deletion test-helpers/TestEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,48 @@ export class TestEngine {
public bank!: t.BankInstance;
public accounts!: t.AccountsInstance;
public proxyAdmin!: t.ProxyAdminInstance;
public compoundTokens: any = require("../compound-protocol/networks/development.json");
public compoundTokens: any;

public erc20TokensFromCompound: Array<string> = new Array();
public cTokensCompound: Array<string> = new Array();

constructor(script: String) {
const currentPath = process.cwd();
const compound = `${currentPath}/compound-protocol`;

if (script == "scriptFlywheel.json") {
const modelPath = `${currentPath}/snapshots/config/coverage/${script}`;
const command = `cp ${modelPath} ${compound}/networks/development.json`;
const delModel = `rm -rf ${compound}/networks/development.json`;
shell.exec(delModel);
shell.exec(command);
this.compoundTokens = require("../compound-protocol/networks/development.json");
console.log("modelPath", modelPath);
console.log("DAI", this.compoundTokens.Contracts.DAI);
} else if (script == "whitePaperModel.json") {
const modelPath = `${currentPath}/snapshots/config/coverage/${script}`;
const command = `cp ${modelPath} ${compound}/networks/${script}`;
const delModel = `rm -rf ${compound}/networks/${script}`;
shell.exec(delModel);
shell.exec(command);
this.compoundTokens = require("../compound-protocol/networks/whitePaperModel.json");
console.log("modelPath", modelPath);
console.log("DAI", this.compoundTokens.Contracts.DAI);
}
}

public async setModel(script: String) {
const currentPath = process.cwd();
const compound = `${currentPath}/compound-protocol`;
const modelPath = `${currentPath}/snapshots/config/coverage/${script}`;
const command = `cp ${modelPath} ${compound}/networks/development.json`;
const delModel = `rm -rf ${compound}/networks/development.json`;
shell.exec(delModel);
shell.exec(command);
this.compoundTokens = require("../compound-protocol/networks/development.json");
console.log("modelPath", modelPath);
}

public async deploy(script: String) {
let jsonFileExists = true;

Expand Down
4 changes: 2 additions & 2 deletions test/scriptFlywheel/integration/IntegrationTest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ contract("Integration Tests", async (accounts) => {
before(function () {
this.timeout(0);
// Things to initialize before all test
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

beforeEach(async () => {
// Things to initialize before all test
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");

savingAccount = await testEngine.deploySavingAccount();
Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/TestCOMPToken.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract("SavingAccount.COMP", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/TestGlobalConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract("GlobalConfig", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/TestPausable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract("InitializablePausable", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/TestSavingsAccount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract("SavingAccount", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/additionalBorrowTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ contract("SavingAccount.borrow", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
2 changes: 1 addition & 1 deletion test/scriptFlywheel/unit/additionalDepositTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract("SavingAccount.deposit", async (accounts) => {
before(function () {
// Things to initialize before all test
this.timeout(0);
testEngine = new TestEngine();
testEngine = new TestEngine("scriptFlywheel.json");
// testEngine.deploy("scriptFlywheel.scen");
});

Expand Down
Loading