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

Refactoring to have non parameterization tests use the global token

  • Loading branch information
Freydal committed Aug 28, 2019
commit 3abd65963ec2ec967f2343d477c9dc473a5a4154
@@ -4,7 +4,7 @@ import { fromWei } from "web3-utils";
import { artifacts, KosuTokenContract } from "..";

describe("KosuToken", () => {
let token, from;
let token, from, kosuToken;

before(async () => {
token = await KosuTokenContract.deployFrom0xArtifactAsync(
@@ -14,6 +14,7 @@ describe("KosuToken", () => {
"0x0000000000000000000000000000000000000000",
);
from = accounts[0];
kosuToken = contracts.kosuToken;
});

describe("bonding", () => {
@@ -40,20 +41,21 @@ describe("KosuToken", () => {
.should.eq(endingEther.toString());
});


describe("fallback", () => {
it("should generate tokens with fallback function", async () => {
const startingBalance = await token.balanceOf.callAsync(from);
const startingSupply = await token.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(token.address);
const estimate = await token.estimateEtherToToken.callAsync(TestValues.oneEther);
const startingBalance = await kosuToken.balanceOf.callAsync(from);
const startingSupply = await kosuToken.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(kosuToken.address);
const estimate = await kosuToken.estimateEtherToToken.callAsync(TestValues.oneEther);

await web3Wrapper
.sendTransactionAsync({ to: token.address, value: TestValues.oneEther, from })
.sendTransactionAsync({ to: kosuToken.address, value: TestValues.oneEther, 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);
const finalBalance = await kosuToken.balanceOf.callAsync(from);
const finalSupply = await kosuToken.totalSupply.callAsync();
const endingEther = await web3Wrapper.getBalanceInWeiAsync(kosuToken.address);

startingBalance
.plus(estimate)
@@ -71,17 +73,17 @@ describe("KosuToken", () => {
});

describe("bondTokens", () => {
it("should generate tokens with fallback function", async () => {
const startingBalance = await token.balanceOf.callAsync(from);
const startingSupply = await token.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(token.address);
const estimate = await token.estimateEtherToToken.callAsync(TestValues.oneEther);
it("should generate tokens with bondTokens", async () => {
const startingBalance = await kosuToken.balanceOf.callAsync(from);
const startingSupply = await kosuToken.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(kosuToken.address);
const estimate = await kosuToken.estimateEtherToToken.callAsync(TestValues.oneEther);

await token.bondTokens.awaitTransactionSuccessAsync(TestValues.zero, { value: TestValues.oneEther });
await kosuToken.bondTokens.awaitTransactionSuccessAsync(TestValues.zero, { value: TestValues.oneEther });

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

startingBalance
.plus(estimate)
@@ -100,16 +102,16 @@ describe("KosuToken", () => {

describe("releaseTokens", () => {
it("should sell tokens on the curve", async () => {
const startingBalance = await token.balanceOf.callAsync(from);
const startingSupply = await token.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(token.address);
const estimate = await token.estimateTokenToEther.callAsync(TestValues.oneEther);
const startingBalance = await kosuToken.balanceOf.callAsync(from);
const startingSupply = await kosuToken.totalSupply.callAsync();
const startingEther = await web3Wrapper.getBalanceInWeiAsync(kosuToken.address);
const estimate = await kosuToken.estimateTokenToEther.callAsync(TestValues.oneEther);

await token.releaseTokens.awaitTransactionSuccessAsync(TestValues.oneEther);
await kosuToken.releaseTokens.awaitTransactionSuccessAsync(TestValues.oneEther);

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

startingBalance
.minus(TestValues.oneEther)
@@ -126,11 +128,11 @@ describe("KosuToken", () => {
});

it("should empty the contract", async () => {
await token.releaseTokens.awaitTransactionSuccessAsync(await token.balanceOf.callAsync(from));
await kosuToken.releaseTokens.awaitTransactionSuccessAsync(await kosuToken.balanceOf.callAsync(from));

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

"0".should.eq(finalBalance.toString());
"0".should.eq(finalSupply.toString());
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.