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

contracts: fix 'r' bonding curve parameter to match specification #241

Merged
merged 15 commits into from Aug 28, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Adding token config validation.

  • Loading branch information
Freydal committed Aug 28, 2019
commit ec92e7d41a5aa5e72827f77b444c70d090a8618c
@@ -13,6 +13,7 @@ export const TestValues = {
sixEther: new BigNumber(toWei("6")),
tenEther: new BigNumber(toWei("10")),
oneHundredEther: new BigNumber(toWei("100")),
fourHundredEther: new BigNumber(toWei("400")),
fiveHundredEther: new BigNumber(toWei("500")),
maxUint: new BigNumber(2).pow(new BigNumber(256)).minus(new BigNumber(1)),
};
@@ -59,6 +59,7 @@ before(async () => {
const ganacheSubprovider = new GanacheSubprovider({
mnemonic: process.env.npm_package_config_test_mnemonic,
network_id: 6175,
default_balance_ether: TestValues.fiveHundredEther.multipliedBy(10),
});
provider.addProvider(ganacheSubprovider);
}
@@ -17,7 +17,12 @@ describe("KosuToken", () => {
kosuToken = contracts.kosuToken;
});

describe("bonding", () => {
describe("parameterization", () => {
it("should fail with incorrect initial deposit", async () => {
await web3Wrapper
.sendTransactionAsync({ to: token.address, value: TestValues.twoEther, from }).should.eventually.be.rejected;
});

it("should have expected initial output with parameterization", async () => {
await web3Wrapper
.sendTransactionAsync({ to: token.address, value: TestValues.twoEther.div("10"), from })
@@ -41,6 +46,26 @@ describe("KosuToken", () => {
.should.eq(endingEther.toString());
});

it("should have expected tokens balance at given ether balance", async () => {
await web3Wrapper
.sendTransactionAsync({ to: token.address, value: TestValues.fourHundredEther.minus(await web3Wrapper.getBalanceInWeiAsync(token.address)), from })
.then(txHash => web3Wrapper.awaitTransactionSuccessAsync(txHash));

const finalBalance = await token.balanceOf.callAsync(from);
const finalSupply = await token.totalSupply.callAsync();
const endingEther = await web3Wrapper.getBalanceInWeiAsync(token.address);

"90635575928012811022820"
.should.eq(finalBalance.toString());
"90635575928012811022820"
.should.eq(finalSupply.toString());
TestValues.fourHundredEther
.toString()
.should.eq(endingEther.toString());
});
});

describe("bonding", () => {

describe("fallback", () => {
it("should generate tokens with fallback function", async () => {
@@ -98,6 +123,14 @@ describe("KosuToken", () => {
.toString()
.should.eq(endingEther.toString());
});

// it("should fail with payout below minPayout", async () => {
// const estimate = await kosuToken.estimateEtherToToken.callAsync(TestValues.oneEther);
//
// const error = (await kosuToken.bondTokens.awaitTransactionSuccessAsync(estimate.plus(TestValues.oneEther), { value: TestValues.oneEther }).should.eventually.be.rejected)//.message.should.contains("payout below requested minimum");
// console.log(error.message);
// console.log(await web3Wrapper.getTransactionReceiptIfExistsAsync(error.message.split(":")[1].trim()));
// });
});

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