Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Dec 24, 2024
1 parent b3891df commit 2d27e8d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sdk/src/idl/drift.json
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@
},
{
"name": "authority",
"isMut": false,
"isMut": true,
"isSigner": true
}
],
Expand Down
19 changes: 17 additions & 2 deletions tests/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import {
mockUSDCMint,
} from './testHelpers';
import { PublicKey } from '@solana/web3.js';
import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection';
import {
BankrunContextWrapper,
Connection,
} from '../sdk/src/bankrun/bankrunConnection';
import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader';
import { checkIfAccountExists } from './placeAndMakeSwiftPerpBankrun';

describe('admin', () => {
const chProgram = anchor.workspace.Drift as Program;
Expand Down Expand Up @@ -417,3 +419,16 @@ describe('admin', () => {
await driftClient.unsubscribe();
});
});

async function checkIfAccountExists(
connection: Connection,
account: PublicKey
): Promise<boolean> {
try {
const accountInfo = await connection.getAccountInfo(account);
return accountInfo != null;
} catch (e) {
// Doesn't already exist
return false;
}
}
15 changes: 8 additions & 7 deletions tests/placeAndMakeSwiftPerpBankrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,13 @@ describe('place and make swift order', () => {
);

// Get pyth lazer instruction
const pythLazerCrankIxs = makerDriftClient.getPostPythLazerOracleUpdateIxs(
[6],
PYTH_LAZER_HEX_STRING_SOL,
undefined,
1
);
const pythLazerCrankIxs =
await makerDriftClient.getPostPythLazerOracleUpdateIxs(
[6],
PYTH_LAZER_HEX_STRING_SOL,
undefined,
1
);

const placeSwiftTakerOrderIxs =
await makerDriftClient.getPlaceSwiftTakerPerpOrderIxs(
Expand Down Expand Up @@ -1083,7 +1084,7 @@ function getSizeOfCompressedU16(n: number) {
return 1 + Number(n >= 128) + Number(n >= 16384);
}

export async function checkIfAccountExists(
async function checkIfAccountExists(
connection: Connection,
account: PublicKey
): Promise<boolean> {
Expand Down

0 comments on commit 2d27e8d

Please sign in to comment.