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
4 changes: 2 additions & 2 deletions contracts/DecentralizedAutonomousTrust.sol
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ contract DecentralizedAutonomousTrust
buySlopeNum * totalSupply(), totalSupply(),
buySlopeDen
);
/// Math: this if condition avoids a potential overflow
// Math: this if condition avoids a potential overflow
if(exitFee <= reserve)
{
exitFee = 0;
Expand Down Expand Up @@ -938,7 +938,7 @@ contract DecentralizedAutonomousTrust
}
else
{
require(false, "INVALID_STATE");
revert("INVALID_STATE");
}

emit Close(exitFee);
Expand Down
3 changes: 2 additions & 1 deletion test/wiki/close/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ contract("wiki / close / close", accounts => {
contracts.dat.close({
from: await contracts.dat.beneficiary(),
value: "10000000000000000000000"
})
}),
"INVALID_STATE"
);
});
});
5 changes: 5 additions & 0 deletions test/wiki/close/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ contract("wiki / close / init", accounts => {
assert.equal(state.toString(), constants.STATE.INIT);
});

it("exitFee estimate is 0", async () => {
const fee = await contracts.dat.estimateExitFee(0);
assert.equal(fee, 0);
});

describe("on close", () => {
beforeEach(async () => {
await contracts.dat.close({
Expand Down
19 changes: 19 additions & 0 deletions test/wiki/close/run.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { tokens } = require("hardlydifficult-ethereum-contracts");

const sleep = require("sleep");
const BigNumber = require("bignumber.js");
const {
Expand Down Expand Up @@ -163,4 +165,21 @@ contract("wiki / close / run", accounts => {
);
});
});

describe("when reserve is high", () => {
beforeEach(async () => {
// Redeploy using an ERC-20
const token = await tokens.dai.deploy(web3, accounts[0]);
contracts = await deployDat(accounts, { currency: token.address });
await approveAll(contracts, accounts);
await token.mint(contracts.dat.address, constants.MAX_UINT, {
from: accounts[0]
});
});

it("exitFee is 0", async () => {
const exitFee = new BigNumber(await contracts.dat.estimateExitFee(0));
assert.equal(exitFee, 0);
});
});
});