This commit is contained in:
Conner Gallagher 2023-06-26 13:20:59 -06:00
parent 50f18920d4
commit dc90cf456f
5 changed files with 16 additions and 31 deletions

View File

@ -268,7 +268,7 @@ async function programDeploy(
{ {
cwd: switchboardDir, cwd: switchboardDir,
encoding: "utf8", encoding: "utf8",
// stdio: 'pipe', stdio: "pipe",
shell: "/bin/zsh", shell: "/bin/zsh",
} }
); );
@ -289,7 +289,7 @@ async function programDeploy(
{ {
cwd: switchboardDir, cwd: switchboardDir,
encoding: "utf8", encoding: "utf8",
// stdio: 'pipe', stdio: "pipe",
shell: "/bin/zsh", shell: "/bin/zsh",
} }
); );

View File

@ -1,10 +1,5 @@
import { PublicKey } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js";
// Program ID defined in the provided IDL. Do not edit, it will get overwritten.
export const PROGRAM_ID_IDL = new PublicKey(
"SBAPyGPyvYEXTiTEfVrktmpvm3Bae3VoZmjYZ6694Ha"
);
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten. // Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
export const PROGRAM_ID_CLI = new PublicKey( export const PROGRAM_ID_CLI = new PublicKey(
"SBAPyGPyvYEXTiTEfVrktmpvm3Bae3VoZmjYZ6694Ha" "SBAPyGPyvYEXTiTEfVrktmpvm3Bae3VoZmjYZ6694Ha"

View File

@ -1,10 +1,5 @@
import { PublicKey } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js";
// Program ID defined in the provided IDL. Do not edit, it will get overwritten.
export const PROGRAM_ID_IDL = new PublicKey(
"SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f"
);
// Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten. // Program ID passed with the cli --program-id flag when running the code generator. Do not edit, it will get overwritten.
export const PROGRAM_ID_CLI = new PublicKey( export const PROGRAM_ID_CLI = new PublicKey(
"SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f" "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f"

View File

@ -2,7 +2,7 @@ import "mocha";
import { functionVerify } from "../src/generated/index.js"; import { functionVerify } from "../src/generated/index.js";
import * as sbv2 from "../src/index.js"; import * as sbv2 from "../src/index.js";
import { QuoteAccount } from "../src/index.js"; import { AttestationQueueAccount, EnclaveAccount } from "../src/index.js";
import { setupTest, TestContext } from "./utils.js"; import { setupTest, TestContext } from "./utils.js";
@ -17,8 +17,8 @@ const unixTimestamp = () => Math.floor(Date.now() / 1000);
describe("Function Tests", () => { describe("Function Tests", () => {
let ctx: TestContext; let ctx: TestContext;
let attestationQueueAccount: sbv2.AttestationQueueAccount; let attestationQueueAccount: AttestationQueueAccount;
let attestationQuoteVerifierAccount: sbv2.QuoteAccount; let attestationQuoteVerifierAccount: EnclaveAccount;
const quoteVerifierKeypair = Keypair.generate(); const quoteVerifierKeypair = Keypair.generate();
const quoteVerifierSigner = Keypair.generate(); const quoteVerifierSigner = Keypair.generate();
@ -76,14 +76,14 @@ describe("Function Tests", () => {
); );
await attestationQuoteVerifierAccount.rotate({ await attestationQuoteVerifierAccount.rotate({
securedSigner: quoteVerifierSigner, enclaveSigner: quoteVerifierSigner,
authority: ctx.payer, authority: ctx.payer,
registryKey: new Uint8Array(Array(64).fill(1)), registryKey: new Uint8Array(Array(64).fill(1)),
}); });
const quoteData1 = await attestationQuoteVerifierAccount.loadData(); const quoteData1 = await attestationQuoteVerifierAccount.loadData();
assert( assert(
quoteData1.securedSigner.equals(quoteVerifierSigner.publicKey), quoteData1.enclaveSigner.equals(quoteVerifierSigner.publicKey),
"QuoteAuthorityMismatch" "QuoteAuthorityMismatch"
); );
assert( assert(
@ -93,7 +93,7 @@ describe("Function Tests", () => {
// join the queue so we can verify other quotes // join the queue so we can verify other quotes
await attestationQuoteVerifierAccount.heartbeat({ await attestationQuoteVerifierAccount.heartbeat({
securedSigner: quoteVerifierSigner, enclaveSigner: quoteVerifierSigner,
}); });
}); });
@ -139,11 +139,11 @@ describe("Function Tests", () => {
}); });
it("Verifies the function's quote", async () => { it("Verifies the function's quote", async () => {
const [functionQuoteAccount] = functionAccount.getQuoteAccount(); const [functionQuoteAccount] = functionAccount.getEnclaveAccount();
const initialQuoteState = await functionQuoteAccount.loadData(); const initialQuoteState = await functionQuoteAccount.loadData();
const initialVerificationStatus = const initialVerificationStatus =
QuoteAccount.getVerificationStatus(initialQuoteState); EnclaveAccount.getVerificationStatus(initialQuoteState);
assert( assert(
initialVerificationStatus.kind === "None", initialVerificationStatus.kind === "None",
@ -159,7 +159,7 @@ describe("Function Tests", () => {
const finalQuoteState = await functionQuoteAccount.loadData(); const finalQuoteState = await functionQuoteAccount.loadData();
const finalVerificationStatus = const finalVerificationStatus =
QuoteAccount.getVerificationStatus(finalQuoteState); EnclaveAccount.getVerificationStatus(finalQuoteState);
assert( assert(
finalVerificationStatus.kind === "VerificationSuccess", finalVerificationStatus.kind === "VerificationSuccess",
@ -270,7 +270,6 @@ describe("Function Tests", () => {
attestationQueuePubkey, attestationQueuePubkey,
functionPubkey, functionPubkey,
escrowPubkey, escrowPubkey,
fnPermission,
fnQuote, fnQuote,
} = sbv2.FunctionAccount.decodeAddressLookup(lookupTable); } = sbv2.FunctionAccount.decodeAddressLookup(lookupTable);
@ -287,8 +286,8 @@ describe("Function Tests", () => {
}, },
{ {
function: functionAccount.publicKey, function: functionAccount.publicKey,
fnSigner: trustedSigner.publicKey, functionEnclaveSigner: trustedSigner.publicKey,
securedSigner: quoteVerifierSigner.publicKey, verifierEnclaveSigner: quoteVerifierSigner.publicKey,
verifierQuote: attestationQuoteVerifierAccount.publicKey, verifierQuote: attestationQuoteVerifierAccount.publicKey,
attestationQueue: attestationQueuePubkey, attestationQueue: attestationQueuePubkey,
escrow: escrowPubkey, escrow: escrowPubkey,
@ -302,12 +301,9 @@ describe("Function Tests", () => {
ctx.payer.publicKey, ctx.payer.publicKey,
ctx.payer.publicKey ctx.payer.publicKey
)[0].publicKey, )[0].publicKey,
fnPermission: fnPermission,
state: statePubkey, state: statePubkey,
payer: ctx.payer.publicKey,
fnQuote: fnQuote, fnQuote: fnQuote,
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID, tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
systemProgram: anchor.web3.SystemProgram.programId,
} }
); );
}; };
@ -385,7 +381,7 @@ describe("Function Tests", () => {
const preFunctionData = await functionAccount.loadData(); const preFunctionData = await functionAccount.loadData();
assert( assert(
preFunctionData.isTriggered === false, preFunctionData.isTriggered === 0,
"Function should be originally untriggered" "Function should be originally untriggered"
); );
@ -393,7 +389,7 @@ describe("Function Tests", () => {
const postFunctionData = await functionAccount.loadData(); const postFunctionData = await functionAccount.loadData();
assert( assert(
postFunctionData.isTriggered === true, postFunctionData.isTriggered === 1,
"Function should have been triggered" "Function should have been triggered"
); );
}); });

View File

@ -1,4 +1,4 @@
lockfileVersion: '6.1' lockfileVersion: '6.0'
settings: settings:
autoInstallPeers: true autoInstallPeers: true
@ -6570,7 +6570,6 @@ packages:
file:javascript/solana.js: file:javascript/solana.js:
resolution: {directory: javascript/solana.js, type: directory} resolution: {directory: javascript/solana.js, type: directory}
name: '@switchboard-xyz/solana.js' name: '@switchboard-xyz/solana.js'
version: 2.3.0-beta.7
engines: {node: '>=16.0.0', npm: '>=7.0.0'} engines: {node: '>=16.0.0', npm: '>=7.0.0'}
dependencies: dependencies:
'@coral-xyz/anchor': 0.27.0 '@coral-xyz/anchor': 0.27.0