-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
5,416 additions
and
3,664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./pedersen/index.js"; | ||
export * from './pedersen/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./pedersen.js"; | ||
export * from './pedersen.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,46 @@ | ||
import { FileCrs, SRS_DEV_PATH } from "../crs/index.js"; | ||
import { BarretenbergWasm } from "./barretenberg_wasm.js"; | ||
import { FileCrs, SRS_DEV_PATH } from '../crs/index.js'; | ||
import { BarretenbergWasm } from './barretenberg_wasm.js'; | ||
|
||
describe("basic barretenberg smoke test", () => { | ||
describe('basic barretenberg smoke test', () => { | ||
const wasm: BarretenbergWasm = new BarretenbergWasm(); | ||
|
||
beforeAll(async () => { | ||
await wasm.init(); | ||
}); | ||
|
||
it("should new malloc, transfer and slice mem", () => { | ||
it('should new malloc, transfer and slice mem', () => { | ||
const length = 1024; | ||
const ptr = wasm.call("bbmalloc", length); | ||
const ptr = wasm.call('bbmalloc', length); | ||
const buf = Buffer.alloc(length, 128); | ||
wasm.writeMemory(ptr, buf); | ||
wasm.call("bbfree", ptr); | ||
wasm.call('bbfree', ptr); | ||
const result = Buffer.from(wasm.getMemorySlice(ptr, ptr + length)); | ||
expect(result).toStrictEqual(buf); | ||
}); | ||
|
||
it("should use asyncify to do an async callback into js", async () => { | ||
const addr1 = await wasm.asyncCall("test_async_func", 1024 * 1024, 1); | ||
const addr2 = await wasm.asyncCall("test_async_func", 1024 * 1024 * 2, 2); | ||
expect( | ||
wasm.getMemorySlice(addr1, addr1 + 1024 * 1024).every((v) => v === 1) | ||
).toBe(true); | ||
expect( | ||
wasm.getMemorySlice(addr2, addr2 + 1024 * 1024 * 2).every((v) => v === 2) | ||
).toBe(true); | ||
it('should use asyncify to do an async callback into js', async () => { | ||
const addr1 = await wasm.asyncCall('test_async_func', 1024 * 1024, 1); | ||
const addr2 = await wasm.asyncCall('test_async_func', 1024 * 1024 * 2, 2); | ||
expect(wasm.getMemorySlice(addr1, addr1 + 1024 * 1024).every(v => v === 1)).toBe(true); | ||
expect(wasm.getMemorySlice(addr2, addr2 + 1024 * 1024 * 2).every(v => v === 2)).toBe(true); | ||
}); | ||
|
||
it("should correctly pass CRS data through env_load_verifier_crs", async () => { | ||
it('should correctly pass CRS data through env_load_verifier_crs', async () => { | ||
const crs = new FileCrs(0, SRS_DEV_PATH); | ||
await crs.init(); | ||
const g2DataPtr = await wasm.asyncCall("test_env_load_verifier_crs"); | ||
const g2DataPtr = await wasm.asyncCall('test_env_load_verifier_crs'); | ||
const g2Data = wasm.getMemorySlice(g2DataPtr, g2DataPtr + 128); | ||
expect(Buffer.from(g2Data)).toStrictEqual(crs.getG2Data()); | ||
wasm.call("bbfree", g2DataPtr); | ||
wasm.call('bbfree', g2DataPtr); | ||
}); | ||
|
||
it("should correctly pass CRS data through env_load_prover_crs", async () => { | ||
it('should correctly pass CRS data through env_load_prover_crs', async () => { | ||
const numPoints = 1024; | ||
const crs = new FileCrs(numPoints, SRS_DEV_PATH); | ||
await crs.init(); | ||
const g1DataPtr = await wasm.asyncCall( | ||
"test_env_load_prover_crs", | ||
numPoints | ||
); | ||
const g1DataPtr = await wasm.asyncCall('test_env_load_prover_crs', numPoints); | ||
const g1Data = wasm.getMemorySlice(g1DataPtr, g1DataPtr + numPoints * 64); | ||
expect(Buffer.from(g1Data)).toStrictEqual(crs.getG1Data()); | ||
wasm.call("bbfree", g1DataPtr); | ||
wasm.call('bbfree', g1DataPtr); | ||
}); | ||
}); |
Oops, something went wrong.