|
|
@@ -6,7 +6,7 @@ import { createWormholeProgramInterface } from "@certusone/wormhole-sdk/lib/cjs/
|
|
|
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
|
|
|
import {
|
|
|
getPythClusterApiUrl,
|
|
|
- PythCluster,
|
|
|
+ type PythCluster,
|
|
|
} from "@pythnetwork/client/lib/cluster";
|
|
|
import {
|
|
|
Connection,
|
|
|
@@ -56,104 +56,104 @@ test("Wormhole multisig instruction parse: send message without governance paylo
|
|
|
);
|
|
|
expect(parsedInstruction.name).toBe("postMessage");
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["bridge"].pubkey.equals(
|
|
|
- instruction.keys[0].pubkey,
|
|
|
+ parsedInstruction.accounts.named["bridge"]?.pubkey.equals(
|
|
|
+ instruction.keys[0]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["bridge"].isSigner).toBe(
|
|
|
- instruction.keys[0].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["bridge"]?.isSigner).toBe(
|
|
|
+ instruction.keys[0]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["bridge"].isWritable).toBe(
|
|
|
- instruction.keys[0].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["bridge"]?.isWritable).toBe(
|
|
|
+ instruction.keys[0]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["message"].pubkey.equals(
|
|
|
- instruction.keys[1].pubkey,
|
|
|
+ parsedInstruction.accounts.named["message"]?.pubkey.equals(
|
|
|
+ instruction.keys[1]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["message"].isSigner).toBe(
|
|
|
- instruction.keys[1].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["message"]?.isSigner).toBe(
|
|
|
+ instruction.keys[1]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["message"].isWritable).toBe(
|
|
|
- instruction.keys[1].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["message"]?.isWritable).toBe(
|
|
|
+ instruction.keys[1]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["emitter"].pubkey.equals(
|
|
|
- instruction.keys[2].pubkey,
|
|
|
+ parsedInstruction.accounts.named["emitter"]?.pubkey.equals(
|
|
|
+ instruction.keys[2]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["emitter"].isSigner).toBe(
|
|
|
- instruction.keys[2].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["emitter"]?.isSigner).toBe(
|
|
|
+ instruction.keys[2]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["emitter"].isWritable).toBe(
|
|
|
- instruction.keys[2].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["emitter"]?.isWritable).toBe(
|
|
|
+ instruction.keys[2]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["sequence"].pubkey.equals(
|
|
|
- instruction.keys[3].pubkey,
|
|
|
+ parsedInstruction.accounts.named["sequence"]?.pubkey.equals(
|
|
|
+ instruction.keys[3]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["sequence"].isSigner).toBe(
|
|
|
- instruction.keys[3].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["sequence"]?.isSigner).toBe(
|
|
|
+ instruction.keys[3]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["sequence"].isWritable).toBe(
|
|
|
- instruction.keys[3].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["sequence"]?.isWritable).toBe(
|
|
|
+ instruction.keys[3]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["payer"].pubkey.equals(
|
|
|
- instruction.keys[4].pubkey,
|
|
|
+ parsedInstruction.accounts.named["payer"]?.pubkey.equals(
|
|
|
+ instruction.keys[4]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["payer"].isSigner).toBe(
|
|
|
- instruction.keys[4].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["payer"]?.isSigner).toBe(
|
|
|
+ instruction.keys[4]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["payer"].isWritable).toBe(
|
|
|
- instruction.keys[4].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["payer"]?.isWritable).toBe(
|
|
|
+ instruction.keys[4]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["feeCollector"].pubkey.equals(
|
|
|
- instruction.keys[5].pubkey,
|
|
|
+ parsedInstruction.accounts.named["feeCollector"]?.pubkey.equals(
|
|
|
+ instruction.keys[5]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["feeCollector"].isSigner).toBe(
|
|
|
- instruction.keys[5].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["feeCollector"]?.isSigner).toBe(
|
|
|
+ instruction.keys[5]?.isSigner,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["feeCollector"].isWritable,
|
|
|
- ).toBe(instruction.keys[5].isWritable);
|
|
|
+ parsedInstruction.accounts.named["feeCollector"]?.isWritable,
|
|
|
+ ).toBe(instruction.keys[5]?.isWritable);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["clock"].pubkey.equals(
|
|
|
- instruction.keys[6].pubkey,
|
|
|
+ parsedInstruction.accounts.named["clock"]?.pubkey.equals(
|
|
|
+ instruction.keys[6]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["clock"].isSigner).toBe(
|
|
|
- instruction.keys[6].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["clock"]?.isSigner).toBe(
|
|
|
+ instruction.keys[6]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["clock"].isWritable).toBe(
|
|
|
- instruction.keys[6].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["clock"]?.isWritable).toBe(
|
|
|
+ instruction.keys[6]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["rent"].pubkey.equals(
|
|
|
- instruction.keys[7].pubkey,
|
|
|
+ parsedInstruction.accounts.named["rent"]?.pubkey.equals(
|
|
|
+ instruction.keys[7]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["rent"].isSigner).toBe(
|
|
|
- instruction.keys[7].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["rent"]?.isSigner).toBe(
|
|
|
+ instruction.keys[7]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["rent"].isWritable).toBe(
|
|
|
- instruction.keys[7].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["rent"]?.isWritable).toBe(
|
|
|
+ instruction.keys[7]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["systemProgram"].pubkey.equals(
|
|
|
- instruction.keys[8].pubkey,
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.pubkey.equals(
|
|
|
+ instruction.keys[8]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["systemProgram"].isSigner).toBe(
|
|
|
- instruction.keys[8].isSigner,
|
|
|
- );
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["systemProgram"].isWritable,
|
|
|
- ).toBe(instruction.keys[8].isWritable);
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.isSigner,
|
|
|
+ ).toBe(instruction.keys[8]?.isSigner);
|
|
|
+ expect(
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.isWritable,
|
|
|
+ ).toBe(instruction.keys[8]?.isWritable);
|
|
|
expect(parsedInstruction.accounts.remaining.length).toBe(0);
|
|
|
|
|
|
expect(parsedInstruction.args.nonce).toBe(1);
|
|
|
@@ -208,104 +208,104 @@ test("Wormhole multisig instruction parse: send message with governance payload"
|
|
|
);
|
|
|
expect(parsedInstruction.name).toBe("postMessage");
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["bridge"].pubkey.equals(
|
|
|
- instruction.keys[0].pubkey,
|
|
|
+ parsedInstruction.accounts.named["bridge"]?.pubkey.equals(
|
|
|
+ instruction.keys[0]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["bridge"].isSigner).toBe(
|
|
|
- instruction.keys[0].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["bridge"]?.isSigner).toBe(
|
|
|
+ instruction.keys[0]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["bridge"].isWritable).toBe(
|
|
|
- instruction.keys[0].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["bridge"]?.isWritable).toBe(
|
|
|
+ instruction.keys[0]!.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["message"].pubkey.equals(
|
|
|
- instruction.keys[1].pubkey,
|
|
|
+ parsedInstruction.accounts.named["message"]?.pubkey.equals(
|
|
|
+ instruction.keys[1]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["message"].isSigner).toBe(
|
|
|
- instruction.keys[1].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["message"]?.isSigner).toBe(
|
|
|
+ instruction.keys[1]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["message"].isWritable).toBe(
|
|
|
- instruction.keys[1].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["message"]?.isWritable).toBe(
|
|
|
+ instruction.keys[1]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["emitter"].pubkey.equals(
|
|
|
- instruction.keys[2].pubkey,
|
|
|
+ parsedInstruction.accounts.named["emitter"]?.pubkey.equals(
|
|
|
+ instruction.keys[2]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["emitter"].isSigner).toBe(
|
|
|
- instruction.keys[2].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["emitter"]?.isSigner).toBe(
|
|
|
+ instruction.keys[2]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["emitter"].isWritable).toBe(
|
|
|
- instruction.keys[2].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["emitter"]?.isWritable).toBe(
|
|
|
+ instruction.keys[2]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["sequence"].pubkey.equals(
|
|
|
- instruction.keys[3].pubkey,
|
|
|
+ parsedInstruction.accounts.named["sequence"]?.pubkey.equals(
|
|
|
+ instruction.keys[3]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["sequence"].isSigner).toBe(
|
|
|
- instruction.keys[3].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["sequence"]?.isSigner).toBe(
|
|
|
+ instruction.keys[3]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["sequence"].isWritable).toBe(
|
|
|
- instruction.keys[3].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["sequence"]?.isWritable).toBe(
|
|
|
+ instruction.keys[3]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["payer"].pubkey.equals(
|
|
|
- instruction.keys[4].pubkey,
|
|
|
+ parsedInstruction.accounts.named["payer"]?.pubkey.equals(
|
|
|
+ instruction.keys[4]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["payer"].isSigner).toBe(
|
|
|
- instruction.keys[4].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["payer"]?.isSigner).toBe(
|
|
|
+ instruction.keys[4]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["payer"].isWritable).toBe(
|
|
|
- instruction.keys[4].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["payer"]?.isWritable).toBe(
|
|
|
+ instruction.keys[4]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["feeCollector"].pubkey.equals(
|
|
|
- instruction.keys[5].pubkey,
|
|
|
+ parsedInstruction.accounts.named["feeCollector"]?.pubkey.equals(
|
|
|
+ instruction.keys[5]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["feeCollector"].isSigner).toBe(
|
|
|
- instruction.keys[5].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["feeCollector"]?.isSigner).toBe(
|
|
|
+ instruction.keys[5]?.isSigner,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["feeCollector"].isWritable,
|
|
|
- ).toBe(instruction.keys[5].isWritable);
|
|
|
+ parsedInstruction.accounts.named["feeCollector"]?.isWritable,
|
|
|
+ ).toBe(instruction.keys[5]?.isWritable);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["clock"].pubkey.equals(
|
|
|
- instruction.keys[6].pubkey,
|
|
|
+ parsedInstruction.accounts.named["clock"]?.pubkey.equals(
|
|
|
+ instruction.keys[6]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["clock"].isSigner).toBe(
|
|
|
- instruction.keys[6].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["clock"]?.isSigner).toBe(
|
|
|
+ instruction.keys[6]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["clock"].isWritable).toBe(
|
|
|
- instruction.keys[6].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["clock"]?.isWritable).toBe(
|
|
|
+ instruction.keys[6]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["rent"].pubkey.equals(
|
|
|
- instruction.keys[7].pubkey,
|
|
|
+ parsedInstruction.accounts.named["rent"]?.pubkey.equals(
|
|
|
+ instruction.keys[7]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["rent"].isSigner).toBe(
|
|
|
- instruction.keys[7].isSigner,
|
|
|
+ expect(parsedInstruction.accounts.named["rent"]?.isSigner).toBe(
|
|
|
+ instruction.keys[7]?.isSigner,
|
|
|
);
|
|
|
- expect(parsedInstruction.accounts.named["rent"].isWritable).toBe(
|
|
|
- instruction.keys[7].isWritable,
|
|
|
+ expect(parsedInstruction.accounts.named["rent"]?.isWritable).toBe(
|
|
|
+ instruction.keys[7]?.isWritable,
|
|
|
);
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["systemProgram"].pubkey.equals(
|
|
|
- instruction.keys[8].pubkey,
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.pubkey.equals(
|
|
|
+ instruction.keys[8]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
- expect(parsedInstruction.accounts.named["systemProgram"].isSigner).toBe(
|
|
|
- instruction.keys[8].isSigner,
|
|
|
- );
|
|
|
expect(
|
|
|
- parsedInstruction.accounts.named["systemProgram"].isWritable,
|
|
|
- ).toBe(instruction.keys[8].isWritable);
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.isSigner,
|
|
|
+ ).toBe(instruction.keys[8]?.isSigner);
|
|
|
+ expect(
|
|
|
+ parsedInstruction.accounts.named["systemProgram"]?.isWritable,
|
|
|
+ ).toBe(instruction.keys[8]?.isWritable);
|
|
|
expect(parsedInstruction.accounts.remaining.length).toBe(0);
|
|
|
|
|
|
expect(parsedInstruction.args.nonce).toBe(0);
|
|
|
@@ -325,23 +325,23 @@ test("Wormhole multisig instruction parse: send message with governance payload"
|
|
|
).forEach((instruction, i) => {
|
|
|
expect(
|
|
|
instruction.programId.equals(
|
|
|
- executePostedVaa.instructions[i].programId,
|
|
|
+ executePostedVaa.instructions[i]!.programId,
|
|
|
),
|
|
|
- );
|
|
|
+ ).toBeTruthy();
|
|
|
expect(
|
|
|
- instruction.data.equals(executePostedVaa.instructions[i].data),
|
|
|
- );
|
|
|
+ instruction.data.equals(executePostedVaa.instructions[i]!.data),
|
|
|
+ ).toBeTruthy();
|
|
|
instruction.keys.forEach((account, j) => {
|
|
|
expect(
|
|
|
account.pubkey.equals(
|
|
|
- executePostedVaa.instructions[i].keys[j].pubkey,
|
|
|
+ executePostedVaa.instructions[i]!.keys[j]!.pubkey,
|
|
|
),
|
|
|
).toBeTruthy();
|
|
|
expect(account.isSigner).toBe(
|
|
|
- executePostedVaa.instructions[i].keys[j].isSigner,
|
|
|
+ executePostedVaa.instructions[i]!.keys[j]!.isSigner,
|
|
|
);
|
|
|
expect(account.isWritable).toBe(
|
|
|
- executePostedVaa.instructions[i].keys[j].isWritable,
|
|
|
+ executePostedVaa.instructions[i]!.keys[j]!.isWritable,
|
|
|
);
|
|
|
});
|
|
|
});
|