update tests
This commit is contained in:
parent
9d71b29f0f
commit
01d4e66c74
@ -181,14 +181,32 @@ contract('Contribution app', (accounts) => {
|
|||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
assert.equal(mintTokenPermission, true);
|
assert.equal(mintTokenPermission, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Add contribution", async () => {
|
describe("Add contribution", async () => {
|
||||||
let amount = 100;
|
// contributor detials
|
||||||
let contributorId = 1;
|
let account, contributorHashDigest, contributorHashFunction, contributorHashSize;
|
||||||
let hashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
// contribution details
|
||||||
let hashFunction = 1;
|
let amount, contributorId, hashDigest, hashFunction, hashSize;
|
||||||
let hashSize = 1;
|
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
before(async () => {
|
||||||
|
// Add contributor from Contributor app
|
||||||
|
account = root;
|
||||||
|
contributorHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
||||||
|
contributorHashFunction = 0;
|
||||||
|
contributorHashSize = 0;
|
||||||
|
await contributor.addContributor(account, contributorHashDigest, contributorHashFunction, contributorHashSize);
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
assert.equal(await contributor.addressExists(account), true);
|
||||||
|
|
||||||
|
amount = 100;
|
||||||
|
contributorId = await contributor.getContributorIdByAddress(root);
|
||||||
|
hashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
||||||
|
hashFunction = 1;
|
||||||
|
hashSize = 1;
|
||||||
|
});
|
||||||
|
|
||||||
it("should revert when add contribution from address that does not have permission", async () => {
|
it("should revert when add contribution from address that does not have permission", async () => {
|
||||||
return assertRevert(async () => {
|
return assertRevert(async () => {
|
||||||
@ -212,7 +230,7 @@ contract('Contribution app', (accounts) => {
|
|||||||
assert.equal(contributionCountAfter.toNumber()-contributionCountBefore.toNumber(), 1, "contributions counter incremented");
|
assert.equal(contributionCountAfter.toNumber()-contributionCountBefore.toNumber(), 1, "contributions counter incremented");
|
||||||
let contributionObject = await contribution.getContribution(contributionCountAfter.toNumber());
|
let contributionObject = await contribution.getContribution(contributionCountAfter.toNumber());
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
assert.equal(contributionObject[1], contributorId, "contribution added belong to contributor id");
|
assert.equal(contributionObject[1].toNumber(), contributorId.toNumber(), "contribution added belong to contributor id");
|
||||||
let isExist = await contribution.exists(contributionCountAfter.toNumber());
|
let isExist = await contribution.exists(contributionCountAfter.toNumber());
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
assert.equal(isExist, true, "contribution exist");
|
assert.equal(isExist, true, "contribution exist");
|
||||||
@ -258,15 +276,6 @@ contract('Contribution app', (accounts) => {
|
|||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
before(async () =>{
|
before(async () =>{
|
||||||
//add contributor
|
|
||||||
let account = root;
|
|
||||||
let contributorHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
||||||
let contributorHashFunction = 0;
|
|
||||||
let contributorHashSize = 0;
|
|
||||||
await contributor.addContributor(account, contributorHashDigest, contributorHashFunction, contributorHashSize);
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
assert.equal(await contributor.addressExists(account), true);
|
|
||||||
|
|
||||||
//add contribution
|
//add contribution
|
||||||
let amount = 200;
|
let amount = 200;
|
||||||
let contributorId = await contributor.getContributorIdByAddress(root);
|
let contributorId = await contributor.getContributorIdByAddress(root);
|
||||||
@ -294,14 +303,20 @@ contract('Contribution app', (accounts) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("claim contribution", async () => {
|
it("claim contribution", async () => {
|
||||||
|
let contributionObject = await contribution.getContribution(contributionId.toNumber());
|
||||||
|
let confirmationBlock = contributionObject[7];
|
||||||
|
let chainBlockNumberBefore = await getBlockNumber();
|
||||||
|
|
||||||
if(contributionId > 10) {
|
if(contributionId > 10) {
|
||||||
await timeTravel(blocksToWait);
|
await timeTravel(blocksToWait);
|
||||||
await mineBlock();
|
await mineBlock();
|
||||||
|
let chainBlockNumberAfter = await getBlockNumber();
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
assert.equal(chainBlockNumberAfter.toNumber()-chainBlockNumberBefore.toNumber(), confirmationBlock.toNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Claim contribution
|
//Claim contribution
|
||||||
await contribution.claim(contributionId);
|
await contribution.claim(contributionId, {from: root});
|
||||||
let contributionObject = await contribution.getContribution(contributionId.toNumber());
|
contributionObject = await contribution.getContribution(contributionId.toNumber());
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
assert(contributionObject[3], true);
|
assert(contributionObject[3], true);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user