fix: fixed size return for proof

This commit is contained in:
rymnc 2024-05-28 18:35:12 +05:30
parent 3a89171cde
commit 57fca341b1
No known key found for this signature in database
GPG Key ID: AAA088D5C68ECD34
2 changed files with 8 additions and 3 deletions

View File

@ -177,7 +177,12 @@ contract WakuRlnV2 {
/// @notice Returns the merkle proof elements of a given membership
/// @param index The index of the member
/// @return The merkle proof elements of the member
function merkleProofElements(uint40 index) public view returns (uint256[] memory) {
return LazyIMT.merkleProofElements(imtData, index, DEPTH);
function merkleProofElements(uint40 index) public view returns (uint256[DEPTH] memory) {
uint256[DEPTH] memory castedProof;
uint256[] memory proof = LazyIMT.merkleProofElements(imtData, index, DEPTH);
for (uint8 i = 0; i < DEPTH; i++) {
castedProof[i] = proof[i];
}
return castedProof;
}
}

View File

@ -47,7 +47,7 @@ contract WakuRlnV2Test is Test {
assertEq(fetchedUserMessageLimit2, userMessageLimit);
assertEq(index2, 0);
assertEq(rateCommitment2, rateCommitment);
uint256[] memory proof = w.merkleProofElements(0);
uint256[20] memory proof = w.merkleProofElements(0);
uint256[20] memory expectedProof = [
0,
14_744_269_619_966_411_208_579_211_824_598_458_697_587_494_354_926_760_081_771_325_075_741_142_829_156,