-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ludo Galabru
committed
Oct 19, 2023
1 parent
0d2fba0
commit 8f728b6
Showing
7 changed files
with
200 additions
and
226 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -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)); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.