mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 23:13:09 +00:00
Fix formatting
This commit is contained in:
parent
d8decd497c
commit
197d9b82fa
@ -33,9 +33,6 @@ initLock(testLock)
|
||||
|
||||
suite "Onchain group manager":
|
||||
setup:
|
||||
# Acquire lock to ensure tests run sequentially
|
||||
acquire(testLock)
|
||||
|
||||
let runAnvil {.used.} = runAnvil()
|
||||
|
||||
var manager {.threadvar.}: OnchainGroupManager
|
||||
@ -85,14 +82,17 @@ suite "Onchain group manager":
|
||||
let accounts = waitFor web3.provider.eth_accounts()
|
||||
web3.defaultAccount = accounts[2]
|
||||
let (privateKey, acc) = createEthAccount(web3)
|
||||
let tokenAddress = (waitFor deployTestToken(privateKey, acc, web3)).valueOr:
|
||||
assert false, "Failed to deploy test token contract: " & $error
|
||||
return
|
||||
let differentContractAddress = (
|
||||
|
||||
let testTokenAddressRes = waitFor deployTestToken(privateKey, acc, web3)
|
||||
if testTokenAddressRes.isErr():
|
||||
error "Failed to deploy test token contract", error = testTokenAddressRes.error
|
||||
raise newException(CatchableError, "Failed to deploy test token contract")
|
||||
let TOKEN_ADDRESS = testTokenAddressRes.get()
|
||||
|
||||
let differentContractAddress =
|
||||
waitFor executeForgeContractDeployScripts(privateKey, acc, web3)
|
||||
).valueOr:
|
||||
assert false, "Failed to deploy RLN contract: " & $error
|
||||
return
|
||||
if differentContractAddress.isErr():
|
||||
error "Failed to deploy RLN contract", error = differentContractAddress.error
|
||||
# simulating a change in the contractAddress
|
||||
let manager2 = OnchainGroupManager(
|
||||
ethClientUrls: @[EthClient],
|
||||
|
||||
@ -574,7 +574,7 @@ proc runAnvil*(port: int = 8540, chainId: string = "1234"): Process =
|
||||
"--balance",
|
||||
"1000000000",
|
||||
"--chain-id",
|
||||
$chainId,
|
||||
$chainId
|
||||
],
|
||||
options = {poUsePath},
|
||||
)
|
||||
@ -651,6 +651,11 @@ proc setupOnchainGroupManager*(
|
||||
discard await sendMintCall(
|
||||
web3, web3.defaultAccount, testTokenAddress, acc, ethToWei(1000.u256), some(0.u256)
|
||||
)
|
||||
let contractAddressRes =
|
||||
await executeForgeContractDeployScripts(privateKey, acc, web3)
|
||||
if contractAddressRes.isErr():
|
||||
error "Failed to deploy RLN contract", error = contractAddressRes.error
|
||||
raise newException(CatchableError, "Failed to deploy RLN contract")
|
||||
|
||||
let contractAddress = (await executeForgeContractDeployScripts(privateKey, acc, web3)).valueOr:
|
||||
assert false, "Failed to deploy RLN contract: " & $error
|
||||
|
||||
@ -30,11 +30,17 @@ logScope:
|
||||
# using the when predicate does not work within the contract macro, hence need to dupe
|
||||
contract(WakuRlnContract):
|
||||
# this serves as an entrypoint into the rln membership set
|
||||
proc register(idCommitment: UInt256, userMessageLimit: UInt32, idCommitmentsToErase: seq[UInt256])
|
||||
proc register(
|
||||
idCommitment: UInt256, userMessageLimit: UInt32, idCommitmentsToErase: seq[UInt256]
|
||||
)
|
||||
|
||||
# Initializes the implementation contract (only used in unit tests)
|
||||
proc initialize(maxMessageLimit: UInt256)
|
||||
# this event is raised when a new member is registered
|
||||
proc MembershipRegistered(idCommitment: UInt256, membershipRateLimit: UInt256, index: UInt32) {.event.}
|
||||
proc MembershipRegistered(
|
||||
idCommitment: UInt256, membershipRateLimit: UInt256, index: UInt32
|
||||
) {.event.}
|
||||
|
||||
# this function denotes existence of a given user
|
||||
proc isInMembershipSet(idCommitment: Uint256): bool {.view.}
|
||||
# this constant describes the next index of a new member
|
||||
@ -299,12 +305,14 @@ method register*(
|
||||
let idCommitment = identityCredential.idCommitment.toUInt256()
|
||||
let idCommitmentsToErase: seq[UInt256] = @[]
|
||||
debug "registering the member",
|
||||
idCommitment = idCommitment, userMessageLimit = userMessageLimit, idCommitmentsToErase = idCommitmentsToErase
|
||||
idCommitment = idCommitment,
|
||||
userMessageLimit = userMessageLimit,
|
||||
idCommitmentsToErase = idCommitmentsToErase
|
||||
var txHash: TxHash
|
||||
g.retryWrapper(txHash, "Failed to register the member"):
|
||||
await wakuRlnContract.register(idCommitment, userMessageLimit.stuint(32),idCommitmentsToErase).send(
|
||||
gasPrice = gasPrice
|
||||
)
|
||||
await wakuRlnContract
|
||||
.register(idCommitment, userMessageLimit.stuint(32), idCommitmentsToErase)
|
||||
.send(gasPrice = gasPrice)
|
||||
|
||||
# wait for the transaction to be mined
|
||||
var tsReceipt: ReceiptObject
|
||||
@ -327,7 +335,9 @@ method register*(
|
||||
debug "third topic", firstTopic = firstTopic
|
||||
# the hash of the signature of MembershipRegistered(uint256,uint256,uint32) event is equal to the following hex value
|
||||
if firstTopic !=
|
||||
cast[FixedBytes[32]](keccak.keccak256.digest("MembershipRegistered(uint256,uint256,uint32)").data):
|
||||
cast[FixedBytes[32]](keccak.keccak256.digest(
|
||||
"MembershipRegistered(uint256,uint256,uint32)"
|
||||
).data):
|
||||
raise newException(ValueError, "register: unexpected event signature")
|
||||
|
||||
# the arguments of the raised event i.e., MembershipRegistered are encoded inside the data field
|
||||
@ -623,13 +633,10 @@ method init*(g: OnchainGroupManager): Future[GroupManagerResult[void]] {.async.}
|
||||
# now we check on the contract if the commitment actually has a membership
|
||||
let idCommitmentBytes = keystoreCred.identityCredential.idCommitment
|
||||
let idCommitmentUInt256 = keystoreCred.identityCredential.idCommitment.toUInt256()
|
||||
let idCommitmentHex = idCommitmentBytes.inHex()
|
||||
debug "Keystore idCommitment in bytes",
|
||||
idCommitmentBytes = idCommitmentBytes
|
||||
debug "Keystore idCommitment in UInt256 ",
|
||||
idCommitmentUInt256 = idCommitmentUInt256
|
||||
debug "Keystore idCommitment in hex ",
|
||||
idCommitmentHex = idCommitmentHex
|
||||
let idCommitmentHex = idCommitmentBytes.inHex()
|
||||
debug "Keystore idCommitment in bytes", idCommitmentBytes = idCommitmentBytes
|
||||
debug "Keystore idCommitment in UInt256 ", idCommitmentUInt256 = idCommitmentUInt256
|
||||
debug "Keystore idCommitment in hex ", idCommitmentHex = idCommitmentHex
|
||||
let idCommitment = idCommitmentUInt256
|
||||
try:
|
||||
# let membershipExists =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user