fix: clean up racy tests

This commit is contained in:
Michael Vines
2020-12-24 10:43:45 -08:00
parent 87eb924d2a
commit 5ced2f75a6
9 changed files with 192 additions and 156 deletions

View File

@ -2919,7 +2919,10 @@ export class Connection {
const signData = transaction.serializeMessage(); const signData = transaction.serializeMessage();
const wireTransaction = transaction._serialize(signData); const wireTransaction = transaction._serialize(signData);
const encodedTransaction = wireTransaction.toString('base64'); const encodedTransaction = wireTransaction.toString('base64');
const config: any = {encoding: 'base64'}; const config: any = {
encoding: 'base64',
commitment: this.commitment,
};
const args = [encodedTransaction, config]; const args = [encodedTransaction, config];
if (signers) { if (signers) {

View File

@ -128,7 +128,6 @@ export class Loader {
[payer, program], [payer, program],
{ {
commitment: 'singleGossip', commitment: 'singleGossip',
skipPreflight: true,
}, },
); );
} }
@ -170,7 +169,6 @@ export class Loader {
transactions.push( transactions.push(
sendAndConfirmTransaction(connection, transaction, [payer, program], { sendAndConfirmTransaction(connection, transaction, [payer, program], {
commitment: 'singleGossip', commitment: 'singleGossip',
skipPreflight: true,
}), }),
); );
@ -211,7 +209,6 @@ export class Loader {
[payer, program], [payer, program],
{ {
commitment: 'singleGossip', commitment: 'singleGossip',
skipPreflight: true,
}, },
); );
} }

View File

@ -16,7 +16,7 @@ import {BPF_LOADER_PROGRAM_ID} from '../src/bpf-loader';
if (!mockRpcEnabled) { if (!mockRpcEnabled) {
// The default of 5 seconds is too slow for live testing sometimes // The default of 5 seconds is too slow for live testing sometimes
jest.setTimeout(120000); jest.setTimeout(240000);
} }
test('load BPF C program', async () => { test('load BPF C program', async () => {
@ -54,7 +54,7 @@ test('load BPF C program', async () => {
}); });
await sendAndConfirmTransaction(connection, transaction, [from], { await sendAndConfirmTransaction(connection, transaction, [from], {
commitment: 'singleGossip', commitment: 'singleGossip',
skipPreflight: true, preflightCommitment: 'singleGossip',
}); });
}); });
@ -67,7 +67,6 @@ describe('load BPF Rust program', () => {
const connection = new Connection(url, 'singleGossip'); const connection = new Connection(url, 'singleGossip');
let program: Account; let program: Account;
let signature: string;
let payerAccount: Account; let payerAccount: Account;
let programData: Buffer; let programData: Buffer;
@ -116,7 +115,9 @@ describe('load BPF Rust program', () => {
programData, programData,
BPF_LOADER_PROGRAM_ID, BPF_LOADER_PROGRAM_ID,
); );
});
test('get confirmed transaction', async () => {
const transaction = new Transaction().add({ const transaction = new Transaction().add({
keys: [ keys: [
{pubkey: payerAccount.publicKey, isSigner: true, isWritable: true}, {pubkey: payerAccount.publicKey, isSigner: true, isWritable: true},
@ -124,18 +125,16 @@ describe('load BPF Rust program', () => {
programId: program.publicKey, programId: program.publicKey,
}); });
signature = await sendAndConfirmTransaction( const signature = await sendAndConfirmTransaction(
connection, connection,
transaction, transaction,
[payerAccount], [payerAccount],
{ {
commitment: 'max', commitment: 'max', // `getParsedConfirmedTransaction` requires max commitment
skipPreflight: true, preflightCommitment: connection.commitment || 'max',
}, },
); );
});
test('get confirmed transaction', async () => {
const parsedTx = await connection.getParsedConfirmedTransaction(signature); const parsedTx = await connection.getParsedConfirmedTransaction(signature);
if (parsedTx === null) { if (parsedTx === null) {
expect(parsedTx).not.toBeNull(); expect(parsedTx).not.toBeNull();

View File

@ -26,7 +26,7 @@ import {mockConfirmTransaction} from './mockrpc/confirm-transaction';
import {mockRpcSocket} from './__mocks__/rpc-websockets'; import {mockRpcSocket} from './__mocks__/rpc-websockets';
// Testing tokens and blockhash cache each take around 30s to complete // Testing tokens and blockhash cache each take around 30s to complete
jest.setTimeout(40000); jest.setTimeout(90000);
const errorMessage = 'Invalid'; const errorMessage = 'Invalid';
const errorResponse = { const errorResponse = {
@ -91,7 +91,7 @@ test('get account info - not found', async () => {
}); });
test('get program accounts', async () => { test('get program accounts', async () => {
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const account0 = new Account(); const account0 = new Account();
const account1 = new Account(); const account1 = new Account();
const programId = new Account(); const programId = new Account();
@ -107,6 +107,15 @@ test('get program accounts', async () => {
'2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
mockConfirmTransaction(
'2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
);
let signature = await connection.requestAirdrop(
account0.publicKey,
LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(signature);
mockRpc.push([ mockRpc.push([
url, url,
{ {
@ -119,8 +128,14 @@ test('get program accounts', async () => {
'2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
await connection.requestAirdrop(account0.publicKey, LAMPORTS_PER_SOL); mockConfirmTransaction(
await connection.requestAirdrop(account1.publicKey, 0.5 * LAMPORTS_PER_SOL); '2WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
);
signature = await connection.requestAirdrop(
account1.publicKey,
0.5 * LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(signature);
mockGetRecentBlockhash('max'); mockGetRecentBlockhash('max');
mockRpc.push([ mockRpc.push([
@ -146,8 +161,7 @@ test('get program accounts', async () => {
'3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
); );
await sendAndConfirmTransaction(connection, transaction, [account0], { await sendAndConfirmTransaction(connection, transaction, [account0], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
mockRpc.push([ mockRpc.push([
@ -173,15 +187,14 @@ test('get program accounts', async () => {
'3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '3WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
); );
await sendAndConfirmTransaction(connection, transaction, [account1], { await sendAndConfirmTransaction(connection, transaction, [account1], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getFeeCalculatorForBlockhash', method: 'getFeeCalculatorForBlockhash',
params: [transaction.recentBlockhash, {commitment: 'recent'}], params: [transaction.recentBlockhash, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -218,7 +231,7 @@ test('get program accounts', async () => {
method: 'getProgramAccounts', method: 'getProgramAccounts',
params: [ params: [
programId.publicKey.toBase58(), programId.publicKey.toBase58(),
{commitment: 'recent', encoding: 'base64'}, {commitment: 'singleGossip', encoding: 'base64'},
], ],
}, },
{ {
@ -372,13 +385,13 @@ test('get inflation', async () => {
}); });
test('get epoch info', async () => { test('get epoch info', async () => {
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getEpochInfo', method: 'getEpochInfo',
params: [{commitment: 'recent'}], params: [{commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -1246,7 +1259,7 @@ test('get recent blockhash', async () => {
const connection = new Connection(url); const connection = new Connection(url);
for (const commitment of [ for (const commitment of [
'max', 'max',
'recent', 'singleGossip',
'root', 'root',
'single', 'single',
'singleGossip', 'singleGossip',
@ -1264,14 +1277,14 @@ test('get recent blockhash', async () => {
test('get fee calculator', async () => { test('get fee calculator', async () => {
const connection = new Connection(url); const connection = new Connection(url);
mockGetRecentBlockhash('recent'); mockGetRecentBlockhash('singleGossip');
const {blockhash} = await connection.getRecentBlockhash('recent'); const {blockhash} = await connection.getRecentBlockhash('singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getFeeCalculatorForBlockhash', method: 'getFeeCalculatorForBlockhash',
params: [blockhash, {commitment: 'recent'}], params: [blockhash, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -1289,7 +1302,7 @@ test('get fee calculator', async () => {
]); ]);
const feeCalculator = ( const feeCalculator = (
await connection.getFeeCalculatorForBlockhash(blockhash, 'recent') await connection.getFeeCalculatorForBlockhash(blockhash, 'singleGossip')
).value; ).value;
if (feeCalculator === null) { if (feeCalculator === null) {
expect(feeCalculator).not.toBeNull(); expect(feeCalculator).not.toBeNull();
@ -1462,7 +1475,7 @@ describe('token methods', () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const newAccount = new Account().publicKey; const newAccount = new Account().publicKey;
let testToken: Token; let testToken: Token;
@ -1721,17 +1734,20 @@ test('stake activation should return activating for new accounts', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const voteAccounts = await connection.getVoteAccounts(); const voteAccounts = await connection.getVoteAccounts();
const voteAccount = voteAccounts.current.concat(voteAccounts.delinquent)[0]; const voteAccount = voteAccounts.current.concat(voteAccounts.delinquent)[0];
const votePubkey = new PublicKey(voteAccount.votePubkey); const votePubkey = new PublicKey(voteAccount.votePubkey);
const authorized = new Account(); const authorized = new Account();
await connection.requestAirdrop(authorized.publicKey, 2 * LAMPORTS_PER_SOL); let signature = await connection.requestAirdrop(
authorized.publicKey,
2 * LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(signature);
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
StakeProgram.space, StakeProgram.space,
'recent',
); );
const newStakeAccount = new Account(); const newStakeAccount = new Account();
@ -1747,7 +1763,9 @@ test('stake activation should return activating for new accounts', async () => {
connection, connection,
createAndInitialize, createAndInitialize,
[authorized, newStakeAccount], [authorized, newStakeAccount],
{commitment: 'single', skipPreflight: true}, {
commitment: 'singleGossip',
},
); );
let delegation = StakeProgram.delegate({ let delegation = StakeProgram.delegate({
stakePubkey: newStakeAccount.publicKey, stakePubkey: newStakeAccount.publicKey,
@ -1755,15 +1773,14 @@ test('stake activation should return activating for new accounts', async () => {
votePubkey, votePubkey,
}); });
await sendAndConfirmTransaction(connection, delegation, [authorized], { await sendAndConfirmTransaction(connection, delegation, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
const LARGE_EPOCH = 4000; const LARGE_EPOCH = 4000;
await expect( await expect(
connection.getStakeActivation( connection.getStakeActivation(
newStakeAccount.publicKey, newStakeAccount.publicKey,
'recent', 'singleGossip',
LARGE_EPOCH, LARGE_EPOCH,
), ),
).rejects.toThrow( ).rejects.toThrow(
@ -1784,7 +1801,7 @@ test('stake activation should only accept state with valid string literals', asy
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const publicKey = new Account().publicKey; const publicKey = new Account().publicKey;
const addStakeActivationMock = state => { const addStakeActivationMock = state => {
@ -1836,13 +1853,13 @@ test('getVersion', async () => {
test('request airdrop', async () => { test('request airdrop', async () => {
const account = new Account(); const account = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [0, {commitment: 'recent'}], params: [0, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -1852,7 +1869,7 @@ test('request airdrop', async () => {
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
0, 0,
'recent', 'singleGossip',
); );
mockRpc.push([ mockRpc.push([
@ -1874,13 +1891,13 @@ test('request airdrop', async () => {
); );
mockConfirmTransaction(signature); mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature);
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [account.publicKey.toBase58(), {commitment: 'recent'}], params: [account.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -1902,7 +1919,7 @@ test('request airdrop', async () => {
method: 'getAccountInfo', method: 'getAccountInfo',
params: [ params: [
account.publicKey.toBase58(), account.publicKey.toBase58(),
{commitment: 'recent', encoding: 'base64'}, {commitment: 'singleGossip', encoding: 'base64'},
], ],
}, },
{ {
@ -1936,7 +1953,7 @@ test('request airdrop', async () => {
method: 'getAccountInfo', method: 'getAccountInfo',
params: [ params: [
account.publicKey.toBase58(), account.publicKey.toBase58(),
{commitment: 'recent', encoding: 'jsonParsed'}, {commitment: 'singleGossip', encoding: 'jsonParsed'},
], ],
}, },
{ {
@ -1972,13 +1989,13 @@ test('request airdrop', async () => {
test('transaction failure', async () => { test('transaction failure', async () => {
const account = new Account(); const account = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [0, {commitment: 'recent'}], params: [0, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -1988,7 +2005,7 @@ test('transaction failure', async () => {
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
0, 0,
'recent', 'singleGossip',
); );
mockRpc.push([ mockRpc.push([
@ -2009,13 +2026,13 @@ test('transaction failure', async () => {
); );
mockConfirmTransaction(airdropSignature); mockConfirmTransaction(airdropSignature);
await connection.confirmTransaction(airdropSignature, 'single'); await connection.confirmTransaction(airdropSignature);
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [account.publicKey.toBase58(), {commitment: 'recent'}], params: [account.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2062,7 +2079,7 @@ test('transaction failure', async () => {
connection, connection,
transaction, transaction,
[account, newAccount], [account, newAccount],
{commitment: 'single', skipPreflight: true}, {commitment: 'singleGossip'},
); );
mockRpc.push([ mockRpc.push([
@ -2097,7 +2114,7 @@ test('transaction failure', async () => {
mockRpcSocket.push([ mockRpcSocket.push([
{ {
method: 'signatureSubscribe', method: 'signatureSubscribe',
params: [signature, {commitment: 'single'}], params: [signature, {commitment: 'singleGossip'}],
}, },
{ {
context: { context: {
@ -2109,7 +2126,7 @@ test('transaction failure', async () => {
// Wait for one confirmation // Wait for one confirmation
const confirmResult = ( const confirmResult = (
await connection.confirmTransaction(signature, 'single') await connection.confirmTransaction(signature, 'singleGossip')
).value; ).value;
expect(confirmResult.err).toEqual(expectedErr); expect(confirmResult.err).toEqual(expectedErr);
@ -2148,13 +2165,13 @@ test('transaction failure', async () => {
test('transaction', async () => { test('transaction', async () => {
const accountFrom = new Account(); const accountFrom = new Account();
const accountTo = new Account(); const accountTo = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [0, {commitment: 'recent'}], params: [0, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2164,7 +2181,7 @@ test('transaction', async () => {
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
0, 0,
'recent', 'singleGossip',
); );
mockRpc.push([ mockRpc.push([
@ -2185,13 +2202,13 @@ test('transaction', async () => {
); );
mockConfirmTransaction(airdropFromSig); mockConfirmTransaction(airdropFromSig);
await connection.confirmTransaction(airdropFromSig, 'single'); await connection.confirmTransaction(airdropFromSig);
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountFrom.publicKey.toBase58(), {commitment: 'recent'}], params: [accountFrom.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2226,13 +2243,13 @@ test('transaction', async () => {
); );
mockConfirmTransaction(airdropToSig); mockConfirmTransaction(airdropToSig);
await connection.confirmTransaction(airdropToSig, 'single'); await connection.confirmTransaction(airdropToSig);
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountTo.publicKey.toBase58(), {commitment: 'recent'}], params: [accountTo.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2274,8 +2291,9 @@ test('transaction', async () => {
); );
mockConfirmTransaction(signature); mockConfirmTransaction(signature);
let confirmResult = (await connection.confirmTransaction(signature, 'single')) let confirmResult = (
.value; await connection.confirmTransaction(signature, 'singleGossip')
).value;
expect(confirmResult.err).toBeNull(); expect(confirmResult.err).toBeNull();
mockGetRecentBlockhash('max'); mockGetRecentBlockhash('max');
@ -2309,7 +2327,7 @@ test('transaction', async () => {
expect(transaction.recentBlockhash).not.toEqual(transaction2.recentBlockhash); expect(transaction.recentBlockhash).not.toEqual(transaction2.recentBlockhash);
mockConfirmTransaction(signature2); mockConfirmTransaction(signature2);
await connection.confirmTransaction(signature2, 'single'); await connection.confirmTransaction(signature2, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -2341,7 +2359,7 @@ test('transaction', async () => {
expect(transaction2.recentBlockhash).toEqual(transaction3.recentBlockhash); expect(transaction2.recentBlockhash).toEqual(transaction3.recentBlockhash);
mockConfirmTransaction(signature3); mockConfirmTransaction(signature3);
await connection.confirmTransaction(signature3, 'single'); await connection.confirmTransaction(signature3, 'singleGossip');
// Sleep until blockhash cache times out // Sleep until blockhash cache times out
await sleep( await sleep(
@ -2377,7 +2395,7 @@ test('transaction', async () => {
}, },
); );
mockConfirmTransaction(signature4); mockConfirmTransaction(signature4);
await connection.confirmTransaction(signature4, 'single'); await connection.confirmTransaction(signature4, 'singleGossip');
expect(transaction4.recentBlockhash).not.toEqual( expect(transaction4.recentBlockhash).not.toEqual(
transaction3.recentBlockhash, transaction3.recentBlockhash,
@ -2387,7 +2405,7 @@ test('transaction', async () => {
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountFrom.publicKey.toBase58(), {commitment: 'recent'}], params: [accountFrom.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2409,7 +2427,7 @@ test('transaction', async () => {
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountTo.publicKey.toBase58(), {commitment: 'recent'}], params: [accountTo.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -2434,27 +2452,27 @@ test('multi-instruction transaction', async () => {
const accountFrom = new Account(); const accountFrom = new Account();
const accountTo = new Account(); const accountTo = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
let signature = await connection.requestAirdrop( let signature = await connection.requestAirdrop(
accountFrom.publicKey, accountFrom.publicKey,
LAMPORTS_PER_SOL, LAMPORTS_PER_SOL,
); );
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature, 'singleGossip');
expect(await connection.getBalance(accountFrom.publicKey)).toBe( expect(await connection.getBalance(accountFrom.publicKey)).toBe(
LAMPORTS_PER_SOL, LAMPORTS_PER_SOL,
); );
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
0, 0,
'recent', 'singleGossip',
); );
signature = await connection.requestAirdrop( signature = await connection.requestAirdrop(
accountTo.publicKey, accountTo.publicKey,
minimumAmount + 21, minimumAmount + 21,
); );
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature);
expect(await connection.getBalance(accountTo.publicKey)).toBe( expect(await connection.getBalance(accountTo.publicKey)).toBe(
minimumAmount + 21, minimumAmount + 21,
); );
@ -2482,7 +2500,7 @@ test('multi-instruction transaction', async () => {
{skipPreflight: true}, {skipPreflight: true},
); );
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature, 'singleGossip');
const response = (await connection.getSignatureStatus(signature)).value; const response = (await connection.getSignatureStatus(signature)).value;
if (response !== null) { if (response !== null) {
@ -2509,7 +2527,7 @@ test('account change notification', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const owner = new Account(); const owner = new Account();
const programAccount = new Account(); const programAccount = new Account();
@ -2518,7 +2536,7 @@ test('account change notification', async () => {
const subscriptionId = connection.onAccountChange( const subscriptionId = connection.onAccountChange(
programAccount.publicKey, programAccount.publicKey,
mockCallback, mockCallback,
'recent', 'singleGossip',
); );
const balanceNeeded = Math.max( const balanceNeeded = Math.max(
@ -2526,7 +2544,11 @@ test('account change notification', async () => {
1, 1,
); );
await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL); let signature = await connection.requestAirdrop(
owner.publicKey,
LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(signature);
try { try {
const transaction = new Transaction().add( const transaction = new Transaction().add(
SystemProgram.transfer({ SystemProgram.transfer({
@ -2536,8 +2558,7 @@ test('account change notification', async () => {
}), }),
); );
await sendAndConfirmTransaction(connection, transaction, [owner], { await sendAndConfirmTransaction(connection, transaction, [owner], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
} catch (err) { } catch (err) {
await connection.removeAccountChangeListener(subscriptionId); await connection.removeAccountChangeListener(subscriptionId);
@ -2571,7 +2592,7 @@ test('program account change notification', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const owner = new Account(); const owner = new Account();
const programAccount = new Account(); const programAccount = new Account();
@ -2595,7 +2616,11 @@ test('program account change notification', async () => {
}, },
); );
await connection.requestAirdrop(owner.publicKey, LAMPORTS_PER_SOL); let signature = await connection.requestAirdrop(
owner.publicKey,
LAMPORTS_PER_SOL,
);
await connection.confirmTransaction(signature);
try { try {
const transaction = new Transaction().add( const transaction = new Transaction().add(
SystemProgram.transfer({ SystemProgram.transfer({
@ -2605,8 +2630,7 @@ test('program account change notification', async () => {
}), }),
); );
await sendAndConfirmTransaction(connection, transaction, [owner], { await sendAndConfirmTransaction(connection, transaction, [owner], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
} catch (err) { } catch (err) {
await connection.removeProgramAccountChangeListener(subscriptionId); await connection.removeProgramAccountChangeListener(subscriptionId);
@ -2634,7 +2658,7 @@ test('slot notification', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
let notified = false; let notified = false;
const subscriptionId = connection.onSlotChange(slotInfo => { const subscriptionId = connection.onSlotChange(slotInfo => {
@ -2666,7 +2690,7 @@ test('root notification', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
let roots = []; let roots = [];
const subscriptionId = connection.onRootChange(root => { const subscriptionId = connection.onRootChange(root => {

View File

@ -7,7 +7,7 @@ export function mockConfirmTransaction(signature: TransactionSignature) {
mockRpcSocket.push([ mockRpcSocket.push([
{ {
method: 'signatureSubscribe', method: 'signatureSubscribe',
params: [signature, {commitment: 'single'}], params: [signature, {commitment: 'singleGossip'}],
}, },
{ {
context: { context: {

View File

@ -34,13 +34,13 @@ const expectedData = (authorizedPubkey: PublicKey): [string, string] => {
test('create and query nonce account', async () => { test('create and query nonce account', async () => {
const from = new Account(); const from = new Account();
const nonceAccount = new Account(); const nonceAccount = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [NONCE_ACCOUNT_LENGTH, {commitment: 'recent'}], params: [NONCE_ACCOUNT_LENGTH, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -70,13 +70,13 @@ test('create and query nonce account', async () => {
minimumAmount * 2, minimumAmount * 2,
); );
mockConfirmTransaction(signature); mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [from.publicKey.toBase58(), {commitment: 'recent'}], params: [from.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -121,7 +121,7 @@ test('create and query nonce account', async () => {
}, },
); );
mockConfirmTransaction(nonceSignature); mockConfirmTransaction(nonceSignature);
await connection.confirmTransaction(nonceSignature, 'single'); await connection.confirmTransaction(nonceSignature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -129,7 +129,7 @@ test('create and query nonce account', async () => {
method: 'getAccountInfo', method: 'getAccountInfo',
params: [ params: [
nonceAccount.publicKey.toBase58(), nonceAccount.publicKey.toBase58(),
{encoding: 'base64', commitment: 'recent'}, {encoding: 'base64', commitment: 'singleGossip'},
], ],
}, },
{ {
@ -165,13 +165,13 @@ test('create and query nonce account with seed', async () => {
seed, seed,
SystemProgram.programId, SystemProgram.programId,
); );
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [NONCE_ACCOUNT_LENGTH, {commitment: 'recent'}], params: [NONCE_ACCOUNT_LENGTH, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -201,13 +201,13 @@ test('create and query nonce account with seed', async () => {
minimumAmount * 2, minimumAmount * 2,
); );
mockConfirmTransaction(signature); mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [from.publicKey.toBase58(), {commitment: 'recent'}], params: [from.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -250,7 +250,7 @@ test('create and query nonce account with seed', async () => {
skipPreflight: true, skipPreflight: true,
}); });
mockConfirmTransaction(nonceSignature); mockConfirmTransaction(nonceSignature);
await connection.confirmTransaction(nonceSignature, 'single'); await connection.confirmTransaction(nonceSignature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -258,7 +258,7 @@ test('create and query nonce account with seed', async () => {
method: 'getAccountInfo', method: 'getAccountInfo',
params: [ params: [
noncePubkey.toBase58(), noncePubkey.toBase58(),
{encoding: 'base64', commitment: 'recent'}, {encoding: 'base64', commitment: 'singleGossip'},
], ],
}, },
{ {

View File

@ -15,11 +15,12 @@ import {
Transaction, Transaction,
} from '../src'; } from '../src';
import {mockRpcEnabled} from './__mocks__/node-fetch'; import {mockRpcEnabled} from './__mocks__/node-fetch';
import {newAccountWithLamports} from './new-account-with-lamports';
import {url} from './url'; import {url} from './url';
if (!mockRpcEnabled) { if (!mockRpcEnabled) {
// Testing max commitment level takes around 20s to complete // Testing max commitment level takes around 20s to complete
jest.setTimeout(30000); jest.setTimeout(60000);
} }
test('createAccountWithSeed', async () => { test('createAccountWithSeed', async () => {
@ -265,19 +266,26 @@ test('live staking actions', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const voteAccounts = await connection.getVoteAccounts(); const voteAccounts = await connection.getVoteAccounts();
const voteAccount = voteAccounts.current.concat(voteAccounts.delinquent)[0]; const voteAccount = voteAccounts.current.concat(voteAccounts.delinquent)[0];
const votePubkey = new PublicKey(voteAccount.votePubkey); const votePubkey = new PublicKey(voteAccount.votePubkey);
const from = new Account(); const from = await newAccountWithLamports(connection, 2 * LAMPORTS_PER_SOL);
const authorized = new Account(); const authorized = await newAccountWithLamports(
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL); connection,
await connection.requestAirdrop(authorized.publicKey, 2 * LAMPORTS_PER_SOL); 2 * LAMPORTS_PER_SOL,
);
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
StakeProgram.space, StakeProgram.space,
'recent', );
expect(await connection.getBalance(from.publicKey)).toEqual(
2 * LAMPORTS_PER_SOL,
);
expect(await connection.getBalance(authorized.publicKey)).toEqual(
2 * LAMPORTS_PER_SOL,
); );
{ {
@ -295,7 +303,7 @@ test('live staking actions', async () => {
connection, connection,
createAndInitialize, createAndInitialize,
[from, newStakeAccount], [from, newStakeAccount],
{commitment: 'single', skipPreflight: true}, {commitment: 'singleGossip'},
); );
expect(await connection.getBalance(newStakeAccount.publicKey)).toEqual( expect(await connection.getBalance(newStakeAccount.publicKey)).toEqual(
minimumAmount + 42, minimumAmount + 42,
@ -307,8 +315,7 @@ test('live staking actions', async () => {
votePubkey, votePubkey,
}); });
await sendAndConfirmTransaction(connection, delegation, [authorized], { await sendAndConfirmTransaction(connection, delegation, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
} }
@ -334,7 +341,7 @@ test('live staking actions', async () => {
connection, connection,
createAndInitializeWithSeed, createAndInitializeWithSeed,
[from], [from],
{commitment: 'single', skipPreflight: true}, {commitment: 'singleGossip'},
); );
let originalStakeBalance = await connection.getBalance(newAccountPubkey); let originalStakeBalance = await connection.getBalance(newAccountPubkey);
expect(originalStakeBalance).toEqual(3 * minimumAmount + 42); expect(originalStakeBalance).toEqual(3 * minimumAmount + 42);
@ -345,8 +352,7 @@ test('live staking actions', async () => {
votePubkey, votePubkey,
}); });
await sendAndConfirmTransaction(connection, delegation, [authorized], { await sendAndConfirmTransaction(connection, delegation, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
// Test that withdraw fails before deactivation // Test that withdraw fails before deactivation
@ -359,8 +365,7 @@ test('live staking actions', async () => {
}); });
await expect( await expect(
sendAndConfirmTransaction(connection, withdraw, [authorized], { sendAndConfirmTransaction(connection, withdraw, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}), }),
).rejects.toThrow(); ).rejects.toThrow();
@ -373,8 +378,7 @@ test('live staking actions', async () => {
lamports: minimumAmount + 20, lamports: minimumAmount + 20,
}); });
await sendAndConfirmTransaction(connection, split, [authorized, newStake], { await sendAndConfirmTransaction(connection, split, [authorized, newStake], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
// Authorize to new account // Authorize to new account
@ -388,8 +392,7 @@ test('live staking actions', async () => {
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer, stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
}); });
await sendAndConfirmTransaction(connection, authorize, [authorized], { await sendAndConfirmTransaction(connection, authorize, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
authorize = StakeProgram.authorize({ authorize = StakeProgram.authorize({
stakePubkey: newAccountPubkey, stakePubkey: newAccountPubkey,
@ -398,8 +401,7 @@ test('live staking actions', async () => {
stakeAuthorizationType: StakeAuthorizationLayout.Staker, stakeAuthorizationType: StakeAuthorizationLayout.Staker,
}); });
await sendAndConfirmTransaction(connection, authorize, [authorized], { await sendAndConfirmTransaction(connection, authorize, [authorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
// Test old authorized can't deactivate // Test old authorized can't deactivate
@ -412,7 +414,7 @@ test('live staking actions', async () => {
connection, connection,
deactivateNotAuthorized, deactivateNotAuthorized,
[authorized], [authorized],
{commitment: 'single', skipPreflight: true}, {commitment: 'singleGossip', skipPreflight: true},
), ),
).rejects.toThrow(); ).rejects.toThrow();
@ -422,8 +424,7 @@ test('live staking actions', async () => {
authorizedPubkey: newAuthorized.publicKey, authorizedPubkey: newAuthorized.publicKey,
}); });
await sendAndConfirmTransaction(connection, deactivate, [newAuthorized], { await sendAndConfirmTransaction(connection, deactivate, [newAuthorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
// Test that withdraw succeeds after deactivation // Test that withdraw succeeds after deactivation
@ -433,9 +434,9 @@ test('live staking actions', async () => {
toPubkey: recipient.publicKey, toPubkey: recipient.publicKey,
lamports: minimumAmount + 20, lamports: minimumAmount + 20,
}); });
await sendAndConfirmTransaction(connection, withdraw, [newAuthorized], { await sendAndConfirmTransaction(connection, withdraw, [newAuthorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
const balance = await connection.getBalance(newAccountPubkey); const balance = await connection.getBalance(newAccountPubkey);
expect(balance).toEqual(minimumAmount + 2); expect(balance).toEqual(minimumAmount + 2);
@ -450,11 +451,10 @@ test('live staking actions', async () => {
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer, stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
}); });
await sendAndConfirmTransaction(connection, authorize, [newAuthorized], { await sendAndConfirmTransaction(connection, authorize, [newAuthorized], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
// Restore the previous authority using a dervied address // Restore the previous authority using a derived address
authorize = StakeProgram.authorizeWithSeed({ authorize = StakeProgram.authorizeWithSeed({
stakePubkey: newAccountPubkey, stakePubkey: newAccountPubkey,
authorityBase: from.publicKey, authorityBase: from.publicKey,
@ -464,7 +464,6 @@ test('live staking actions', async () => {
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer, stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
}); });
await sendAndConfirmTransaction(connection, authorize, [from], { await sendAndConfirmTransaction(connection, authorize, [from], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true,
}); });
}); });

View File

@ -13,6 +13,7 @@ import {
} from '../src'; } from '../src';
import {NONCE_ACCOUNT_LENGTH} from '../src/nonce-account'; import {NONCE_ACCOUNT_LENGTH} from '../src/nonce-account';
import {mockRpcEnabled} from './__mocks__/node-fetch'; import {mockRpcEnabled} from './__mocks__/node-fetch';
import {newAccountWithLamports} from './new-account-with-lamports';
import {sleep} from '../src/util/sleep'; import {sleep} from '../src/util/sleep';
import {url} from './url'; import {url} from './url';
@ -277,19 +278,17 @@ test('live Nonce actions', async () => {
return; return;
} }
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
const nonceAccount = new Account(); const nonceAccount = new Account();
const from = new Account(); const from = await newAccountWithLamports(connection, 2 * LAMPORTS_PER_SOL);
const to = new Account(); const to = new Account();
const authority = new Account(); const newAuthority = await newAccountWithLamports(
const newAuthority = new Account(); connection,
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL); LAMPORTS_PER_SOL,
await connection.requestAirdrop(authority.publicKey, LAMPORTS_PER_SOL); );
await connection.requestAirdrop(newAuthority.publicKey, LAMPORTS_PER_SOL);
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
NONCE_ACCOUNT_LENGTH, NONCE_ACCOUNT_LENGTH,
'recent',
); );
let createNonceAccount = new Transaction().add( let createNonceAccount = new Transaction().add(
@ -304,7 +303,7 @@ test('live Nonce actions', async () => {
connection, connection,
createNonceAccount, createNonceAccount,
[from, nonceAccount], [from, nonceAccount],
{commitment: 'single', skipPreflight: true}, {commitment: 'singleGossip', preflightCommitment: 'singleGossip'},
); );
const nonceBalance = await connection.getBalance(nonceAccount.publicKey); const nonceBalance = await connection.getBalance(nonceAccount.publicKey);
expect(nonceBalance).toEqual(minimumAmount); expect(nonceBalance).toEqual(minimumAmount);
@ -333,8 +332,8 @@ test('live Nonce actions', async () => {
}), }),
); );
await sendAndConfirmTransaction(connection, advanceNonce, [from], { await sendAndConfirmTransaction(connection, advanceNonce, [from], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true, preflightCommitment: 'singleGossip',
}); });
const nonceQuery3 = await connection.getNonce(nonceAccount.publicKey); const nonceQuery3 = await connection.getNonce(nonceAccount.publicKey);
if (nonceQuery3 === null) { if (nonceQuery3 === null) {
@ -355,8 +354,8 @@ test('live Nonce actions', async () => {
}), }),
); );
await sendAndConfirmTransaction(connection, authorizeNonce, [from], { await sendAndConfirmTransaction(connection, authorizeNonce, [from], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true, preflightCommitment: 'singleGossip',
}); });
let transfer = new Transaction().add( let transfer = new Transaction().add(
@ -375,8 +374,8 @@ test('live Nonce actions', async () => {
}; };
await sendAndConfirmTransaction(connection, transfer, [from, newAuthority], { await sendAndConfirmTransaction(connection, transfer, [from, newAuthority], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true, preflightCommitment: 'singleGossip',
}); });
const toBalance = await connection.getBalance(to.publicKey); const toBalance = await connection.getBalance(to.publicKey);
expect(toBalance).toEqual(minimumAmount); expect(toBalance).toEqual(minimumAmount);
@ -394,8 +393,8 @@ test('live Nonce actions', async () => {
}), }),
); );
await sendAndConfirmTransaction(connection, withdrawNonce, [newAuthority], { await sendAndConfirmTransaction(connection, withdrawNonce, [newAuthority], {
commitment: 'single', commitment: 'singleGossip',
skipPreflight: true, preflightCommitment: 'singleGossip',
}); });
expect(await connection.getBalance(nonceAccount.publicKey)).toEqual(0); expect(await connection.getBalance(nonceAccount.publicKey)).toEqual(0);
const withdrawBalance = await connection.getBalance( const withdrawBalance = await connection.getBalance(

View File

@ -20,13 +20,13 @@ test('transaction-payer', async () => {
const accountPayer = new Account(); const accountPayer = new Account();
const accountFrom = new Account(); const accountFrom = new Account();
const accountTo = new Account(); const accountTo = new Account();
const connection = new Connection(url, 'recent'); const connection = new Connection(url, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
{ {
method: 'getMinimumBalanceForRentExemption', method: 'getMinimumBalanceForRentExemption',
params: [0, {commitment: 'recent'}], params: [0, {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -36,7 +36,7 @@ test('transaction-payer', async () => {
const minimumAmount = await connection.getMinimumBalanceForRentExemption( const minimumAmount = await connection.getMinimumBalanceForRentExemption(
0, 0,
'recent', 'singleGossip',
); );
mockRpc.push([ mockRpc.push([
@ -48,10 +48,15 @@ test('transaction-payer', async () => {
{ {
error: null, error: null,
result: result:
'0WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '8WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
await connection.requestAirdrop(accountPayer.publicKey, LAMPORTS_PER_SOL); let signature = await connection.requestAirdrop(
accountPayer.publicKey,
LAMPORTS_PER_SOL,
);
mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -62,10 +67,15 @@ test('transaction-payer', async () => {
{ {
error: null, error: null,
result: result:
'0WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '8WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
await connection.requestAirdrop(accountFrom.publicKey, minimumAmount + 12); signature = await connection.requestAirdrop(
accountFrom.publicKey,
minimumAmount + 12,
);
mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -79,7 +89,12 @@ test('transaction-payer', async () => {
'8WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk', '8WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk',
}, },
]); ]);
await connection.requestAirdrop(accountTo.publicKey, minimumAmount + 21); signature = await connection.requestAirdrop(
accountTo.publicKey,
minimumAmount + 21,
);
mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'singleGossip');
mockGetRecentBlockhash('max'); mockGetRecentBlockhash('max');
mockRpc.push([ mockRpc.push([
@ -102,14 +117,14 @@ test('transaction-payer', async () => {
}), }),
); );
const signature = await connection.sendTransaction( signature = await connection.sendTransaction(
transaction, transaction,
[accountPayer, accountFrom], [accountPayer, accountFrom],
{skipPreflight: true}, {skipPreflight: true},
); );
mockConfirmTransaction(signature); mockConfirmTransaction(signature);
await connection.confirmTransaction(signature, 'single'); await connection.confirmTransaction(signature, 'singleGossip');
mockRpc.push([ mockRpc.push([
url, url,
@ -150,7 +165,7 @@ test('transaction-payer', async () => {
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountPayer.publicKey.toBase58(), {commitment: 'recent'}], params: [accountPayer.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,
@ -174,7 +189,7 @@ test('transaction-payer', async () => {
url, url,
{ {
method: 'getBalance', method: 'getBalance',
params: [accountFrom.publicKey.toBase58(), {commitment: 'recent'}], params: [accountFrom.publicKey.toBase58(), {commitment: 'singleGossip'}],
}, },
{ {
error: null, error: null,