34 lines
1.0 KiB
Nim
Raw Normal View History

2023-12-22 19:51:25 -07:00
2024-01-10 16:30:18 +02:00
import std/os
2023-12-22 19:51:25 -07:00
import unittest2
import codex_storage_proofs
suite "storage proofs ffi":
test "basic ffi circuit":
var
2024-01-10 16:30:18 +02:00
r1csPath = "src/circuit_tests/artifacts/storer-test.r1cs".absolutePath()
wasmPath = "src/circuit_tests/artifacts/storer-test_js/storer-test.wasm".absolutePath()
2023-12-22 19:51:25 -07:00
2024-01-10 16:32:48 +02:00
if not r1csPath.fileExists():
raise newException(ValueError, "missing expected r1cs file: " & r1csPath)
if not wasmPath.fileExists():
raise newException(ValueError, "missing expected wasm file: " & wasmPath)
2023-12-22 19:51:25 -07:00
let
2024-01-10 16:30:18 +02:00
r1cs_buff = unsafeBufferPath(r1csPath)
wasm_buff = unsafeBufferPath(wasmPath)
2023-12-22 19:51:25 -07:00
let storage_ctx = init_storage_proofs(r1cs_buff, wasm_buff, nil)
echo "storage_ctx: ", storage_ctx.repr
check storage_ctx != nil
var
2024-01-10 16:30:18 +02:00
mpack_arg_path = "tests/proof_test.mpack"
2023-12-22 19:51:25 -07:00
proofBuff = unsafeBufferFromFile(mpack_arg_path)
echo "proofArgs:size: ", proofBuff.len()
let res = prove_mpack_ext(storage_ctx, addr proofBuff)
echo "result: ", res.repr
check res != nil