mirror of
https://github.com/vacp2p/hello_rln_app.git
synced 2026-01-09 21:07:55 -05:00
add: hello_rln
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"solidity.compileUsingRemoteVersion": "v0.8.15+commit.e14f2714"
|
||||
}
|
||||
24
src/HelloRln.sol
Normal file
24
src/HelloRln.sol
Normal file
@@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.15;
|
||||
|
||||
import "rln-contract/RlnBase.sol";
|
||||
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
|
||||
|
||||
contract HelloRln is Ownable, RlnBase {
|
||||
bytes2 public constant start = 0xdead;
|
||||
uint256 private membershipDeposit = 0;
|
||||
uint256 private depth = 20;
|
||||
|
||||
constructor(address _poseidonHasher) Ownable() RlnBase(membershipDeposit, depth, _poseidonHasher, address(0)) {}
|
||||
|
||||
function _validateRegistration(uint256 idCommitment) internal pure override {
|
||||
if (bytes2(bytes32(idCommitment)) != start) revert FailedValidation();
|
||||
}
|
||||
|
||||
function _validateSlash(uint256 idCommitment, address payable receiver, uint256[8] calldata proof)
|
||||
internal
|
||||
view
|
||||
override
|
||||
onlyOwner
|
||||
{}
|
||||
}
|
||||
25
test/HelloRln.t.sol
Normal file
25
test/HelloRln.t.sol
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.13;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
import "../src/HelloRln.sol";
|
||||
import {FailedValidation} from "rln-contract/RlnBase.sol";
|
||||
|
||||
contract HelloRlnTest is Test {
|
||||
HelloRln public helloRln;
|
||||
|
||||
function setUp() public {
|
||||
helloRln = new HelloRln(address(0));
|
||||
}
|
||||
|
||||
function test__InvalidRegistration(uint256 idCommitment) public {
|
||||
vm.assume(bytes2(bytes32(idCommitment)) != helloRln.start());
|
||||
vm.expectRevert(FailedValidation.selector);
|
||||
helloRln.register(idCommitment);
|
||||
}
|
||||
|
||||
function test__ValidRegistration() public {
|
||||
bytes32 idCommitment = 0xdead000000000000000000000000000000000000000000000000000000000000;
|
||||
helloRln.register(uint256(idCommitment));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user