Skip to content

Commit

Permalink
chore: adjust test scripts for createInstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
kAsky53 committed Oct 13, 2023
1 parent 5fe49da commit 0cf191d
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions tests/bench/tests/compute-units.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("Compute units", () => {
const mintKp = new anchor.web3.Keypair();
mintPk = mintKp.publicKey;
const createMintIx = await tokenProgram.account.mint.createInstruction(
mintKp
mintPk
);
const initMintIx = await tokenProgram.methods
.initializeMint2(0, owner, null)
Expand All @@ -133,7 +133,7 @@ describe("Compute units", () => {
const tokenKp = new anchor.web3.Keypair();
tokenPk = tokenKp.publicKey;
const createTokenIx = await tokenProgram.account.account.createInstruction(
tokenKp
tokenPk
);
const initTokenIx = await tokenProgram.methods
.initializeAccount3(owner)
Expand Down
2 changes: 1 addition & 1 deletion tests/cashiers-check/tests/cashiers-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("cashiers-check", () => {
},
signers: [check, vault],
instructions: [
await program.account.check.createInstruction(check, 300),
await program.account.check.createInstruction(check.publicKey, 300),
...(await serumCmn.createTokenAccountInstrs(
program.provider,
vault.publicKey,
Expand Down
4 changes: 2 additions & 2 deletions tests/cfo/tests/utils/stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ async function setupStakePool(mint, god) {
},
signers: [registrar, rewardQ],
instructions: [
await registry.account.registrar.createInstruction(registrar),
await registry.account.rewardQueue.createInstruction(rewardQ, 8250),
await registry.account.registrar.createInstruction(registrar.publicKey),
await registry.account.rewardQueue.createInstruction(rewardQ.publicKey, 8250),
],
}
);
Expand Down
4 changes: 2 additions & 2 deletions tests/composite/tests/composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe("composite", () => {
},
signers: [dummyA, dummyB],
instructions: [
await program.account.dummyA.createInstruction(dummyA),
await program.account.dummyB.createInstruction(dummyB),
await program.account.dummyA.createInstruction(dummyA.publicKey),
await program.account.dummyB.createInstruction(dummyB.publicKey),
],
});

Expand Down
2 changes: 1 addition & 1 deletion tests/custom-coder/tests/spl-associated-token-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("spl-associated-token-coder", () => {
})
.preInstructions(
await Promise.all([
tokenProgram.account.mint.createInstruction(mintKeypair),
tokenProgram.account.mint.createInstruction(mintKeypair.publicKey),
tokenProgram.methods
.initializeMint(mintDecimals, provider.wallet.publicKey, null)
.accounts({
Expand Down
6 changes: 3 additions & 3 deletions tests/custom-coder/tests/spl-token-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("spl-token", () => {
})
.signers([mintKeypair])
.preInstructions([
await program.account.mint.createInstruction(mintKeypair),
await program.account.mint.createInstruction(mintKeypair.publicKey),
])
.rpc();
const mintAccount = await program.account.mint.fetch(mintKeypair.publicKey);
Expand All @@ -53,7 +53,7 @@ describe("spl-token", () => {
})
.signers([aliceTokenKeypair])
.preInstructions([
await program.account.account.createInstruction(aliceTokenKeypair),
await program.account.account.createInstruction(aliceTokenKeypair.publicKey),
])
.rpc();
const token = await program.account.account.fetch(
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("spl-token", () => {
})
.signers([bobTokenKeypair])
.preInstructions([
await program.account.account.createInstruction(bobTokenKeypair),
await program.account.account.createInstruction(bobTokenKeypair.publicKey),
])
.rpc();
});
Expand Down
2 changes: 1 addition & 1 deletion tests/errors/tests/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe("errors", () => {
},
// this initializes the account.owner variable with Pubkey::default
instructions: [
await program.account.hasOneAccount.createInstruction(account),
await program.account.hasOneAccount.createInstruction(account.publicKey),
],
signers: [account],
});
Expand Down
8 changes: 4 additions & 4 deletions tests/idl/tests/client-interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Client interactions", () => {
.int(i8, i16, i32, i64, i128)
.accounts({ account: kp.publicKey })
.signers([kp])
.preInstructions([await program.account.intAccount.createInstruction(kp)])
.preInstructions([await program.account.intAccount.createInstruction(kp.publicKey)])
.rpc();

const account = await program.account.intAccount.fetch(kp.publicKey);
Expand All @@ -46,7 +46,7 @@ describe("Client interactions", () => {
.accounts({ account: kp.publicKey })
.signers([kp])
.preInstructions([
await program.account.unsignedIntAccount.createInstruction(kp),
await program.account.unsignedIntAccount.createInstruction(kp.publicKey),
])
.rpc();

Expand All @@ -70,7 +70,7 @@ describe("Client interactions", () => {
.accounts({ account: kp.publicKey })
.signers([kp])
.preInstructions([
await program.account.enumAccount.createInstruction(kp),
await program.account.enumAccount.createInstruction(kp.publicKey),
])
.rpc();
return await program.account.enumAccount.fetch(kp.publicKey);
Expand Down Expand Up @@ -135,7 +135,7 @@ describe("Client interactions", () => {
.typeAlias(typeAliasU8, typeAliasU8Array, typeAliasStruct)
.accounts({ account: kp.publicKey })
.signers([kp])
.preInstructions([await program.account.intAccount.createInstruction(kp)])
.preInstructions([await program.account.intAccount.createInstruction(kp.publicKey)])
.rpc();

const account = await program.account.typeAliasAccount.fetch(kp.publicKey);
Expand Down
2 changes: 1 addition & 1 deletion tests/idl/tests/idl-build-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("idl-build features", () => {
.fullPath(outerMyStructArg, someModuleMyStructArg)
.accounts({ account: kp.publicKey })
.preInstructions([
await program.account.fullPathAccount.createInstruction(kp),
await program.account.fullPathAccount.createInstruction(kp.publicKey),
])
.signers([kp])
.rpc();
Expand Down
4 changes: 2 additions & 2 deletions tests/lockup/migrations/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ async function registrarInit(
},
signers: [registrar, rewardQ],
instructions: [
await registry.account.registrar.createInstruction(registrar),
await registry.account.rewardQueue.createInstruction(rewardQ, 8250),
await registry.account.registrar.createInstruction(registrar.publicKey),
await registry.account.rewardQueue.createInstruction(rewardQ.publicKey, 8250),
],
}
);
Expand Down
16 changes: 8 additions & 8 deletions tests/lockup/tests/lockup.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe("Lockup and Registry", () => {
},
signers: [vesting, vault],
instructions: [
await lockup.account.vesting.createInstruction(vesting),
await lockup.account.vesting.createInstruction(vesting.publicKey),
...(await serumCmn.createTokenAccountInstrs(
provider,
vault.publicKey,
Expand Down Expand Up @@ -323,8 +323,8 @@ describe("Lockup and Registry", () => {
},
signers: [registrar, rewardQ],
instructions: [
await registry.account.registrar.createInstruction(registrar),
await registry.account.rewardQueue.createInstruction(rewardQ, 8250),
await registry.account.registrar.createInstruction(registrar.publicKey),
await registry.account.rewardQueue.createInstruction(rewardQ.publicKey, 8250),
],
}
);
Expand Down Expand Up @@ -381,7 +381,7 @@ describe("Lockup and Registry", () => {
tokenProgram: TOKEN_PROGRAM_ID,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
instructions: [await registry.account.member.createInstruction(member)],
instructions: [await registry.account.member.createInstruction(member.publicKey)],
});

const signers = [member, provider.wallet.payer];
Expand Down Expand Up @@ -515,7 +515,7 @@ describe("Lockup and Registry", () => {
mint,
unlockedVendorSigner
)),
await registry.account.rewardVendor.createInstruction(unlockedVendor),
await registry.account.rewardVendor.createInstruction(unlockedVendor.publicKey),
],
}
);
Expand Down Expand Up @@ -634,7 +634,7 @@ describe("Lockup and Registry", () => {
mint,
lockedVendorSigner
)),
await registry.account.rewardVendor.createInstruction(lockedVendor),
await registry.account.rewardVendor.createInstruction(lockedVendor.publicKey),
],
}
);
Expand Down Expand Up @@ -721,7 +721,7 @@ describe("Lockup and Registry", () => {
remainingAccounts,
signers: [vendoredVesting, vendoredVestingVault],
instructions: [
await lockup.account.vesting.createInstruction(vendoredVesting),
await lockup.account.vesting.createInstruction(vendoredVesting.publicKey),
...(await serumCmn.createTokenAccountInstrs(
provider,
vendoredVestingVault.publicKey,
Expand Down Expand Up @@ -834,7 +834,7 @@ describe("Lockup and Registry", () => {
signers: [pendingWithdrawal],
instructions: [
await registry.account.pendingWithdrawal.createInstruction(
pendingWithdrawal
pendingWithdrawal.publicKey
),
],
});
Expand Down
14 changes: 7 additions & 7 deletions tests/misc/tests/misc/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const miscTest = (
.initialize(udata, idata)
.accounts({ data: data.publicKey })
.signers([data])
.preInstructions([await program.account.data.createInstruction(data)])
.preInstructions([await program.account.data.createInstruction(data.publicKey)])
.rpc();
const dataAccount = await program.account.data.fetch(data.publicKey);
assert(dataAccount.udata.eq(udata));
Expand Down Expand Up @@ -155,7 +155,7 @@ const miscTest = (
await program.methods
.initialize(new anchor.BN(10), new anchor.BN(10))
.accounts({ data: data.publicKey })
.preInstructions([await program.account.data.createInstruction(data)])
.preInstructions([await program.account.data.createInstruction(data.publicKey)])
.signers([data])
.rpc();

Expand Down Expand Up @@ -205,7 +205,7 @@ const miscTest = (
await program.methods
.initialize(new anchor.BN(10), new anchor.BN(10))
.accounts({ data: data.publicKey })
.preInstructions([await program.account.data.createInstruction(data)])
.preInstructions([await program.account.data.createInstruction(data.publicKey)])
.signers([data])
.rpc();

Expand Down Expand Up @@ -1342,7 +1342,7 @@ const miscTest = (
},
signers: [data],
instructions: [
await program.account.dataConstArraySize.createInstruction(data),
await program.account.dataConstArraySize.createInstruction(data.publicKey),
],
});
const dataAccount = await program.account.dataConstArraySize.fetch(
Expand All @@ -1360,7 +1360,7 @@ const miscTest = (
},
signers: [data],
instructions: [
await program.account.dataConstArraySize.createInstruction(data),
await program.account.dataConstArraySize.createInstruction(data.publicKey),
],
});
const dataAccount = await program.account.dataConstArraySize.fetch(
Expand Down Expand Up @@ -2420,7 +2420,7 @@ const miscTest = (
signers: [data],
instructions: [
await program.account.dataMultidimensionalArray.createInstruction(
data
data.publicKey
),
],
});
Expand All @@ -2440,7 +2440,7 @@ const miscTest = (
signers: [data],
instructions: [
await program.account.dataMultidimensionalArrayConstSizes.createInstruction(
data
data.publicKey
),
],
});
Expand Down
4 changes: 2 additions & 2 deletions tests/multisig/tests/multisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("multisig", () => {
},
instructions: [
await program.account.multisig.createInstruction(
multisig,
multisig.publicKey,
multisigSize
),
],
Expand Down Expand Up @@ -74,7 +74,7 @@ describe("multisig", () => {
},
instructions: [
await program.account.transaction.createInstruction(
transaction,
transaction.publicKey,
txSize
),
],
Expand Down
2 changes: 1 addition & 1 deletion tests/optional/tests/optional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("Optional", () => {
): Promise<[web3.Keypair, web3.TransactionInstruction]> => {
const keypair = requiredKeypair ?? new web3.Keypair();
const createIx = await program.account.dataAccount.createInstruction(
keypair
keypair.publicKey
);
return [keypair, createIx];
};
Expand Down
4 changes: 2 additions & 2 deletions tests/spl/token-proxy/tests/token-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async function getMintInfo(provider, mintAddr) {
async function createMint(tokenProgram) {
const mint = anchor.web3.Keypair.generate();
const authority = tokenProgram.provider.wallet.publicKey;
const createMintIx = await tokenProgram.account.mint.createInstruction(mint);
const createMintIx = await tokenProgram.account.mint.createInstruction(mint.publicKey);
const initMintIx = await tokenProgram.methods
.initializeMint2(0, authority, null)
.accounts({ mint: mint.publicKey })
Expand All @@ -284,7 +284,7 @@ async function createTokenAccount(tokenProgram, mint, owner) {
const vault = anchor.web3.Keypair.generate();
const tx = new anchor.web3.Transaction();
const createTokenAccountIx =
await tokenProgram.account.account.createInstruction(vault);
await tokenProgram.account.account.createInstruction(vault.publicKey);
const initTokenAccountIx = await tokenProgram.methods
.initializeAccount3(owner)
.accounts({ account: vault.publicKey, mint })
Expand Down
4 changes: 2 additions & 2 deletions tests/tictactoe/tests/tictactoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("tictactoe", () => {
},
signers: [dashboard],
instructions: [
await program.account.dashboard.createInstruction(dashboard),
await program.account.dashboard.createInstruction(dashboard.publicKey),
],
});

Expand All @@ -32,7 +32,7 @@ describe("tictactoe", () => {
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
signers: [game],
instructions: [await program.account.game.createInstruction(game)],
instructions: [await program.account.game.createInstruction(game.publicKey)],
});

console.log("transaction: ", tx);
Expand Down
4 changes: 2 additions & 2 deletions tests/zero-copy/tests/zero-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("zero-copy", () => {
authority: program.provider.wallet.publicKey,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
instructions: [await program.account.foo.createInstruction(foo)],
instructions: [await program.account.foo.createInstruction(foo.publicKey)],
signers: [foo],
});
const account = await program.account.foo.fetch(foo.publicKey);
Expand Down Expand Up @@ -161,7 +161,7 @@ describe("zero-copy", () => {
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
instructions: [
await program.account.eventQ.createInstruction(eventQ, size),
await program.account.eventQ.createInstruction(eventQ.publicKey, size),
],
signers: [eventQ],
});
Expand Down
8 changes: 4 additions & 4 deletions ts/tests/src/spl/binary-oracle-pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function binaryOraclePairTests() {
const poolKp = new Keypair();
poolPk = poolKp.publicKey;
const createPoolAccountIx = await program.account.pool.createInstruction(
poolKp
poolPk
);
// Accounts that are expected to be initialized
poolDepositMintPk = await createMint();
Expand All @@ -64,18 +64,18 @@ export async function binaryOraclePairTests() {
poolDepositTokenAccountPk = depositTokenAccountKp.publicKey;
const createDepositTokenAccountIx =
await tokenProgram.account.account.createInstruction(
depositTokenAccountKp
poolDepositTokenAccountPk
);

const tokenPassMintKp = new Keypair();
tokenPassMintPk = tokenPassMintKp.publicKey;
const createTokenPassMintIx =
await tokenProgram.account.mint.createInstruction(tokenPassMintKp);
await tokenProgram.account.mint.createInstruction(tokenPassMintPk);

const tokenFailMintKp = new Keypair();
tokenFailMintPk = tokenFailMintKp.publicKey;
const createTokenFailMintIx =
await tokenProgram.account.mint.createInstruction(tokenFailMintKp);
await tokenProgram.account.mint.createInstruction(tokenFailMintPk);

const [authorityPk, bump] = await PublicKey.findProgramAddress(
[poolPk.toBuffer()],
Expand Down
2 changes: 1 addition & 1 deletion ts/tests/src/spl/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function recordTests() {
const recordKp = new Keypair();
recordPk = recordKp.publicKey;
const createRecordAccountIx =
await program.account.recordData.createInstruction(recordKp);
await program.account.recordData.createInstruction(recordPk);
const initIx = await program.methods
.initialize()
.accounts({
Expand Down
Loading

0 comments on commit 0cf191d

Please sign in to comment.