From 497b86ed8c52994f3dfc7fa93b9c350ccee45d23 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 22 Aug 2024 16:00:18 +0200 Subject: [PATCH] cleans up testbackendfactory --- tests/codex/slots/testbackendfactory.nim | 59 ++---------------------- 1 file changed, 5 insertions(+), 54 deletions(-) diff --git a/tests/codex/slots/testbackendfactory.nim b/tests/codex/slots/testbackendfactory.nim index 1f44a831..12c68d1b 100644 --- a/tests/codex/slots/testbackendfactory.nim +++ b/tests/codex/slots/testbackendfactory.nim @@ -1,6 +1,4 @@ import os -import std/strutils - import ../../asynctest import pkg/chronos @@ -17,10 +15,6 @@ type argR1csFile: string argWasmFile: string argZKeyFile: string - argUrl: string - argFilepath: string - argZipFile: string - argOutputDir: string method initializeCircomBackend*( self: BackendUtilsMock, @@ -37,29 +31,6 @@ method initializeCircomBackend*( vkpPtr: ptr VerifyingKey = key.addr return CircomCompat(vkp: vkpPtr) -method downloadFile*( - self: BackendUtilsMock, - url: string, - filepath: string -): ?!void = - self.argUrl = url - self.argFilepath = filepath - success() - -method unzipFile*( - self: BackendUtilsMock, - zipFile: string, - outputDir: string): ?!void = - self.argZipFile = zipFile - self.argOutputDir = outputDir - try: - writeFile(outputDir / "proof_main.r1cs", "r1cs_file") - writeFile(outputDir / "proof_main.wasm", "wasm_file") - writeFile(outputDir / "proof_main.zkey", "zkey_file") - except Exception as exc: - return failure(exc.msg) - success() - suite "Test BackendFactory": let utilsMock = BackendUtilsMock() @@ -83,18 +54,13 @@ suite "Test BackendFactory": circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"), circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey") ) - ceremonyHash = string.none - backend = (await initializeBackend(config, ceremonyHash, utilsMock)).tryGet + backend = (await initializeBackend(config, utilsMock)).tryGet check: backend.vkp != nil utilsMock.argR1csFile == $config.circomR1cs utilsMock.argWasmFile == $config.circomWasm utilsMock.argZKeyFile == $config.circomZkey - isEmptyOrWhitespace(utilsMock.argUrl) - isEmptyOrWhitespace(utilsMock.argFilepath) - isEmptyOrWhitespace(utilsMock.argZipFile) - isEmptyOrWhitespace(utilsMock.argOutputDir) test "Should create backend from local files": let @@ -109,24 +75,16 @@ suite "Test BackendFactory": # will be picked up as local files: circuitDir: OutDir("tests/circuits/fixtures") ) - ceremonyHash = string.none - backend = (await initializeBackend(config, ceremonyHash, utilsMock)).tryGet + backend = (await initializeBackend(config, 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" - isEmptyOrWhitespace(utilsMock.argUrl) - isEmptyOrWhitespace(utilsMock.argFilepath) - isEmptyOrWhitespace(utilsMock.argZipFile) - isEmptyOrWhitespace(utilsMock.argOutputDir) - test "Should download and unzip ceremony file if not available": + test "Should suggest usage of downloader tool when files not available": let - ceremonyHash = some "12345" - expectedZip = circuitDir / "circuit.zip" - expectedUrl = "https://circuit.codex.storage/proving-key/" & !ceremonyHash config = CodexConf( cmd: StartUpCmd.persistence, nat: ValidIpAddress.init("127.0.0.1"), @@ -136,14 +94,7 @@ suite "Test BackendFactory": circuitDir: OutDir(circuitDir) ) - backend = (await initializeBackend(config, ceremonyHash, utilsMock)).tryGet + backendResult = (await initializeBackend(config, utilsMock)) 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" - utilsMock.argUrl == expectedUrl - utilsMock.argFilepath == expectedZip - utilsMock.argZipFile == expectedZip - utilsMock.argOutputDir == circuitDir + backendResult.isErr