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

Refactor/reviewing contract code and comments #234

Merged
merged 12 commits into from Aug 26, 2019

Removing tests.

  • Loading branch information
Freydal committed Aug 22, 2019
commit 1957c317b61bc6e7957c81dd9919aa51231a2c6e
@@ -346,134 +346,6 @@ describe("Treasury", async () => {
});
});

describe("updateBalance", () => {
it("should make required changes for balance to end at desired value.", async () => {
await kosuToken.approve.awaitTransactionSuccessAsync(treasury.address, new BigNumber("100000"), {
from: accounts[3],
});
await treasury.contractDeposit.awaitTransactionSuccessAsync(accounts[3], TestValues.oneHundredWei, {
from: accounts[5],
});

await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq(TestValues.oneHundredWei.toString());

await treasury.updateBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("73"), {
from: accounts[5],
});

await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("73");

await treasury.updateBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("80"), {
from: accounts[5],
});

await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("80");

await kosuToken.balanceOf
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("20");
});

it("should fail on insufficient token approval.", async () => {
await treasury.updateBalance.awaitTransactionSuccessAsync(accounts[1], new BigNumber("51"), {
from: accounts[5],
}).should.eventually.be.rejected;
});

it("should fail on insufficient token balance.", async () => {
await kosuToken.approve.awaitTransactionSuccessAsync(treasury.address, new BigNumber("100000"), {
from: accounts[1],
});

await treasury.updateBalance.awaitTransactionSuccessAsync(accounts[1], new BigNumber("101"), {
from: accounts[5],
}).should.eventually.be.rejected;
});
});

describe("adjustBalance", () => {
it("should change the balance by the provided value", async () => {
await kosuToken.approve.awaitTransactionSuccessAsync(treasury.address, new BigNumber("100000"), {
from: accounts[3],
});
await treasury.contractDeposit.awaitTransactionSuccessAsync(accounts[3], TestValues.oneHundredWei, {
from: accounts[5],
});
await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq(TestValues.oneHundredWei.toString());

// should handle negative change
await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("-27"), {
from: accounts[5],
});
await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("73");

// should handle 0
await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("0"), {
from: accounts[5],
});
await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("73");

// should handle positive change
await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("7"), {
from: accounts[5],
});
await treasury.currentBalance
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("80");

await kosuToken.balanceOf
.callAsync(accounts[3])
.then(x => x.toString())
.should.eventually.eq("20");
});

it("should fail on over withdraw.", async () => {
await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("-101"), {
from: accounts[5],
}).should.eventually.be.rejected;
});

it("should fail on insufficient token approval.", async () => {
await kosuToken.approve.awaitTransactionSuccessAsync(treasury.address, new BigNumber("0"), {
from: accounts[3],
});

await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("1"), {
from: accounts[5],
}).should.eventually.be.rejected;
});

it("should fail on insufficient token balance.", async () => {
await kosuToken.approve.awaitTransactionSuccessAsync(treasury.address, new BigNumber("100000"), {
from: accounts[3],
});

await treasury.adjustBalance.awaitTransactionSuccessAsync(accounts[3], new BigNumber("101"), {
from: accounts[5],
}).should.eventually.be.rejected;
});
});

describe("confiscate", () => {
let expectedValue;
let from;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.