Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pids
*.seed
*.pid.lock

# solidity-coverage directories and files
coverageEnv
allFiredEvents
scTopics
coverage.json

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand Down
10 changes: 10 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
compileCommand: "../node_modules/.bin/truffle compile",
testCommand: "../node_modules/.bin/truffle test --network coverage",
// skip interfaces until this resolved: https://github.com/sc-forks/solidity-coverage/issues/162
skipFiles: [
"interfaces/ERC20Interface.sol",
"interfaces/TokenReceiver.sol",
"generic/SignCheck.sol"
]
};
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ before_script:
script:
- yarn test
# discord webhooks hack until this is released: https://github.com/travis-ci/travis-tasks/pull/71
after_script: greenkeeper-lockfile-upload
after_script:
- greenkeeper-lockfile-upload
- yarn coverage && cat coverage/lcov.info | coveralls
after_success:
- wget https://raw.githubusercontent.com/k3rn31p4nic/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

# Augmint - Stable Digital Tokens - Solidity Contracts

[![Build Status](https://travis-ci.org/Augmint/augmint-contracts.svg?branch=staging)](https://travis-ci.org/Augmint/augmint-contracts) [![Greenkeeper badge](https://badges.greenkeeper.io/Augmint/augmint-contracts.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/Augmint/augmint-contracts.svg?branch=staging)](https://travis-ci.org/Augmint/augmint-contracts)
[![Coverage Status](https://coveralls.io/repos/github/Augmint/augmint-contracts/badge.svg?branch=staging)](https://coveralls.io/github/Augmint/augmint-contracts?branch=staging)
[![Greenkeeper badge](https://badges.greenkeeper.io/Augmint/augmint-contracts.svg)](https://greenkeeper.io/)

Decentralised stable cryptocurrency on Ethereum

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build": "$(yarn bin)/truffle compile",
"clean": "rm build/contracts/*",
"test": "$(yarn bin)/truffle test",
"coverage": "$(yarn bin)/solidity-coverage",
"migrate": "$(yarn bin)/truffle migrate",
"compile": "yarn build",
"ganache:run": "./runganache.sh",
Expand All @@ -18,9 +19,11 @@
"devDependencies": {
"babel-register": "6.26.0",
"bignumber.js": "5.0.0",
"coveralls": "3.0.0",
"ganache-cli": "6.1.0-beta.2",
"moment": "2.20.1",
"random-seed": "0.3.0",
"solidity-coverage": "0.4.10",
"stringifier": "1.3.0",
"truffle": "4.1.0"
},
Expand Down
33 changes: 30 additions & 3 deletions test/loanManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,35 @@ const testHelpers = require("./helpers/testHelpers.js");
const loanTestHelpers = require("./helpers/loanTestHelpers.js");

let loanManager = null;
let loanProduct = null;

contract("loanManager tests", accounts => {
before(async function() {
loanManager = loanTestHelpers.loanManager;

loanProduct = {
// assuming prod attributes are same order as array returned
minDisbursedAmount: 300000,
term: 86400,
discountRate: 970000,
collateralRatio: 850000,
defaultingFeePt: 50000,
isActive: true
};
await loanManager.addLoanProduct(
loanProduct.term,
loanProduct.discountRate,
loanProduct.collateralRatio,
loanProduct.minDisbursedAmount,
loanProduct.defaultingFeePt,
loanProduct.isActive,
{ from: accounts[0] }
);

const res = await testHelpers.assertEvent(loanManager, "LoanProductAdded", {
productId: x => x
});
loanProduct.id = res.productId;
});

it("Should add new product allow listing from offset 0", async function() {
Expand Down Expand Up @@ -100,7 +125,7 @@ contract("loanManager tests", accounts => {
});

it("Should disable loan product", async function() {
const tx = await loanManager.setLoanProductActiveState(0, false);
const tx = await loanManager.setLoanProductActiveState(loanProduct.id, false);
testHelpers.logGasUse(this, tx, "setLoanProductActiveState");
assert.equal(
tx.logs[0].event,
Expand All @@ -111,7 +136,7 @@ contract("loanManager tests", accounts => {
});

it("Should enable loan product", async function() {
const tx = await loanManager.setLoanProductActiveState(4, true);
const tx = await loanManager.setLoanProductActiveState(loanProduct.id, true);
testHelpers.logGasUse(this, tx, "setLoanProductActiveState");
assert.equal(
tx.logs[0].event,
Expand All @@ -122,6 +147,8 @@ contract("loanManager tests", accounts => {
});

it("Only allowed should set loan product state", async function() {
await testHelpers.expectThrow(loanManager.setLoanProductActiveState(0, true, { from: accounts[1] }));
await testHelpers.expectThrow(
loanManager.setLoanProductActiveState(loanProduct.id, true, { from: accounts[1] })
);
});
});
7 changes: 7 additions & 0 deletions truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ module.exports = {
gas: 4707806,
gasPrice: 1000000000 // 1 GWEI
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555, // <-- If you change this, also set the port option in .solcover.js.
gas: 0xfffffffffff, // <-- Use this high gas value
gasPrice: 0x01 // <-- Use this low gas price
},
truffleLocal: {
host: "localhost",
port: 9545,
Expand Down
Loading