Skip to content

Commit

Permalink
(WIP) feat: add fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalolpetraglia committed Oct 4, 2023
1 parent 5380581 commit 77a708b
Show file tree
Hide file tree
Showing 7 changed files with 554 additions and 4,693 deletions.
22 changes: 22 additions & 0 deletions lib/create-fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Mina } from "snarkyjs";
import clone from "clone";


export function createAsyncFixture(fn: any) {
let originalResult;
let originalLocal;
let called = false;

return async () => {
if (!called) {
originalLocal = Mina.LocalBlockchain({ proofsEnabled: false });
Mina.setActiveInstance(originalLocal);
originalResult = await fn(originalLocal, Mina);
called = true;
}
const copiedLocal = clone(originalLocal);
Mina.setActiveInstance(copiedLocal);

return { ...clone(originalResult), local: copiedLocal, Mina};
}
}
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bool, Field, Int64, Mina, PublicKey, Sign, Signature, SmartContract, UInt32, UInt64 } from "snarkyjs";
import { Bool, Field, Int64, PublicKey, Sign, Signature, UInt32, UInt64 } from "snarkyjs";

export type BoolLike = Bool | boolean;
export type FieldLike = Field | string | number | bigint;
Expand Down
Loading

0 comments on commit 77a708b

Please sign in to comment.