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

Tests for Origins sale #28

Open
wants to merge 6 commits into
base: origins-sale
Choose a base branch
from
Open
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
81 changes: 81 additions & 0 deletions tests/OriginsBase/creator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let {
secondSaleEndDurationOrTS,
secondTransferType,
secondSaleType,
saleEndDurationOrTSUntilSupply,
} = require("../variable");

contract("OriginsBase (Creator Functions)", (accounts) => {
Expand Down Expand Up @@ -223,4 +224,84 @@ contract("OriginsBase (Creator Functions)", (accounts) => {
"OriginsAdmin: Only verifier can call this function."
);
});

it("Creator should not be able to close sale of tier whose saleEnd is greater than block.timestamp", async () => {
await token.mint(owner, firstRemainingTokens, { from: creator });
await token.approve(originsBase.address, firstRemainingTokens, { from: owner });
await originsBase.createTier(
firstMinAmount,
firstMaxAmount,
firstRemainingTokens,
firstSaleStartTS,
firstSaleEnd,
firstUnlockedBP,
firstVestOrLockCliff,
firstVestOfLockDuration,
firstVerificationType,
firstSaleEndDurationOrTS,
firstTransferType,
firstSaleType,
{ from: owner }
);
tierCount = await originsBase.getTierCount();
await originsBase.setTierDeposit(tierCount, firstDepositRate, zeroAddress, firstDepositType, { from: owner });

await expectRevert(
originsBase.closeSaleOf(tierCount, {
from: creator,
}),
"OriginsBase: Cannot close this tier right now."
);
});

it("Creator should not be able to close sale of tier whose saleEndDurationOrTS is SaleEndDurationOrTS.UntilSupply", async () => {
await token.mint(owner, firstRemainingTokens, { from: creator });
await token.approve(originsBase.address, firstRemainingTokens, { from: owner });
await originsBase.createTier(
firstMinAmount,
firstMaxAmount,
firstRemainingTokens,
firstSaleStartTS,
firstSaleStartTS,
firstUnlockedBP,
firstVestOrLockCliff,
firstVestOfLockDuration,
firstVerificationType,
saleEndDurationOrTSUntilSupply,
firstTransferType,
firstSaleType,
{ from: owner }
);
tierCount = await originsBase.getTierCount();
await originsBase.setTierDeposit(tierCount, firstDepositRate, zeroAddress, firstDepositType, { from: owner });
await originsBase.addressVerification(creator, tierCount, { from: verifier });
await originsBase.buy(tierCount, zero, { from: creator, value: firstRemainingTokens / 2 });

await expectRevert(
originsBase.closeSaleOf(tierCount, {
from: creator,
}),
"OriginsBase: Cannot close this tier right now."
);
});

it("Creator should not be able to claim tier during the sale", async () => {
// TODO
});

it("Creator should not be able to claim unless the sale ended", async () => {
// TODO
});

it("Creator should not be able to claim unless the sale type is Pooled", async () => {
// TODO
});

it("Claim should be rejected if no tokens were bought for the tier for the specified user", async () => {
// TODO
});

it("Creator can not double claim", async () => {
// TODO
});
});
25 changes: 25 additions & 0 deletions tests/OriginsBase/owner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,4 +488,29 @@ contract("OriginsBase (Owner Functions)", (accounts) => {
await time.increase(firstSaleEnd + 100);
await originsBase.withdrawSaleDeposit({ from: owner });
});

it("Owner should be able to close sale of any tier.", async () => {
tierCount = await originsBase.getTierCount();
await originsBase.closeSaleOf(tierCount, { from: owner });
});

it("Owner should not be able to claim tier during the sale", async () => {
// TODO
});

it("Owner should not be able to claim unless the sale ended", async () => {
// TODO
});

it("Owner should not be able to claim unless the sale type is Pooled", async () => {
// TODO
});

it("Claim should be rejected if no tokens were bought for the tier for the specified user", async () => {
// TODO
});

it("Owner can not double claim", async () => {
// TODO
});
});
50 changes: 49 additions & 1 deletion tests/OriginsBase/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,54 @@ contract("OriginsBase (User Functions)", (accounts) => {
});

it("User should be able to check Sale Ended.", async () => {
let saleEnded = await originsBase.checkSaleEnded(1, { from: userOne });
let saleEnded = await originsBase.checkSaleEnded(tierCount, { from: userOne });
});

it("User should be able to check if a user is verified for a particular tier", async () => {
// TODO // let verified = await originsBase.checkVerification(tierCount, userTwo, { from: userOne });
});

it("User should be able to check if he/she is verified for a particular tier", async () => {
// TODO // let verified = await originsBase.checkVerification(tierCount, zeroAddress, { from: userOne });
});

it("User should be able to check if a user has staked for a particular tier", async () => {
// TODO // let staked = await originsBase.checkStakesByTier(tierCount, userTwo, { from: userOne });
});

it("User should be able to check if he/she has staked for a particular tier", async () => {
// TODO // let staked = await originsBase.checkStakesByTier(1, zeroAddress, { from: userOne });
});

it("User should not be able to close sale of tier whose saleEnd is greater than block.timestamp", async () => {
// TODO
});

it("User should not be able to close sale of tier whose saleEndDurationOrTS is SaleEndDurationOrTS.UntilSupply", async () => {
// TODO
});

it("User should not be able to claim tier during the sale", async () => {
// TODO
});

it("User should not be able to claim unless the sale ended", async () => {
// TODO
});

it("User should not be able to claim unless the sale type is Pooled", async () => {
// TODO
});

it("Claim should be rejected if no tokens were bought for the tier for the specified user", async () => {
// TODO
});

it("User can not double claim", async () => {
// TODO
});

it("Claimed amount should be reflected on the balance", async () => {
// TODO
});
});
16 changes: 16 additions & 0 deletions tests/OriginsBase/verifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,20 @@ contract("OriginsBase (Verifier Functions)", (accounts) => {
"OriginsBase: Address and Tier Array length mismatch."
);
});

it("Verifier should be able to check if a user is verified for a particular tier", async () => {
// TODO // let verified = await originsBase.checkVerification(tierCount, userTwo, { from: userOne });
});

it("Verifier should be able to check if he/she is verified for a particular tier", async () => {
// TODO // let verified = await originsBase.checkVerification(tierCount, 0, { from: userOne });
});

it("Verifier should be able to check if a user has staked for a particular tier", async () => {
// TODO // let staked = await originsBase.checkStakesByTier(tierCount, userTwo, { from: userOne });
});

it("Verifier should be able to check if he/she has staked for a particular tier", async () => {
// TODO // let staked = await originsBase.checkStakesByTier(tierCount, 0, { from: userOne });
});
});
3 changes: 3 additions & 0 deletions tests/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
verificationTypeByAddress,
verificationTypeByStake,
saleEndDurationOrTSDuration,
saleEndDurationOrTSUntilSupply,
transferTypeVested,
transferTypeWaitedUnlock,
depositTypeToken,
Expand Down Expand Up @@ -183,4 +184,6 @@ module.exports = {
thirdMaxStake,
thirdBlockNumber,
thirdDate,

saleEndDurationOrTSUntilSupply,
};
Loading