mirror of
https://github.com/logos-storage/logos-storage-proofs.git
synced 2026-01-02 13:33:10 +00:00
updates
This commit is contained in:
parent
9a3259b8a7
commit
7935c8949c
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@ out.log
|
|||||||
src/circuit_tests/artifacts/*
|
src/circuit_tests/artifacts/*
|
||||||
!src/circuit_tests/artifacts/.keep
|
!src/circuit_tests/artifacts/.keep
|
||||||
codex_storage_proofs
|
codex_storage_proofs
|
||||||
|
test/tffi
|
||||||
|
|||||||
@ -22,6 +22,9 @@ static:
|
|||||||
|
|
||||||
include codex_proofs_ffi
|
include codex_proofs_ffi
|
||||||
|
|
||||||
|
proc len*(buff: Buffer): int =
|
||||||
|
buff.len.int
|
||||||
|
|
||||||
template 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),
|
Buffer(data: cast[ptr uint8](path.cstring),
|
||||||
@ -33,26 +36,3 @@ template unsafeBufferFromFile*(path: string): Buffer =
|
|||||||
|
|
||||||
Buffer(data: cast[ptr uint8](entireFile.cstring),
|
Buffer(data: cast[ptr uint8](entireFile.cstring),
|
||||||
len: entireFile.len().uint)
|
len: entireFile.len().uint)
|
||||||
|
|
||||||
when isMainModule:
|
|
||||||
var
|
|
||||||
r1cs_path = "src/circuit_tests/artifacts/storer-test.r1cs"
|
|
||||||
wasm_path = "src/circuit_tests/artifacts/storer-test_js/storer-test.wasm"
|
|
||||||
|
|
||||||
let
|
|
||||||
r1cs_buff = unsafeBufferPath(r1cs_path)
|
|
||||||
wasm_buff = unsafeBufferPath(wasm_path)
|
|
||||||
|
|
||||||
let storage_ctx = init_storage_proofs(r1cs_buff, wasm_buff, nil)
|
|
||||||
|
|
||||||
echo "storage_ctx: ", storage_ctx.repr
|
|
||||||
assert storage_ctx != nil
|
|
||||||
|
|
||||||
var
|
|
||||||
mpack_arg_path = "test/proof_test.mpack"
|
|
||||||
proofBuff = unsafeBufferFromFile(mpack_arg_path)
|
|
||||||
echo "proofArgs:size: ", proofBuff.len
|
|
||||||
let res = prove_mpack_ext(storage_ctx, addr proofBuff)
|
|
||||||
|
|
||||||
echo "result: ", res.repr
|
|
||||||
|
|
||||||
|
|||||||
1
test/config.nims
Normal file
1
test/config.nims
Normal file
@ -0,0 +1 @@
|
|||||||
|
--path:"../"
|
||||||
27
test/tffi.nim
Normal file
27
test/tffi.nim
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
import unittest2
|
||||||
|
import codex_storage_proofs
|
||||||
|
|
||||||
|
suite "storage proofs ffi":
|
||||||
|
test "basic ffi circuit":
|
||||||
|
var
|
||||||
|
r1cs_path = "src/circuit_tests/artifacts/storer-test.r1cs"
|
||||||
|
wasm_path = "src/circuit_tests/artifacts/storer-test_js/storer-test.wasm"
|
||||||
|
|
||||||
|
let
|
||||||
|
r1cs_buff = unsafeBufferPath(r1cs_path)
|
||||||
|
wasm_buff = unsafeBufferPath(wasm_path)
|
||||||
|
|
||||||
|
let storage_ctx = init_storage_proofs(r1cs_buff, wasm_buff, nil)
|
||||||
|
|
||||||
|
echo "storage_ctx: ", storage_ctx.repr
|
||||||
|
check storage_ctx != nil
|
||||||
|
|
||||||
|
var
|
||||||
|
mpack_arg_path = "test/proof_test.mpack"
|
||||||
|
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
|
||||||
Loading…
x
Reference in New Issue
Block a user