I have attached my merkleproof code. I just found this code in openzeppelin repository.
I don't know what is the mistake I did in the code. But still, I get the wrong one. If anyone gives me some tips for that. It would be great for me. or else share any medium and sample files here.
require('@openzeppelin/test-helpers');
const { MerkleTree } = require('merkletreejs');
const keccak256 = require('keccak256');
const { expect } = require('chai');
const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
contract('MerkleProof', function (accounts) {
beforeEach(async function () {
this.merkleProof = await MerkleProofWrapper.new();
});
describe('verify', function () {
it('returns false for an invalid Merkle proof', async function () {
const correctElements = ['a', 'b', 'c'];
const correctMerkleTree = new MerkleTree(correctElements, keccak256, { hashLeaves: true, sortPairs: true });
const correctRoot = correctMerkleTree.getHexRoot();
const correctLeaf = keccak256(correctElements[0]);
const crtProof = correctMerkleTree.getHexProof(correctElements[2]);
console.log("Return check", await this.merkleProof.verify(crtProof, correctRoot, correctLeaf));
expect(await this.merkleProof.verify(crtProof, correctRoot, correctLeaf)).to.equal(true);
});
});
});