Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ejMina226 committed Jan 7, 2025
1 parent 8da0793 commit c3e6488
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions packages/module/test/modules/Balances.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("balances", () => {
it("should compile and prove a method execution", async () => {
expect.assertions(3);

runtime.zkProgrammable.appChain?.setProofsEnabled(true);
runtime.appChain?.setProofsEnabled(true);

const executionContext = container.resolve(RuntimeMethodExecutionContext);
executionContext.setup({
Expand All @@ -80,17 +80,17 @@ describe("balances", () => {
"1439144406936083177718146178121957896974210157062549589517697792374542035761";
const expectedStatus = true;

await runtime.zkProgrammable.zkProgram[0].compile();
await runtime.zkProgram[0].compile();

await balances.getTotalSupply();

const { result } = executionContext.current();

const proof = await result.prove<Proof<undefined, MethodPublicOutput>>();

const verified = await runtime.zkProgrammable.zkProgram[0].verify(proof);
const verified = await runtime.zkProgram[0].verify(proof);

runtime.zkProgrammable.appChain?.setProofsEnabled(false);
runtime.appChain?.setProofsEnabled(false);

expect(verified).toBe(true);

Expand Down
10 changes: 5 additions & 5 deletions packages/protocol/test/BlockProver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {
AreProofsEnabled,
PlainZkProgram,
ZkProgrammable,
ZkProgramFactory,
} from "@proto-kit/common";
import { Bool, Field, Proof, UInt64, ZkProgram } from "o1js";
import "reflect-metadata";
Expand Down Expand Up @@ -30,10 +30,9 @@ class MockAppChain implements AreProofsEnabled {
}
}

class RuntimeZkProgrammable extends ZkProgrammable<
undefined,
MethodPublicOutput
> {
class RuntimeZkProgrammable
implements ZkProgramFactory<undefined, MethodPublicOutput>
{
get appChain(): AreProofsEnabled | undefined {
return new MockAppChain();
}
Expand All @@ -51,6 +50,7 @@ class RuntimeZkProgrammable extends ZkProgrammable<
verify: program.verify.bind(program),
analyzeMethods: program.analyzeMethods.bind(program),
methods: {},
proofsEnabled: true,
Proof: ZkProgram.Proof(program),
},
];
Expand Down
15 changes: 11 additions & 4 deletions packages/protocol/test/TestingProtocol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { WithZkProgrammable, ZkProgrammable } from "@proto-kit/common";
import {
PlainZkProgram,
WithZkProgram,
ZkProgramFactory,
} from "@proto-kit/common";
import { container } from "tsyringe";

import {
Expand All @@ -11,9 +15,12 @@ import {
StateTransitionProver,
} from "../src";

class RuntimeMock implements WithZkProgrammable<undefined, MethodPublicOutput> {
zkProgrammable: ZkProgrammable<undefined, MethodPublicOutput> =
undefined as unknown as ZkProgrammable<undefined, MethodPublicOutput>;
class RuntimeMock implements WithZkProgram<undefined, MethodPublicOutput> {
zkProgramFactory: ZkProgramFactory<undefined, MethodPublicOutput> =
undefined as unknown as ZkProgramFactory<undefined, MethodPublicOutput>;

zkProgram: PlainZkProgram<undefined, MethodPublicOutput>[] =
undefined as unknown as PlainZkProgram<undefined, MethodPublicOutput>[];
}

export function createAndInitTestingProtocol() {
Expand Down

0 comments on commit c3e6488

Please sign in to comment.