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

margin_loan #229

Merged
merged 5 commits into from
May 22, 2019
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
17 changes: 17 additions & 0 deletions test/loanCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ let rates = null;
const ltdParams = { lockDifferenceLimit: 300000, loanDifferenceLimit: 200000, allowedDifferenceAmount: 100000 };
let products = {};

let snapshotIdSingleTest;
let snapshotIdAllTests;

contract("Loans collection tests", accounts => {
before(async function() {
snapshotIdAllTests = await testHelpers.takeSnapshot();

rates = ratesTestHelpers.rates;
monetarySupervisor = tokenTestHelpers.monetarySupervisor;
loanManager = loanTestHelpers.loanManager;
Expand Down Expand Up @@ -48,6 +53,18 @@ contract("Loans collection tests", accounts => {
] = newProducts;
});

after(async () => {
await testHelpers.revertSnapshot(snapshotIdAllTests);
});

beforeEach(async function() {
snapshotIdSingleTest = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotIdSingleTest);
});

it("Should collect a defaulted A-EUR loan and send back leftover collateral ", async function() {
const loan = await loanTestHelpers.createLoan(
this,
Expand Down
17 changes: 17 additions & 0 deletions test/loanManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ let loanProduct = null;

let CHUNK_SIZE = 20;

let snapshotIdSingleTest;
let snapshotIdAllTests;

contract("loanManager tests", accounts => {
before(async function() {
snapshotIdAllTests = await testHelpers.takeSnapshot();

loanManager = loanTestHelpers.loanManager;

loanProduct = {
Expand Down Expand Up @@ -37,6 +42,18 @@ contract("loanManager tests", accounts => {
loanProduct.id = res.productId;
});

after(async () => {
await testHelpers.revertSnapshot(snapshotIdAllTests);
});

beforeEach(async function() {
snapshotIdSingleTest = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotIdSingleTest);
});

it("Verifies default test loanproduct discount rates", async function() {
// correlates with loan products set up in localTest_initialSetup.sol

Expand Down
19 changes: 14 additions & 5 deletions test/loanToDepositRatioLimits.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ let loanManager;
let locker;
let loanProductId;
let lockProductId;
let snapshotId;
let rate;

let snapshotIdSingleTest;
let snapshotIdAllTests;

const ltdParams = { lockDifferenceLimit: 300000, loanDifferenceLimit: 200000, allowedDifferenceAmount: 100000 };

const lockPerTermInterest = 8330;
Expand All @@ -34,6 +36,8 @@ const getLtdLimits = async () => {

contract("Loan to Deposit ratio tests", accounts => {
before(async () => {
snapshotIdAllTests = await testHelpers.takeSnapshot();

augmintToken = tokenTestHelpers.augmintToken;
loanManager = loanTestHelpers.loanManager;
locker = Locker.at(Locker.address);
Expand Down Expand Up @@ -94,11 +98,16 @@ contract("Loan to Deposit ratio tests", accounts => {
]);
});

after(async () => {
await testHelpers.revertSnapshot(snapshotIdAllTests);
});

beforeEach(async function() {
if (snapshotId) {
await testHelpers.revertSnapshot(snapshotId);
}
snapshotId = await testHelpers.takeSnapshot();
snapshotIdSingleTest = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotIdSingleTest);
});

it("LTD when both totalLock and totalLoan 0", async function() {
Expand Down
17 changes: 17 additions & 0 deletions test/loans.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ const ltdParams = { lockDifferenceLimit: 300000, loanDifferenceLimit: 200000, al
let products = {};
let CHUNK_SIZE = 10;

let snapshotIdSingleTest;
let snapshotIdAllTests;

contract("Loans tests", accounts => {
before(async function() {
snapshotIdAllTests = await testHelpers.takeSnapshot();

rates = ratesTestHelpers.rates;
monetarySupervisor = tokenTestHelpers.monetarySupervisor;
augmintToken = tokenTestHelpers.augmintToken;
Expand Down Expand Up @@ -58,6 +63,18 @@ contract("Loans tests", accounts => {
] = newProducts;
});

after(async () => {
await testHelpers.revertSnapshot(snapshotIdAllTests);
});

beforeEach(async function() {
snapshotIdSingleTest = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotIdSingleTest);
});

it("Should get an A-EUR loan", async function() {
await loanTestHelpers.createLoan(this, products.repaying, accounts[0], global.web3v1.utils.toWei("0.5"));
});
Expand Down
9 changes: 9 additions & 0 deletions test/rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ const ratesTestHelpers = require("./helpers/ratesTestHelpers");
const testHelpers = require("./helpers/testHelpers.js");

let rates = null;
let snapshotId;

contract("Rates tests", accounts => {
before(async function() {
rates = ratesTestHelpers.rates;
});

beforeEach(async function() {
snapshotId = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotId);
});

it("should be possible to set 1 rate", async function() {
const symbol = "EUR";

Expand Down
9 changes: 9 additions & 0 deletions test/tokenTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const tokenTestHelpers = new require("./helpers/tokenTestHelpers.js");

let augmintToken = null;
let minFee, maxFee, feePt, minFeeAmount, maxFeeAmount;
let snapshotId;

contract("Transfer Augmint tokens tests", accounts => {
before(async function() {
Expand All @@ -16,6 +17,14 @@ contract("Transfer Augmint tokens tests", accounts => {
maxFeeAmount = maxFee.div(feePt).mul(1000000);
});

beforeEach(async function() {
snapshotId = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotId);
});

it("Should be able to transfer tokens between accounts (without narrative, min fee)", async function() {
await tokenTestHelpers.transferTest(this, {
from: accounts[1],
Expand Down
9 changes: 9 additions & 0 deletions test/tokenTransferFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const testHelpers = new require("./helpers/testHelpers.js");

let augmintToken = null;
let maxFee = null;
let snapshotId;

contract("TransferFrom AugmintToken tests", accounts => {
before(async function() {
Expand All @@ -15,6 +16,14 @@ contract("TransferFrom AugmintToken tests", accounts => {
]);
});

beforeEach(async function() {
snapshotId = await testHelpers.takeSnapshot();
});

afterEach(async function() {
await testHelpers.revertSnapshot(snapshotId);
});

it("transferFrom", async function() {
const from = accounts[1];
const to = accounts[2];
Expand Down