mirror of
https://github.com/vacp2p/rln-interep-contract.git
synced 2026-01-09 13:48:01 -05:00
test: offending pk
This commit is contained in:
@@ -42,9 +42,16 @@ contract RLN {
|
||||
_register(pubkey);
|
||||
}
|
||||
|
||||
/// @dev Registers a member via a valid Interep Semaphore group.
|
||||
/// @param groupId: Id of the group.
|
||||
/// @param signal: Semaphore signal.
|
||||
/// @param nullifierHash: Nullifier hash.
|
||||
/// @param externalNullifier: External nullifier.
|
||||
/// @param proof: Zero-knowledge proof.
|
||||
/// @param pubkey: Public key of the member.
|
||||
function register(
|
||||
uint256 groupId,
|
||||
string calldata signal,
|
||||
bytes32 signal,
|
||||
uint256 nullifierHash,
|
||||
uint256 externalNullifier,
|
||||
uint256[8] calldata proof,
|
||||
@@ -55,7 +62,13 @@ contract RLN {
|
||||
"RLN, register: invalid interep group"
|
||||
);
|
||||
require(pubkeyIndex < SET_SIZE, "RLN, register: set is full");
|
||||
// TODO: verify proof
|
||||
interep.verifyProof(
|
||||
groupId,
|
||||
signal,
|
||||
nullifierHash,
|
||||
externalNullifier,
|
||||
proof
|
||||
);
|
||||
_register(pubkey);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "595225",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x61bcaf553e2b76f90c68125b05da3035f7d91d3bfeab900c886c6a917b97bc67",
|
||||
"blockHash": "0xb06925ee3a47c41b77084e9cf7c76eb60338418541b12ab1807eb683a1939300",
|
||||
"transactionHash": "0xae96071f4bf0c893a293894326d92c0e0a219aab41a2d659621a0f8e2e5266e3",
|
||||
"logs": [],
|
||||
"blockNumber": 2,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "3507975",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x5166b263d192dfee11d2a85568848c2b7fdfca5beb1969596cac98cc4ba841f7",
|
||||
"blockHash": "0x425c4ba6c7b01f161bf24a0d1090f01960751cfafd7feb11d27a454c8bca9b09",
|
||||
"transactionHash": "0x838be24bad8739b8f4355133ee0db0c6487dc1ad2f12bae12f0b82cdb82549c2",
|
||||
"logs": [],
|
||||
"blockNumber": 1,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -89,7 +89,7 @@
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "468004",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x09f229b5465acae09583dfa435afec343ed3a230c5b7be11849143c0d798fe02",
|
||||
"blockHash": "0x0f370dda61ad82e8758a8d1ed98c447bb25b8183be7a1d5118a0d2d1847886d5",
|
||||
"transactionHash": "0xecb0fec4068e603d6464d5cdeeeff90ad706e3ad96c005c45d6081b65f0fd756",
|
||||
"logs": [],
|
||||
"blockNumber": 4,
|
||||
|
||||
File diff suppressed because one or more lines are too long
40
test/rln.ts
40
test/rln.ts
@@ -1,4 +1,4 @@
|
||||
import { expect } from "chai";
|
||||
import { expect, assert } from "chai";
|
||||
import { ethers, deployments } from "hardhat";
|
||||
|
||||
describe("RLN", () => {
|
||||
@@ -66,4 +66,42 @@ describe("RLN", () => {
|
||||
"withdraw index doesn't match registered index"
|
||||
);
|
||||
});
|
||||
|
||||
it("should not allow multiple registrations with same pubkey", async () => {
|
||||
const rln = await ethers.getContract("RLN", ethers.provider.getSigner(0));
|
||||
|
||||
const price = await rln.MEMBERSHIP_DEPOSIT();
|
||||
|
||||
// A valid pair of (id_secret, id_commitment) generated in rust
|
||||
const idCommitment =
|
||||
"0x0c3ac305f6a4fe9bfeb3eba978bc876e2a99208b8b56c80160cfb54ba8f02368";
|
||||
|
||||
const registerTx = await rln["register(uint256)"](idCommitment, {
|
||||
value: price,
|
||||
});
|
||||
const txRegisterReceipt = await registerTx.wait();
|
||||
const index1 = txRegisterReceipt.events[0].args.index;
|
||||
|
||||
// Send the same tx again
|
||||
const registerTx2 = await rln["register(uint256)"](idCommitment, {
|
||||
value: price,
|
||||
});
|
||||
const txRegisterReceipt2 = await registerTx2.wait();
|
||||
const index2 = txRegisterReceipt2.events[0].args.index;
|
||||
|
||||
const pk1 = await rln.members(index1);
|
||||
const pk2 = await rln.members(index2);
|
||||
const samePk = pk1.toHexString() === pk2.toHexString();
|
||||
if(samePk) {
|
||||
assert(false, "same pubkey registered twice");
|
||||
}
|
||||
})
|
||||
|
||||
it("[interep] should register new memberships", () => {
|
||||
// TODO
|
||||
});
|
||||
|
||||
it("[interep] should withdraw membership", () => {
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user