Restores tests

This commit is contained in:
benbierens 2024-08-23 11:08:49 +02:00
parent 4a94df3663
commit e1137a574c
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 22 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import pkg/codex/slots/proofs/backendfactory
import pkg/codex/slots/proofs/backendutils
import ../helpers
import ../examples
type
BackendUtilsMock = ref object of BackendUtils
@ -26,7 +27,7 @@ method initializeCircomBackend*(
self.argWasmFile = wasmFile
self.argZKeyFile = zKeyFile
# We return a backend with *something* that's not nil that we can check for.
var
var
key = VerifyingKey(icLen: 123)
vkpPtr: ptr VerifyingKey = key.addr
return CircomCompat(vkp: vkpPtr)
@ -50,11 +51,12 @@ suite "Test BackendFactory":
discoveryIp: ValidIpAddress.init(IPv4_any()),
metricsAddress: ValidIpAddress.init("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 = (await initializeBackend(config, utilsMock)).tryGet
backend = initializeBackend(config, utilsMock).tryGet
check:
backend.vkp != nil
@ -70,12 +72,13 @@ suite "Test BackendFactory":
discoveryIp: ValidIpAddress.init(IPv4_any()),
metricsAddress: ValidIpAddress.init("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 = (await initializeBackend(config, utilsMock)).tryGet
backend = initializeBackend(config, utilsMock).tryGet
check:
backend.vkp != nil
@ -91,10 +94,11 @@ suite "Test BackendFactory":
discoveryIp: ValidIpAddress.init(IPv4_any()),
metricsAddress: ValidIpAddress.init("127.0.0.1"),
persistenceCmd: PersistenceCmd.prover,
marketplaceAddress: EthAddress.example.some,
circuitDir: OutDir(circuitDir)
)
backendResult = (await initializeBackend(config, utilsMock))
backendResult = initializeBackend(config, utilsMock)
check:
backendResult.isErr

View File

@ -15,6 +15,8 @@ import pkg/codex/chunker
import pkg/codex/blocktype as bt
import pkg/codex/slots
import pkg/codex/stores
import pkg/codex/conf
import pkg/confutils/defs
import pkg/poseidon2/io
import pkg/codex/utils/poseidon2digest
@ -29,9 +31,6 @@ suite "Test Prover":
cellSize = DefaultCellSize
repoTmp = TempLevelDb.new()
metaTmp = TempLevelDb.new()
r1cs = "tests/circuits/fixtures/proof_main.r1cs"
wasm = "tests/circuits/fixtures/proof_main.wasm"
circomBackend = CircomCompat.init(r1cs, wasm)
challenge = 1234567.toF.toBytes.toArray32
var
@ -42,9 +41,20 @@ suite "Test Prover":
let
repoDs = repoTmp.newDb()
metaDs = metaTmp.newDb()
config = CodexConf(
cmd: StartUpCmd.persistence,
nat: ValidIpAddress.init("127.0.0.1"),
discoveryIp: ValidIpAddress.init(IPv4_any()),
metricsAddress: ValidIpAddress.init("127.0.0.1"),
persistenceCmd: PersistenceCmd.prover,
circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"),
circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"),
circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey"),
numProofSamples: samples
)
store = RepoStore.new(repoDs, metaDs)
prover = Prover.new(store, circomBackend, samples)
prover = Prover.new(store, config).tryGet()
teardown:
await repoTmp.destroyDb()