mirror of
https://github.com/logos-storage/logos-storage-proofs.git
synced 2026-01-02 13:33:10 +00:00
add example ffi test
This commit is contained in:
parent
2ba2c31072
commit
a84d7b5241
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import std/os
|
import std/os
|
||||||
import std/strutils
|
import std/strutils
|
||||||
import std/sha1
|
|
||||||
import std/macros
|
import std/macros
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -23,14 +22,23 @@ static:
|
|||||||
|
|
||||||
include codex_proofs_ffi
|
include codex_proofs_ffi
|
||||||
|
|
||||||
proc unsafeBufferPath*(path: var string): Buffer =
|
template unsafeBufferPath*(path: var string): Buffer =
|
||||||
assert path.len() > 0
|
assert path.len() > 0
|
||||||
Buffer(data: cast[ptr uint8](path.cstring), len: path.len().uint)
|
Buffer(data: cast[ptr uint8](path.cstring),
|
||||||
|
len: path.len().uint)
|
||||||
|
|
||||||
|
template unsafeBufferFromFile*(path: string): Buffer =
|
||||||
|
assert path.len() > 0
|
||||||
|
let entireFile = readFile(path)
|
||||||
|
|
||||||
|
Buffer(data: cast[ptr uint8](entireFile.cstring),
|
||||||
|
len: entireFile.len().uint)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var
|
var
|
||||||
r1cs_path = "src/circuit_tests/artifacts/storer-test.r1cs"
|
r1cs_path = "src/circuit_tests/artifacts/storer-test.r1cs"
|
||||||
wasm_path = "src/circuit_tests/artifacts/storer-test_js/storer-test.wasm"
|
wasm_path = "src/circuit_tests/artifacts/storer-test_js/storer-test.wasm"
|
||||||
|
|
||||||
let
|
let
|
||||||
r1cs_buff = unsafeBufferPath(r1cs_path)
|
r1cs_buff = unsafeBufferPath(r1cs_path)
|
||||||
wasm_buff = unsafeBufferPath(wasm_path)
|
wasm_buff = unsafeBufferPath(wasm_path)
|
||||||
@ -40,3 +48,8 @@ when isMainModule:
|
|||||||
echo "storage_ctx: ", storage_ctx.repr
|
echo "storage_ctx: ", storage_ctx.repr
|
||||||
assert storage_ctx != nil
|
assert storage_ctx != nil
|
||||||
|
|
||||||
|
let
|
||||||
|
mpack_arg_path = "test/proof_test.mpack"
|
||||||
|
proofArgs = unsafeBufferFromFile(mpack_arg_path)
|
||||||
|
echo "proofArgs:size: ", proofArgs.len
|
||||||
|
# prove_mpack_ext()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user