mirror of
https://github.com/logos-messaging/waku-rlnv1-contract.git
synced 2026-01-04 07:13:12 +00:00
fix: move noDuplicate into utils
This commit is contained in:
parent
6da7bd0038
commit
ace937c3ad
@ -2,22 +2,11 @@
|
||||
pragma solidity ^0.8.15;
|
||||
|
||||
import {PoseidonHasher} from "rln-contract/PoseidonHasher.sol";
|
||||
import "./utils.sol";
|
||||
import "../contracts/WakuRLn.sol";
|
||||
import "forge-std/Test.sol";
|
||||
import "forge-std/StdCheats.sol";
|
||||
|
||||
function noDuplicate(uint256[] calldata ids) pure returns (bool) {
|
||||
uint256 len = ids.length;
|
||||
for (uint256 i = 0; i < len; i++) {
|
||||
for (uint256 j = i + 1; j < len; j++) {
|
||||
if (ids[i] == ids[j]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
contract WakuRlnTest is Test {
|
||||
using stdStorage for StdStorage;
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.15;
|
||||
|
||||
import {PoseidonHasher} from "rln-contract/PoseidonHasher.sol";
|
||||
import "../contracts/WakuRlnRegistry.sol";
|
||||
import {noDuplicate} from "./WakuRln.t.sol";
|
||||
import {PoseidonHasher} from "rln-contract/PoseidonHasher.sol";
|
||||
import {DuplicateIdCommitment} from "rln-contract/RlnBase.sol";
|
||||
import {noDuplicate} from "./utils.sol";
|
||||
import "forge-std/Test.sol";
|
||||
import "forge-std/StdCheats.sol";
|
||||
|
||||
|
||||
14
test/utils.sol
Normal file
14
test/utils.sol
Normal file
@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.15;
|
||||
|
||||
function noDuplicate(uint256[] calldata ids) pure returns (bool) {
|
||||
uint256 len = ids.length;
|
||||
for (uint256 i = 0; i < len; i++) {
|
||||
for (uint256 j = i + 1; j < len; j++) {
|
||||
if (ids[i] == ids[j]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user