Skip to content

Commit

Permalink
fix: checking for keystore file existence (#2427)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer authored Feb 15, 2024
1 parent 22026b7 commit 8f487a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/waku_rln_relay/test_rln_group_manager_onchain.nim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ suite "Onchain group manager":
rlnInstance: manager.rlnInstance)
expect(ValueError): await manager2.init()

asyncTest "should error when keystore path and password are provided but file doesn't exist":
let manager = await setup()
manager.keystorePath = some("/inexistent/file")
manager.keystorePassword = some("password")

expect(CatchableError): await manager.init()

asyncTest "startGroupSync: should start group sync":
let manager = await setup()

Expand Down
5 changes: 5 additions & 0 deletions waku/waku_rln_relay/group_manager/on_chain/group_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ else:
{.push raises: [].}

import
os,
web3,
web3/ethtypes,
eth/keys as keys,
Expand Down Expand Up @@ -630,6 +631,10 @@ method init*(g: OnchainGroupManager): Future[void] {.async.} =
g.registryContract = some(registryContract)

if g.keystorePath.isSome() and g.keystorePassword.isSome():
if not existsFile(g.keystorePath.get()):
error "File provided as keystore path does not exist", path=g.keystorePath.get()
raise newException(CatchableError, "missing keystore")

var keystoreQuery = KeystoreMembership(
membershipContract: MembershipContract(
chainId: $g.chainId.get(),
Expand Down

0 comments on commit 8f487a2

Please sign in to comment.