Skip to content

Commit

Permalink
fix: clean up racy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Dec 24, 2020
1 parent fdbf9d0 commit 9108edc
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 156 deletions.
5 changes: 4 additions & 1 deletion src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2919,7 +2919,10 @@ export class Connection {
const signData = transaction.serializeMessage();
const wireTransaction = transaction._serialize(signData);
const encodedTransaction = wireTransaction.toString('base64');
const config: any = {encoding: 'base64'};
const config: any = {
encoding: 'base64',
commitment: this.commitment,
};
const args = [encodedTransaction, config];

if (signers) {
Expand Down
3 changes: 0 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class Loader {
[payer, program],
{
commitment: 'singleGossip',
skipPreflight: true,
},
);
}
Expand Down Expand Up @@ -170,7 +169,6 @@ export class Loader {
transactions.push(
sendAndConfirmTransaction(connection, transaction, [payer, program], {
commitment: 'singleGossip',
skipPreflight: true,
}),
);

Expand Down Expand Up @@ -211,7 +209,6 @@ export class Loader {
[payer, program],
{
commitment: 'singleGossip',
skipPreflight: true,
},
);
}
Expand Down
15 changes: 7 additions & 8 deletions test/bpf-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {BPF_LOADER_PROGRAM_ID} from '../src/bpf-loader';

if (!mockRpcEnabled) {
// The default of 5 seconds is too slow for live testing sometimes
jest.setTimeout(120000);
jest.setTimeout(240000);
}

test('load BPF C program', async () => {
Expand Down Expand Up @@ -54,7 +54,7 @@ test('load BPF C program', async () => {
});
await sendAndConfirmTransaction(connection, transaction, [from], {
commitment: 'singleGossip',
skipPreflight: true,
preflightCommitment: 'singleGossip',
});
});

Expand All @@ -67,7 +67,6 @@ describe('load BPF Rust program', () => {
const connection = new Connection(url, 'singleGossip');

let program: Account;
let signature: string;
let payerAccount: Account;
let programData: Buffer;

Expand Down Expand Up @@ -116,26 +115,26 @@ describe('load BPF Rust program', () => {
programData,
BPF_LOADER_PROGRAM_ID,
);
});

test('get confirmed transaction', async () => {
const transaction = new Transaction().add({
keys: [
{pubkey: payerAccount.publicKey, isSigner: true, isWritable: true},
],
programId: program.publicKey,
});

signature = await sendAndConfirmTransaction(
const signature = await sendAndConfirmTransaction(
connection,
transaction,
[payerAccount],
{
commitment: 'max',
skipPreflight: true,
commitment: 'max', // `getParsedConfirmedTransaction` requires max commitment
preflightCommitment: connection.commitment || 'max',
},
);
});

test('get confirmed transaction', async () => {
const parsedTx = await connection.getParsedConfirmedTransaction(signature);
if (parsedTx === null) {
expect(parsedTx).not.toBeNull();
Expand Down

0 comments on commit 9108edc

Please sign in to comment.