mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-12 18:56:36 +00:00
* Move to version 2.0.6 * Update nim-confutils submodule to latest version * Update dependencies * Update Nim version to 2.0.12 * Add gcsafe pragma * Add missing import * Update specific conf for Nim 2.x * Fix method signatures * Revert erasure coding attempt to fix bug * More gcsafe pragma * Duplicate code from libp2p because it is not exported anymore * Fix camelcase function names * Use alreadySeen because need is not a bool anymore * newLPStreamReadError does not exist anymore so use another error * Replace ValidIpAddress by IpAddress * Add gcsafe pragma * Restore maintenance parameter deleted by mistake when removing esasure coding fix attempt code * Update method signatures * Copy LPStreamReadError code from libp2p which was removed * Fix camel case * Fix enums in tests * Fix camel case * Extract node components to a variable to make Nim 2 happy * Update the tests using ValidIpAddress to IpAddress * Fix cast for value which is already an option * Set nim version to 2.0.x for CI * Set nim version to 2.0.x for CI * Move to miniupnp version 2.2.4 to avoid symlink error * Set core.symlinks to false for Windows for miniupnp >= 2.2.5 support * Update to Nim 2.0.14 * Update CI nim versions to 2.0.14 * Try with GCC 14 * Replace apt-fast by apt-get * Update ubuntu runner to latest * Use Ubuntu 20.04 for coverage * Disable CI cache for coverage * Add coverage property description * Remove commented test * Check the node value of seen instead of using alreadySeen * Fix the merge. The taskpool work was reverted. * Update nim-ethers submodule * Remove deprecated ValidIpAddress. Fix missing case and imports. * Fix a weird issue where nim-confutils cannot find NatAny * Fix tests and remove useless static keyword
108 lines
3.1 KiB
Nim
108 lines
3.1 KiB
Nim
import os
|
|
import ../../asynctest
|
|
|
|
import pkg/chronos
|
|
import pkg/confutils/defs
|
|
import pkg/codex/conf
|
|
import pkg/codex/slots/proofs/backends
|
|
import pkg/codex/slots/proofs/backendfactory
|
|
import pkg/codex/slots/proofs/backendutils
|
|
import pkg/codex/utils/natutils
|
|
|
|
import ../helpers
|
|
import ../examples
|
|
|
|
type
|
|
BackendUtilsMock = ref object of BackendUtils
|
|
argR1csFile: string
|
|
argWasmFile: string
|
|
argZKeyFile: string
|
|
|
|
method initializeCircomBackend*(
|
|
self: BackendUtilsMock,
|
|
r1csFile: string,
|
|
wasmFile: string,
|
|
zKeyFile: string
|
|
): AnyBackend =
|
|
self.argR1csFile = r1csFile
|
|
self.argWasmFile = wasmFile
|
|
self.argZKeyFile = zKeyFile
|
|
# We return a backend with *something* that's not nil that we can check for.
|
|
var
|
|
key = VerifyingKey(icLen: 123)
|
|
vkpPtr: ptr VerifyingKey = key.addr
|
|
return CircomCompat(vkp: vkpPtr)
|
|
|
|
suite "Test BackendFactory":
|
|
let
|
|
utilsMock = BackendUtilsMock()
|
|
circuitDir = "testecircuitdir"
|
|
|
|
setup:
|
|
createDir(circuitDir)
|
|
|
|
teardown:
|
|
removeDir(circuitDir)
|
|
|
|
test "Should create backend from cli config":
|
|
let
|
|
config = CodexConf(
|
|
cmd: StartUpCmd.persistence,
|
|
nat: NatConfig(
|
|
hasExtIp: false,
|
|
nat: NatNone),
|
|
metricsAddress: parseIpAddress("127.0.0.1"),
|
|
persistenceCmd: PersistenceCmd.prover,
|
|
marketplaceAddress: EthAddress.example.some,
|
|
circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"),
|
|
circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"),
|
|
circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey")
|
|
)
|
|
backend = config.initializeBackend(utilsMock).tryGet
|
|
|
|
check:
|
|
backend.vkp != nil
|
|
utilsMock.argR1csFile == $config.circomR1cs
|
|
utilsMock.argWasmFile == $config.circomWasm
|
|
utilsMock.argZKeyFile == $config.circomZkey
|
|
|
|
test "Should create backend from local files":
|
|
let
|
|
config = CodexConf(
|
|
cmd: StartUpCmd.persistence,
|
|
nat: NatConfig(
|
|
hasExtIp: false,
|
|
nat: NatNone),
|
|
metricsAddress: parseIpAddress("127.0.0.1"),
|
|
persistenceCmd: PersistenceCmd.prover,
|
|
marketplaceAddress: EthAddress.example.some,
|
|
|
|
# Set the circuitDir such that the tests/circuits/fixtures/ files
|
|
# will be picked up as local files:
|
|
circuitDir: OutDir("tests/circuits/fixtures")
|
|
)
|
|
backend = config.initializeBackend(utilsMock).tryGet
|
|
|
|
check:
|
|
backend.vkp != nil
|
|
utilsMock.argR1csFile == config.circuitDir / "proof_main.r1cs"
|
|
utilsMock.argWasmFile == config.circuitDir / "proof_main.wasm"
|
|
utilsMock.argZKeyFile == config.circuitDir / "proof_main.zkey"
|
|
|
|
test "Should suggest usage of downloader tool when files not available":
|
|
let
|
|
config = CodexConf(
|
|
cmd: StartUpCmd.persistence,
|
|
nat: NatConfig(
|
|
hasExtIp: false,
|
|
nat: NatNone),
|
|
metricsAddress: parseIpAddress("127.0.0.1"),
|
|
persistenceCmd: PersistenceCmd.prover,
|
|
marketplaceAddress: EthAddress.example.some,
|
|
circuitDir: OutDir(circuitDir)
|
|
)
|
|
backendResult = config.initializeBackend(utilsMock)
|
|
|
|
check:
|
|
backendResult.isErr
|