fix: default preflightCommitment to Connection.commitment when sending tx (#15299)
This commit is contained in:
parent
08f94a2bd2
commit
b09865e5a0
|
@ -3034,7 +3034,8 @@ export class Connection {
|
||||||
const config: any = {encoding: 'base64'};
|
const config: any = {encoding: 'base64'};
|
||||||
const args = [encodedTransaction, config];
|
const args = [encodedTransaction, config];
|
||||||
const skipPreflight = options && options.skipPreflight;
|
const skipPreflight = options && options.skipPreflight;
|
||||||
const preflightCommitment = options && options.preflightCommitment;
|
const preflightCommitment =
|
||||||
|
(options && options.preflightCommitment) || this.commitment;
|
||||||
|
|
||||||
if (skipPreflight) {
|
if (skipPreflight) {
|
||||||
config.skipPreflight = skipPreflight;
|
config.skipPreflight = skipPreflight;
|
||||||
|
|
|
@ -1361,6 +1361,25 @@ describe('Connection', () => {
|
||||||
).to.be.rejected;
|
).to.be.rejected;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('consistent preflightCommitment', async () => {
|
||||||
|
const connection = new Connection(url, 'singleGossip');
|
||||||
|
const sender = new Account();
|
||||||
|
const recipient = new Account();
|
||||||
|
let signature = await connection.requestAirdrop(
|
||||||
|
sender.publicKey,
|
||||||
|
2 * LAMPORTS_PER_SOL,
|
||||||
|
);
|
||||||
|
await connection.confirmTransaction(signature, 'singleGossip');
|
||||||
|
const transaction = new Transaction().add(
|
||||||
|
SystemProgram.transfer({
|
||||||
|
fromPubkey: sender.publicKey,
|
||||||
|
toPubkey: recipient.publicKey,
|
||||||
|
lamports: LAMPORTS_PER_SOL,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await sendAndConfirmTransaction(connection, transaction, [sender]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
it('get largest accounts', async () => {
|
it('get largest accounts', async () => {
|
||||||
|
|
Loading…
Reference in New Issue