Skip to content

Commit

Permalink
updating integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luiz-lvj committed Oct 31, 2024
1 parent 8af6c6c commit cef9e43
Show file tree
Hide file tree
Showing 16 changed files with 11,499 additions and 36 deletions.
1 change: 1 addition & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
docker compose up --build --exit-code-from app
git status --porcelain
git diff
[[ -z $(git status --porcelain ) ]]
- name: Upload package file as artifact
uses: actions/upload-artifact@v4
Expand Down
14 changes: 7 additions & 7 deletions tools/garaga_rs/src/wasm_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ fn parse_biguint_array(value: JsValue) -> Result<Vec<BigUint>, JsValue> {
array
.iter()
.map(|v| {
let s = v
.as_string()
.ok_or_else(|| JsValue::from_str("public_inputs element is not a string"))?;
// let s = v
// .as_string()
// .ok_or_else(|| JsValue::from_str("public_inputs element is not a string"))?;

// Parse the string into BigUint using the helper function
jsvalue_to_biguint(JsValue::from_str(&s))
jsvalue_to_biguint(v)
})
.collect()
}
Expand Down Expand Up @@ -225,9 +225,9 @@ pub fn get_groth16_calldata(
let b = parse_g2_point(get_property(&proof_obj, "b")?)?;
let c = parse_g1_point(get_property(&proof_obj, "c")?)?;

let public_inputs = parse_biguint_array(get_property(&proof_obj, "public_inputs")?)?;
let public_inputs = parse_biguint_array(get_property(&proof_obj, "publicInputs")?)?;

let image_id = parse_optional_uint8_array(get_property(&proof_obj, "image_id")?);
let image_id = parse_optional_uint8_array(get_property(&proof_obj, "imageId")?);
let journal = parse_optional_uint8_array(get_property(&proof_obj, "journal")?);

let proof = Groth16Proof {
Expand Down Expand Up @@ -419,7 +419,7 @@ mod tests {
public_inputs.push(&JsValue::from_str(
"0x1e17db88c1d2e83e49f692cce4bb8169309de90afb2b141156243106aa34b474",
));
js_sys::Reflect::set(&obj, &JsValue::from_str("public_inputs"), &public_inputs).unwrap();
js_sys::Reflect::set(&obj, &JsValue::from_str("publicInputs"), &public_inputs).unwrap();

obj.into()
}
Expand Down
54 changes: 27 additions & 27 deletions tools/npm/garaga_ts/src/wasm/pkg/garaga_rs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function takeObject(idx) {
return ret;
}

let WASM_VECTOR_LEN = 0;
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );

if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };

let cachedUint8ArrayMemory0 = null;

Expand All @@ -31,6 +33,22 @@ function getUint8ArrayMemory0() {
return cachedUint8ArrayMemory0;
}

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];

heap[idx] = obj;
return idx;
}

let WASM_VECTOR_LEN = 0;

const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );

const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
Expand Down Expand Up @@ -98,24 +116,6 @@ function getDataViewMemory0() {
return cachedDataViewMemory0;
}

const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );

if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };

function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];

heap[idx] = obj;
return idx;
}

function debugString(val) {
// primitive types
const type = typeof val;
Expand Down Expand Up @@ -381,14 +381,6 @@ function __wbg_get_imports() {
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
Expand All @@ -397,6 +389,14 @@ function __wbg_get_imports() {
const ret = getObject(arg0) + getObject(arg1);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};
imports.wbg.__wbindgen_bigint_from_str = function(arg0, arg1) {
const ret = BigInt(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down
2 changes: 1 addition & 1 deletion tools/npm/garaga_ts/src/wasm/pkg/garaga_rs_bg.wasm.js

Large diffs are not rendered by default.

Loading

0 comments on commit cef9e43

Please sign in to comment.