Skip to content

Commit

Permalink
refactor: handling fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Oct 19, 2023
1 parent 0d2fba0 commit 8f728b6
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 226 deletions.
76 changes: 0 additions & 76 deletions unit-tests/pyth-pnau.test.ts

This file was deleted.

83 changes: 4 additions & 79 deletions unit-tests/constants.ts → unit-tests/pyth/fixtures.ts

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions unit-tests/pyth/oracle.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Cl, ClarityType } from "@stacks/transactions";
import { beforeEach, describe, expect, it } from "vitest";
import { ParsedTransactionResult, tx } from "@hirosystems/clarinet-sdk";
import { apnuMainnetVaas } from "./fixtures";
import { wormhole } from "../wormhole/helper";

const pythOracleContractName = "pyth-oracle-v1";
const pythDecoderPnauContractName = "pyth-pnau-decoder-v1";
const pythStorageContractName = "pyth-store-v1";
const wormholeCoreContractName = "wormhole-core-v1";

describe("pyth-oracle-v1::decode-and-verify-price-feeds mainnet VAAs", () => {
const accounts = simnet.getAccounts();
const sender = accounts.get("wallet_1")!;

let block: ParsedTransactionResult[] | undefined = undefined;

// Before starting the test suite, we have to setup the guardian set.
beforeEach(async () => {
block = wormhole.applyMainnetGuardianSetUpdates(sender, wormholeCoreContractName)
})

it("should succeed handling the 3 guardians rotations", () => {
expect(block!).toHaveLength(3);
block!.forEach((b: ParsedTransactionResult) => {
expect(b.result).toHaveClarityType(ClarityType.ResponseOk);
});
});

it("should succeed handling PNAU mainnet payloads", () => {
const vaaBytes = Cl.bufferFromHex(apnuMainnetVaas[0]);
const executionPlan = Cl.tuple({
'pyth-storage-contract': Cl.contractPrincipal(simnet.deployer, pythStorageContractName),
'pyth-decoder-contract': Cl.contractPrincipal(simnet.deployer, pythDecoderPnauContractName),
'wormhole-core-contract': Cl.contractPrincipal(simnet.deployer, wormholeCoreContractName),
});

let res = simnet.callPublicFn(
pythOracleContractName,
"verify-and-update-price-feeds",
[vaaBytes, executionPlan],
sender
);

const result = res.result;
console.log(Cl.prettyPrint(result, 2));
});
});
49 changes: 0 additions & 49 deletions unit-tests/wormhole.test.ts

This file was deleted.

Loading

0 comments on commit 8f728b6

Please sign in to comment.