Skip to content

Commit

Permalink
Add indexing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pzixel committed Oct 13, 2021
1 parent ae61beb commit f19117b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/MerkleDrop128.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract('MerkleDrop128', async function ([addr1, w1, w2, w3, w4]) {
await Promise.all(wallets.map(w => this.token.mint(w, 1)));
});

describe('Main', async function () {
describe.only('Main', async function () {
beforeEach(async function () {
const accountWithDropValues = [
{
Expand All @@ -51,6 +51,18 @@ contract('MerkleDrop128', async function ([addr1, w1, w2, w3, w4]) {
account: w1,
amount: 1,
},
{
account: w2,
amount: 1,
},
{
account: w3,
amount: 1,
},
{
account: w4,
amount: 1,
},
];
const { hashedElements, leaves, root, proofs, drop } = await makeDrop(this.token, accountWithDropValues, 1000000);
this.hashedElements = hashedElements;
Expand All @@ -61,6 +73,14 @@ contract('MerkleDrop128', async function ([addr1, w1, w2, w3, w4]) {
this.account = Wallet.fromPrivateKey(Buffer.from('ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', 'hex'));
});

it('Should enumerate items properly', async function () {
for (let i = 0; i < this.proofs.length; i++) {
const result = await this.drop.verify(this.proofs[findSortedIndex(this, i)], this.root, this.leaves[findSortedIndex(this, i)]);
expect(result.valid).to.be.true;
expect(result.index).to.be.bignumber.equal(toBN(findSortedIndex(this, i)));
}
});

it('Should transfer money to another wallet', async function () {
const data = MerkleTree.bufferToHex(keccak256(w1));
const signature = ethSigUtil.personalSign(this.account.getPrivateKey(), { data });
Expand Down

0 comments on commit f19117b

Please sign in to comment.