feat: update commitment variants (#15253)
* feat: update commitment variants * fix: make pretty * fix: deprecate, but leave in commitment types
This commit is contained in:
13
web3.js/module.d.ts
vendored
13
web3.js/module.d.ts
vendored
@ -77,11 +77,14 @@ declare module '@solana/web3.js' {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Commitment =
|
export type Commitment =
|
||||||
| 'max'
|
| 'processed'
|
||||||
| 'recent'
|
| 'confirmed'
|
||||||
| 'root'
|
| 'finalized'
|
||||||
| 'single'
|
| 'recent' // Deprecated as of v1.5.5
|
||||||
| 'singleGossip';
|
| 'single' // Deprecated as of v1.5.5
|
||||||
|
| 'singleGossip' // Deprecated as of v1.5.5
|
||||||
|
| 'root' // Deprecated as of v1.5.5
|
||||||
|
| 'max'; // Deprecated as of v1.5.5
|
||||||
|
|
||||||
export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
|
export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
|
||||||
|
|
||||||
|
@ -90,11 +90,14 @@ declare module '@solana/web3.js' {
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare export type Commitment =
|
declare export type Commitment =
|
||||||
| 'max'
|
| 'processed'
|
||||||
| 'recent'
|
| 'confirmed'
|
||||||
| 'root'
|
| 'finalized'
|
||||||
| 'single'
|
| 'recent' // Deprecated as of v1.5.5
|
||||||
| 'singleGossip';
|
| 'single' // Deprecated as of v1.5.5
|
||||||
|
| 'singleGossip' // Deprecated as of v1.5.5
|
||||||
|
| 'root' // Deprecated as of v1.5.5
|
||||||
|
| 'max'; // Deprecated as of v1.5.5
|
||||||
|
|
||||||
declare export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
|
declare export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
|
||||||
|
|
||||||
|
@ -145,16 +145,22 @@ function notificationResultAndContext(resultDescription: any) {
|
|||||||
/**
|
/**
|
||||||
* The level of commitment desired when querying state
|
* The level of commitment desired when querying state
|
||||||
* <pre>
|
* <pre>
|
||||||
* 'max': Query the most recent block which has been finalized by the cluster
|
* 'processed': Query the most recent block which has reached 1 confirmation by the connected node
|
||||||
* 'recent': Query the most recent block which has reached 1 confirmation by the connected node
|
* 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
|
||||||
* 'root': Query the most recent block which has been rooted by the connected node
|
* 'finalized': Query the most recent block which has been finalized by the cluster
|
||||||
* 'single': Query the most recent block which has reached 1 confirmation by the cluster
|
|
||||||
* 'singleGossip': Query the most recent block which has reached 1 confirmation according to votes seen in gossip
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @typedef {'max' | 'recent' | 'root' | 'single' | 'singleGossip'} Commitment
|
* @typedef {'processed' | 'confirmed' | 'finalized'} Commitment
|
||||||
*/
|
*/
|
||||||
export type Commitment = 'max' | 'recent' | 'root' | 'single' | 'singleGossip';
|
export type Commitment =
|
||||||
|
| 'processed'
|
||||||
|
| 'confirmed'
|
||||||
|
| 'finalized'
|
||||||
|
| 'recent' // Deprecated as of v1.5.5
|
||||||
|
| 'single' // Deprecated as of v1.5.5
|
||||||
|
| 'singleGossip' // Deprecated as of v1.5.5
|
||||||
|
| 'root' // Deprecated as of v1.5.5
|
||||||
|
| 'max'; // Deprecated as of v1.5.5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter for largest accounts query
|
* Filter for largest accounts query
|
||||||
@ -2291,13 +2297,16 @@ export class Connection {
|
|||||||
|
|
||||||
let timeoutMs = 60 * 1000;
|
let timeoutMs = 60 * 1000;
|
||||||
switch (subscriptionCommitment) {
|
switch (subscriptionCommitment) {
|
||||||
|
case 'processed':
|
||||||
case 'recent':
|
case 'recent':
|
||||||
case 'single':
|
case 'single':
|
||||||
|
case 'confirmed':
|
||||||
case 'singleGossip': {
|
case 'singleGossip': {
|
||||||
timeoutMs = 30 * 1000;
|
timeoutMs = 30 * 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// exhaust enums to ensure full coverage
|
// exhaust enums to ensure full coverage
|
||||||
|
case 'finalized':
|
||||||
case 'max':
|
case 'max':
|
||||||
case 'root':
|
case 'root':
|
||||||
}
|
}
|
||||||
@ -2876,7 +2885,7 @@ export class Connection {
|
|||||||
try {
|
try {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
for (let i = 0; i < 50; i++) {
|
for (let i = 0; i < 50; i++) {
|
||||||
const {blockhash} = await this.getRecentBlockhash('max');
|
const {blockhash} = await this.getRecentBlockhash('finalized');
|
||||||
|
|
||||||
if (this._blockhashInfo.recentBlockhash != blockhash) {
|
if (this._blockhashInfo.recentBlockhash != blockhash) {
|
||||||
this._blockhashInfo = {
|
this._blockhashInfo = {
|
||||||
|
@ -68,7 +68,7 @@ export class Loader {
|
|||||||
// Fetch program account info to check if it has already been created
|
// Fetch program account info to check if it has already been created
|
||||||
const programInfo = await connection.getAccountInfo(
|
const programInfo = await connection.getAccountInfo(
|
||||||
program.publicKey,
|
program.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
|
|
||||||
let transaction: Transaction | null = null;
|
let transaction: Transaction | null = null;
|
||||||
@ -128,7 +128,7 @@ export class Loader {
|
|||||||
transaction,
|
transaction,
|
||||||
[payer, program],
|
[payer, program],
|
||||||
{
|
{
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ export class Loader {
|
|||||||
});
|
});
|
||||||
transactions.push(
|
transactions.push(
|
||||||
sendAndConfirmTransaction(connection, transaction, [payer, program], {
|
sendAndConfirmTransaction(connection, transaction, [payer, program], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ export class Loader {
|
|||||||
transaction,
|
transaction,
|
||||||
[payer, program],
|
[payer, program],
|
||||||
{
|
{
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ if (process.env.TEST_LIVE) {
|
|||||||
it('load BPF C program', async () => {
|
it('load BPF C program', async () => {
|
||||||
const data = await fs.readFile('test/fixtures/noop-c/noop.so');
|
const data = await fs.readFile('test/fixtures/noop-c/noop.so');
|
||||||
|
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
const {feeCalculator} = await connection.getRecentBlockhash();
|
const {feeCalculator} = await connection.getRecentBlockhash();
|
||||||
const fees =
|
const fees =
|
||||||
feeCalculator.lamportsPerSignature *
|
feeCalculator.lamportsPerSignature *
|
||||||
@ -59,13 +59,13 @@ if (process.env.TEST_LIVE) {
|
|||||||
programId: program.publicKey,
|
programId: program.publicKey,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, transaction, [from], {
|
await sendAndConfirmTransaction(connection, transaction, [from], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
}).timeout(5000);
|
}).timeout(5000);
|
||||||
|
|
||||||
describe('load BPF Rust program', () => {
|
describe('load BPF Rust program', () => {
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
|
|
||||||
let program = new Account();
|
let program = new Account();
|
||||||
let payerAccount = new Account();
|
let payerAccount = new Account();
|
||||||
@ -141,8 +141,8 @@ if (process.env.TEST_LIVE) {
|
|||||||
transaction,
|
transaction,
|
||||||
[payerAccount],
|
[payerAccount],
|
||||||
{
|
{
|
||||||
commitment: 'max', // `getParsedConfirmedTransaction` requires max commitment
|
commitment: 'finalized', // `getParsedConfirmedTransaction` requires max commitment
|
||||||
preflightCommitment: connection.commitment || 'max',
|
preflightCommitment: connection.commitment || 'finalized',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [account0],
|
signers: [account0],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [account1],
|
signers: [account1],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ describe('Connection', () => {
|
|||||||
method: 'getProgramAccounts',
|
method: 'getProgramAccounts',
|
||||||
params: [
|
params: [
|
||||||
programId.publicKey.toBase58(),
|
programId.publicKey.toBase58(),
|
||||||
{commitment: 'singleGossip', encoding: 'base64'},
|
{commitment: 'confirmed', encoding: 'base64'},
|
||||||
],
|
],
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
const programAccounts = await connection.getProgramAccounts(
|
const programAccounts = await connection.getProgramAccounts(
|
||||||
programId.publicKey,
|
programId.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
expect(programAccounts).to.have.length(2);
|
expect(programAccounts).to.have.length(2);
|
||||||
programAccounts.forEach(function (keyedAccount) {
|
programAccounts.forEach(function (keyedAccount) {
|
||||||
@ -210,7 +210,7 @@ describe('Connection', () => {
|
|||||||
method: 'getProgramAccounts',
|
method: 'getProgramAccounts',
|
||||||
params: [
|
params: [
|
||||||
programId.publicKey.toBase58(),
|
programId.publicKey.toBase58(),
|
||||||
{commitment: 'singleGossip', encoding: 'jsonParsed'},
|
{commitment: 'confirmed', encoding: 'jsonParsed'},
|
||||||
],
|
],
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
const programAccounts = await connection.getParsedProgramAccounts(
|
const programAccounts = await connection.getParsedProgramAccounts(
|
||||||
programId.publicKey,
|
programId.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
expect(programAccounts).to.have.length(2);
|
expect(programAccounts).to.have.length(2);
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ describe('Connection', () => {
|
|||||||
it('get epoch info', async () => {
|
it('get epoch info', async () => {
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getEpochInfo',
|
method: 'getEpochInfo',
|
||||||
params: [{commitment: 'singleGossip'}],
|
params: [{commitment: 'confirmed'}],
|
||||||
value: {
|
value: {
|
||||||
epoch: 0,
|
epoch: 0,
|
||||||
slotIndex: 1,
|
slotIndex: 1,
|
||||||
@ -329,7 +329,7 @@ describe('Connection', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const epochInfo = await connection.getEpochInfo('singleGossip');
|
const epochInfo = await connection.getEpochInfo('confirmed');
|
||||||
|
|
||||||
for (const key of [
|
for (const key of [
|
||||||
'epoch',
|
'epoch',
|
||||||
@ -1012,13 +1012,7 @@ describe('Connection', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('get recent blockhash', async () => {
|
it('get recent blockhash', async () => {
|
||||||
for (const commitment of [
|
for (const commitment of ['processed', 'confirmed', 'finalized']) {
|
||||||
'max',
|
|
||||||
'singleGossip',
|
|
||||||
'root',
|
|
||||||
'single',
|
|
||||||
'singleGossip',
|
|
||||||
]) {
|
|
||||||
const {blockhash, feeCalculator} = await helpers.recentBlockhash({
|
const {blockhash, feeCalculator} = await helpers.recentBlockhash({
|
||||||
connection,
|
connection,
|
||||||
commitment,
|
commitment,
|
||||||
@ -1032,7 +1026,7 @@ describe('Connection', () => {
|
|||||||
const {blockhash} = await helpers.recentBlockhash({connection});
|
const {blockhash} = await helpers.recentBlockhash({connection});
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getFeeCalculatorForBlockhash',
|
method: 'getFeeCalculatorForBlockhash',
|
||||||
params: [blockhash, {commitment: 'singleGossip'}],
|
params: [blockhash, {commitment: 'confirmed'}],
|
||||||
value: {
|
value: {
|
||||||
feeCalculator: {
|
feeCalculator: {
|
||||||
lamportsPerSignature: 5000,
|
lamportsPerSignature: 5000,
|
||||||
@ -1042,7 +1036,7 @@ describe('Connection', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const feeCalculator = (
|
const feeCalculator = (
|
||||||
await connection.getFeeCalculatorForBlockhash(blockhash, 'singleGossip')
|
await connection.getFeeCalculatorForBlockhash(blockhash, 'confirmed')
|
||||||
).value;
|
).value;
|
||||||
if (feeCalculator === null) {
|
if (feeCalculator === null) {
|
||||||
expect(feeCalculator).not.to.be.null;
|
expect(feeCalculator).not.to.be.null;
|
||||||
@ -1149,7 +1143,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
if (process.env.TEST_LIVE) {
|
if (process.env.TEST_LIVE) {
|
||||||
describe('token methods', () => {
|
describe('token methods', () => {
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
const newAccount = new Account().publicKey;
|
const newAccount = new Account().publicKey;
|
||||||
|
|
||||||
let testToken: Token;
|
let testToken: Token;
|
||||||
@ -1205,7 +1199,7 @@ describe('Connection', () => {
|
|||||||
new u64(1),
|
new u64(1),
|
||||||
);
|
);
|
||||||
|
|
||||||
await connection.confirmTransaction(testSignature, 'max');
|
await connection.confirmTransaction(testSignature, 'finalized');
|
||||||
|
|
||||||
testOwner = accountOwner;
|
testOwner = accountOwner;
|
||||||
testToken = token;
|
testToken = token;
|
||||||
@ -1421,7 +1415,7 @@ describe('Connection', () => {
|
|||||||
authorized.publicKey,
|
authorized.publicKey,
|
||||||
2 * LAMPORTS_PER_SOL,
|
2 * LAMPORTS_PER_SOL,
|
||||||
);
|
);
|
||||||
await connection.confirmTransaction(signature, 'singleGossip');
|
await connection.confirmTransaction(signature, 'confirmed');
|
||||||
|
|
||||||
const minimumAmount = await connection.getMinimumBalanceForRentExemption(
|
const minimumAmount = await connection.getMinimumBalanceForRentExemption(
|
||||||
StakeProgram.space,
|
StakeProgram.space,
|
||||||
@ -1441,8 +1435,8 @@ describe('Connection', () => {
|
|||||||
createAndInitialize,
|
createAndInitialize,
|
||||||
[authorized, newStakeAccount],
|
[authorized, newStakeAccount],
|
||||||
{
|
{
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let delegation = StakeProgram.delegate({
|
let delegation = StakeProgram.delegate({
|
||||||
@ -1451,15 +1445,15 @@ describe('Connection', () => {
|
|||||||
votePubkey,
|
votePubkey,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
const LARGE_EPOCH = 4000;
|
const LARGE_EPOCH = 4000;
|
||||||
await expect(
|
await expect(
|
||||||
connection.getStakeActivation(
|
connection.getStakeActivation(
|
||||||
newStakeAccount.publicKey,
|
newStakeAccount.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
LARGE_EPOCH,
|
LARGE_EPOCH,
|
||||||
),
|
),
|
||||||
).to.be.rejectedWith(
|
).to.be.rejectedWith(
|
||||||
@ -1468,7 +1462,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
const activationState = await connection.getStakeActivation(
|
const activationState = await connection.getStakeActivation(
|
||||||
newStakeAccount.publicKey,
|
newStakeAccount.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
expect(activationState.state).to.eq('activating');
|
expect(activationState.state).to.eq('activating');
|
||||||
expect(activationState.inactive).to.eq(42);
|
expect(activationState.inactive).to.eq(42);
|
||||||
@ -1495,15 +1489,15 @@ describe('Connection', () => {
|
|||||||
await addStakeActivationMock('active');
|
await addStakeActivationMock('active');
|
||||||
let activation = await connection.getStakeActivation(
|
let activation = await connection.getStakeActivation(
|
||||||
publicKey,
|
publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
expect(activation.state).to.eq('active');
|
expect(activation.state).to.eq('active');
|
||||||
expect(activation.active).to.eq(0);
|
expect(activation.active).to.eq(0);
|
||||||
expect(activation.inactive).to.eq(80);
|
expect(activation.inactive).to.eq(80);
|
||||||
|
|
||||||
await addStakeActivationMock('invalid');
|
await addStakeActivationMock('invalid');
|
||||||
await expect(connection.getStakeActivation(publicKey, 'singleGossip')).to
|
await expect(connection.getStakeActivation(publicKey, 'confirmed')).to.be
|
||||||
.be.rejected;
|
.rejected;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1529,22 +1523,19 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getBalance',
|
method: 'getBalance',
|
||||||
params: [account.publicKey.toBase58(), {commitment: 'singleGossip'}],
|
params: [account.publicKey.toBase58(), {commitment: 'confirmed'}],
|
||||||
value: LAMPORTS_PER_SOL,
|
value: LAMPORTS_PER_SOL,
|
||||||
withContext: true,
|
withContext: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const balance = await connection.getBalance(
|
const balance = await connection.getBalance(account.publicKey, 'confirmed');
|
||||||
account.publicKey,
|
|
||||||
'singleGossip',
|
|
||||||
);
|
|
||||||
expect(balance).to.eq(LAMPORTS_PER_SOL);
|
expect(balance).to.eq(LAMPORTS_PER_SOL);
|
||||||
|
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
account.publicKey.toBase58(),
|
account.publicKey.toBase58(),
|
||||||
{commitment: 'singleGossip', encoding: 'base64'},
|
{commitment: 'confirmed', encoding: 'base64'},
|
||||||
],
|
],
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
@ -1557,7 +1548,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
const accountInfo = await connection.getAccountInfo(
|
const accountInfo = await connection.getAccountInfo(
|
||||||
account.publicKey,
|
account.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
if (accountInfo === null) {
|
if (accountInfo === null) {
|
||||||
expect(accountInfo).not.to.be.null;
|
expect(accountInfo).not.to.be.null;
|
||||||
@ -1571,7 +1562,7 @@ describe('Connection', () => {
|
|||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
account.publicKey.toBase58(),
|
account.publicKey.toBase58(),
|
||||||
{commitment: 'singleGossip', encoding: 'jsonParsed'},
|
{commitment: 'confirmed', encoding: 'jsonParsed'},
|
||||||
],
|
],
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
@ -1583,7 +1574,7 @@ describe('Connection', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const parsedAccountInfo = (
|
const parsedAccountInfo = (
|
||||||
await connection.getParsedAccountInfo(account.publicKey, 'singleGossip')
|
await connection.getParsedAccountInfo(account.publicKey, 'confirmed')
|
||||||
).value;
|
).value;
|
||||||
if (parsedAccountInfo === null) {
|
if (parsedAccountInfo === null) {
|
||||||
expect(parsedAccountInfo).not.to.be.null;
|
expect(parsedAccountInfo).not.to.be.null;
|
||||||
@ -1621,7 +1612,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [payer, newAccount],
|
signers: [payer, newAccount],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
// This should fail because the account is already created
|
// This should fail because the account is already created
|
||||||
@ -1631,7 +1622,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [payer, newAccount],
|
signers: [payer, newAccount],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
err: expectedErr,
|
err: expectedErr,
|
||||||
})
|
})
|
||||||
).value;
|
).value;
|
||||||
@ -1658,7 +1649,7 @@ describe('Connection', () => {
|
|||||||
|
|
||||||
if (process.env.TEST_LIVE) {
|
if (process.env.TEST_LIVE) {
|
||||||
it('transaction', async () => {
|
it('transaction', async () => {
|
||||||
connection._commitment = 'singleGossip';
|
connection._commitment = 'confirmed';
|
||||||
|
|
||||||
const accountFrom = new Account();
|
const accountFrom = new Account();
|
||||||
const accountTo = new Account();
|
const accountTo = new Account();
|
||||||
@ -1689,7 +1680,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
[accountFrom],
|
[accountFrom],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send again and ensure that new blockhash is used
|
// Send again and ensure that new blockhash is used
|
||||||
@ -1706,7 +1697,7 @@ describe('Connection', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction2,
|
transaction2,
|
||||||
[accountFrom],
|
[accountFrom],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(signature).not.to.eq(signature2);
|
expect(signature).not.to.eq(signature2);
|
||||||
@ -1723,7 +1714,7 @@ describe('Connection', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await sendAndConfirmTransaction(connection, transaction3, [accountFrom], {
|
await sendAndConfirmTransaction(connection, transaction3, [accountFrom], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
expect(transaction2.recentBlockhash).to.eq(transaction3.recentBlockhash);
|
expect(transaction2.recentBlockhash).to.eq(transaction3.recentBlockhash);
|
||||||
|
|
||||||
@ -1744,7 +1735,7 @@ describe('Connection', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await sendAndConfirmTransaction(connection, transaction4, [accountFrom], {
|
await sendAndConfirmTransaction(connection, transaction4, [accountFrom], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(transaction4.recentBlockhash).not.to.eq(
|
expect(transaction4.recentBlockhash).not.to.eq(
|
||||||
@ -1761,7 +1752,7 @@ describe('Connection', () => {
|
|||||||
}).timeout(45 * 1000); // waits 30s for cache timeout
|
}).timeout(45 * 1000); // waits 30s for cache timeout
|
||||||
|
|
||||||
it('multi-instruction transaction', async () => {
|
it('multi-instruction transaction', async () => {
|
||||||
connection._commitment = 'singleGossip';
|
connection._commitment = 'confirmed';
|
||||||
|
|
||||||
const accountFrom = new Account();
|
const accountFrom = new Account();
|
||||||
const accountTo = new Account();
|
const accountTo = new Account();
|
||||||
@ -1840,7 +1831,7 @@ describe('Connection', () => {
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// const connection = new Connection(url, 'singleGossip');
|
// const connection = new Connection(url, 'confirmed');
|
||||||
// const owner = new Account();
|
// const owner = new Account();
|
||||||
// const programAccount = new Account();
|
// const programAccount = new Account();
|
||||||
|
|
||||||
@ -1849,7 +1840,7 @@ describe('Connection', () => {
|
|||||||
// const subscriptionId = connection.onAccountChange(
|
// const subscriptionId = connection.onAccountChange(
|
||||||
// programAccount.publicKey,
|
// programAccount.publicKey,
|
||||||
// mockCallback,
|
// mockCallback,
|
||||||
// 'singleGossip',
|
// 'confirmed',
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// const balanceNeeded = Math.max(
|
// const balanceNeeded = Math.max(
|
||||||
@ -1871,7 +1862,7 @@ describe('Connection', () => {
|
|||||||
// }),
|
// }),
|
||||||
// );
|
// );
|
||||||
// await sendAndConfirmTransaction(connection, transaction, [owner], {
|
// await sendAndConfirmTransaction(connection, transaction, [owner], {
|
||||||
// commitment: 'singleGossip',
|
// commitment: 'confirmed',
|
||||||
// });
|
// });
|
||||||
// } catch (err) {
|
// } catch (err) {
|
||||||
// await connection.removeAccountChangeListener(subscriptionId);
|
// await connection.removeAccountChangeListener(subscriptionId);
|
||||||
@ -1900,7 +1891,7 @@ describe('Connection', () => {
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
it('program account change notification', async () => {
|
it('program account change notification', async () => {
|
||||||
connection._commitment = 'singleGossip';
|
connection._commitment = 'confirmed';
|
||||||
|
|
||||||
const owner = new Account();
|
const owner = new Account();
|
||||||
const programAccount = new Account();
|
const programAccount = new Account();
|
||||||
@ -1942,7 +1933,7 @@ describe('Connection', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await sendAndConfirmTransaction(connection, transaction, [owner], {
|
await sendAndConfirmTransaction(connection, transaction, [owner], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await connection.removeProgramAccountChangeListener(subscriptionId);
|
await connection.removeProgramAccountChangeListener(subscriptionId);
|
||||||
|
@ -162,11 +162,11 @@ const airdrop = async ({
|
|||||||
|
|
||||||
await mockRpcMessage({
|
await mockRpcMessage({
|
||||||
method: 'signatureSubscribe',
|
method: 'signatureSubscribe',
|
||||||
params: [signature, {commitment: 'singleGossip'}],
|
params: [signature, {commitment: 'confirmed'}],
|
||||||
result: {err: null},
|
result: {err: null},
|
||||||
});
|
});
|
||||||
|
|
||||||
await connection.confirmTransaction(signature, 'singleGossip');
|
await connection.confirmTransaction(signature, 'confirmed');
|
||||||
return signature;
|
return signature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,14 +78,14 @@ describe('Nonce', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [from, nonceAccount],
|
signers: [from, nonceAccount],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
nonceAccount.publicKey.toBase58(),
|
nonceAccount.publicKey.toBase58(),
|
||||||
{encoding: 'base64', commitment: 'singleGossip'},
|
{encoding: 'base64', commitment: 'confirmed'},
|
||||||
],
|
],
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
@ -98,7 +98,7 @@ describe('Nonce', () => {
|
|||||||
|
|
||||||
const nonceAccountData = await connection.getNonce(
|
const nonceAccountData = await connection.getNonce(
|
||||||
nonceAccount.publicKey,
|
nonceAccount.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
if (nonceAccountData === null) {
|
if (nonceAccountData === null) {
|
||||||
expect(nonceAccountData).not.to.be.null;
|
expect(nonceAccountData).not.to.be.null;
|
||||||
@ -148,14 +148,14 @@ describe('Nonce', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [from],
|
signers: [from],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
noncePubkey.toBase58(),
|
noncePubkey.toBase58(),
|
||||||
{encoding: 'base64', commitment: 'singleGossip'},
|
{encoding: 'base64', commitment: 'confirmed'},
|
||||||
],
|
],
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
@ -168,7 +168,7 @@ describe('Nonce', () => {
|
|||||||
|
|
||||||
const nonceAccountData = await connection.getNonce(
|
const nonceAccountData = await connection.getNonce(
|
||||||
noncePubkey,
|
noncePubkey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
if (nonceAccountData === null) {
|
if (nonceAccountData === null) {
|
||||||
expect(nonceAccountData).not.to.be.null;
|
expect(nonceAccountData).not.to.be.null;
|
||||||
|
@ -33,12 +33,12 @@ if (process.env.TEST_LIVE) {
|
|||||||
keccak_256.update(toBuffer(message)).digest(),
|
keccak_256.update(toBuffer(message)).digest(),
|
||||||
);
|
);
|
||||||
const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
|
const {signature, recid: recoveryId} = ecdsaSign(messageHash, privateKey);
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
|
|
||||||
const from = new Account();
|
const from = new Account();
|
||||||
await connection.confirmTransaction(
|
await connection.confirmTransaction(
|
||||||
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL),
|
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL),
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
|
|
||||||
const transaction = new Transaction().add(
|
const transaction = new Transaction().add(
|
||||||
@ -51,19 +51,19 @@ if (process.env.TEST_LIVE) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await sendAndConfirmTransaction(connection, transaction, [from], {
|
await sendAndConfirmTransaction(connection, transaction, [from], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create secp256k1 instruction with private key', async () => {
|
it('create secp256k1 instruction with private key', async () => {
|
||||||
const privateKey = randomPrivateKey();
|
const privateKey = randomPrivateKey();
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
|
|
||||||
const from = new Account();
|
const from = new Account();
|
||||||
await connection.confirmTransaction(
|
await connection.confirmTransaction(
|
||||||
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL),
|
await connection.requestAirdrop(from.publicKey, 2 * LAMPORTS_PER_SOL),
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
|
|
||||||
const transaction = new Transaction().add(
|
const transaction = new Transaction().add(
|
||||||
@ -74,8 +74,8 @@ if (process.env.TEST_LIVE) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await sendAndConfirmTransaction(connection, transaction, [from], {
|
await sendAndConfirmTransaction(connection, transaction, [from], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -326,7 +326,7 @@ describe('StakeProgram', () => {
|
|||||||
|
|
||||||
if (process.env.TEST_LIVE) {
|
if (process.env.TEST_LIVE) {
|
||||||
it('live staking actions', async () => {
|
it('live staking actions', async () => {
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
|
|
||||||
const voteAccounts = await connection.getVoteAccounts();
|
const voteAccounts = await connection.getVoteAccounts();
|
||||||
const voteAccount = voteAccounts.current.concat(
|
const voteAccount = voteAccounts.current.concat(
|
||||||
@ -377,7 +377,7 @@ describe('StakeProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
createAndInitialize,
|
createAndInitialize,
|
||||||
[payer, newStakeAccount],
|
[payer, newStakeAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
expect(await connection.getBalance(newStakeAccount.publicKey)).to.eq(
|
expect(await connection.getBalance(newStakeAccount.publicKey)).to.eq(
|
||||||
minimumAmount + 42,
|
minimumAmount + 42,
|
||||||
@ -389,7 +389,7 @@ describe('StakeProgram', () => {
|
|||||||
votePubkey,
|
votePubkey,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +415,7 @@ describe('StakeProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
createAndInitializeWithSeed,
|
createAndInitializeWithSeed,
|
||||||
[payer],
|
[payer],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
let originalStakeBalance = await connection.getBalance(newAccountPubkey);
|
let originalStakeBalance = await connection.getBalance(newAccountPubkey);
|
||||||
expect(originalStakeBalance).to.eq(3 * minimumAmount + 42);
|
expect(originalStakeBalance).to.eq(3 * minimumAmount + 42);
|
||||||
@ -426,7 +426,7 @@ describe('StakeProgram', () => {
|
|||||||
votePubkey,
|
votePubkey,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
await sendAndConfirmTransaction(connection, delegation, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test that withdraw fails before deactivation
|
// Test that withdraw fails before deactivation
|
||||||
@ -439,7 +439,7 @@ describe('StakeProgram', () => {
|
|||||||
});
|
});
|
||||||
await expect(
|
await expect(
|
||||||
sendAndConfirmTransaction(connection, withdraw, [authorized], {
|
sendAndConfirmTransaction(connection, withdraw, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
}),
|
}),
|
||||||
).to.be.rejected;
|
).to.be.rejected;
|
||||||
|
|
||||||
@ -449,7 +449,7 @@ describe('StakeProgram', () => {
|
|||||||
authorizedPubkey: authorized.publicKey,
|
authorizedPubkey: authorized.publicKey,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, deactivate, [authorized], {
|
await sendAndConfirmTransaction(connection, deactivate, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
let stakeActivationState;
|
let stakeActivationState;
|
||||||
@ -468,7 +468,7 @@ describe('StakeProgram', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await sendAndConfirmTransaction(connection, withdraw, [authorized], {
|
await sendAndConfirmTransaction(connection, withdraw, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
const recipientBalance = await connection.getBalance(recipient.publicKey);
|
const recipientBalance = await connection.getBalance(recipient.publicKey);
|
||||||
expect(recipientBalance).to.eq(minimumAmount + 20);
|
expect(recipientBalance).to.eq(minimumAmount + 20);
|
||||||
@ -486,7 +486,7 @@ describe('StakeProgram', () => {
|
|||||||
split,
|
split,
|
||||||
[authorized, newStake],
|
[authorized, newStake],
|
||||||
{
|
{
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const balance = await connection.getBalance(newAccountPubkey);
|
const balance = await connection.getBalance(newAccountPubkey);
|
||||||
@ -506,7 +506,7 @@ describe('StakeProgram', () => {
|
|||||||
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, authorize, [authorized], {
|
await sendAndConfirmTransaction(connection, authorize, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
authorize = StakeProgram.authorize({
|
authorize = StakeProgram.authorize({
|
||||||
stakePubkey: newAccountPubkey,
|
stakePubkey: newAccountPubkey,
|
||||||
@ -515,7 +515,7 @@ describe('StakeProgram', () => {
|
|||||||
stakeAuthorizationType: StakeAuthorizationLayout.Staker,
|
stakeAuthorizationType: StakeAuthorizationLayout.Staker,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, authorize, [authorized], {
|
await sendAndConfirmTransaction(connection, authorize, [authorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test old authorized can't delegate
|
// Test old authorized can't delegate
|
||||||
@ -530,7 +530,7 @@ describe('StakeProgram', () => {
|
|||||||
delegateNotAuthorized,
|
delegateNotAuthorized,
|
||||||
[authorized],
|
[authorized],
|
||||||
{
|
{
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).to.be.rejected;
|
).to.be.rejected;
|
||||||
@ -543,7 +543,7 @@ describe('StakeProgram', () => {
|
|||||||
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, authorize, [newAuthorized], {
|
await sendAndConfirmTransaction(connection, authorize, [newAuthorized], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Restore the previous authority using a derived address
|
// Restore the previous authority using a derived address
|
||||||
@ -556,7 +556,7 @@ describe('StakeProgram', () => {
|
|||||||
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer,
|
||||||
});
|
});
|
||||||
await sendAndConfirmTransaction(connection, authorize, [payer], {
|
await sendAndConfirmTransaction(connection, authorize, [payer], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
}).timeout(10 * 1000);
|
}).timeout(10 * 1000);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ describe('SystemProgram', () => {
|
|||||||
|
|
||||||
if (process.env.TEST_LIVE) {
|
if (process.env.TEST_LIVE) {
|
||||||
it('live Nonce actions', async () => {
|
it('live Nonce actions', async () => {
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
const nonceAccount = new Account();
|
const nonceAccount = new Account();
|
||||||
const from = new Account();
|
const from = new Account();
|
||||||
await helpers.airdrop({
|
await helpers.airdrop({
|
||||||
@ -323,7 +323,7 @@ describe('SystemProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
createNonceAccount,
|
createNonceAccount,
|
||||||
[from, nonceAccount],
|
[from, nonceAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
const nonceBalance = await connection.getBalance(nonceAccount.publicKey);
|
const nonceBalance = await connection.getBalance(nonceAccount.publicKey);
|
||||||
expect(nonceBalance).to.eq(minimumAmount);
|
expect(nonceBalance).to.eq(minimumAmount);
|
||||||
@ -352,7 +352,7 @@ describe('SystemProgram', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await sendAndConfirmTransaction(connection, advanceNonce, [from], {
|
await sendAndConfirmTransaction(connection, advanceNonce, [from], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
const nonceQuery3 = await connection.getNonce(nonceAccount.publicKey);
|
const nonceQuery3 = await connection.getNonce(nonceAccount.publicKey);
|
||||||
if (nonceQuery3 === null) {
|
if (nonceQuery3 === null) {
|
||||||
@ -373,7 +373,7 @@ describe('SystemProgram', () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await sendAndConfirmTransaction(connection, authorizeNonce, [from], {
|
await sendAndConfirmTransaction(connection, authorizeNonce, [from], {
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
let transfer = new Transaction().add(
|
let transfer = new Transaction().add(
|
||||||
@ -396,7 +396,7 @@ describe('SystemProgram', () => {
|
|||||||
transfer,
|
transfer,
|
||||||
[from, newAuthority],
|
[from, newAuthority],
|
||||||
{
|
{
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const toBalance = await connection.getBalance(to.publicKey);
|
const toBalance = await connection.getBalance(to.publicKey);
|
||||||
@ -419,7 +419,7 @@ describe('SystemProgram', () => {
|
|||||||
withdrawNonce,
|
withdrawNonce,
|
||||||
[newAuthority],
|
[newAuthority],
|
||||||
{
|
{
|
||||||
preflightCommitment: 'singleGossip',
|
preflightCommitment: 'confirmed',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(await connection.getBalance(nonceAccount.publicKey)).to.eq(0);
|
expect(await connection.getBalance(nonceAccount.publicKey)).to.eq(0);
|
||||||
@ -430,7 +430,7 @@ describe('SystemProgram', () => {
|
|||||||
}).timeout(10 * 1000);
|
}).timeout(10 * 1000);
|
||||||
|
|
||||||
it('live withSeed actions', async () => {
|
it('live withSeed actions', async () => {
|
||||||
const connection = new Connection(url, 'singleGossip');
|
const connection = new Connection(url, 'confirmed');
|
||||||
const baseAccount = new Account();
|
const baseAccount = new Account();
|
||||||
await helpers.airdrop({
|
await helpers.airdrop({
|
||||||
connection,
|
connection,
|
||||||
@ -468,7 +468,7 @@ describe('SystemProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
createAccountWithSeedTransaction,
|
createAccountWithSeedTransaction,
|
||||||
[baseAccount],
|
[baseAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
const createAccountWithSeedBalance = await connection.getBalance(
|
const createAccountWithSeedBalance = await connection.getBalance(
|
||||||
createAccountWithSeedAddress,
|
createAccountWithSeedAddress,
|
||||||
@ -492,7 +492,7 @@ describe('SystemProgram', () => {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
[baseAccount],
|
[baseAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
let transferWithSeedAddressBalance = await connection.getBalance(
|
let transferWithSeedAddressBalance = await connection.getBalance(
|
||||||
transferWithSeedAddress,
|
transferWithSeedAddress,
|
||||||
@ -521,7 +521,7 @@ describe('SystemProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
transferWithSeedTransaction,
|
transferWithSeedTransaction,
|
||||||
[baseAccount],
|
[baseAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
const toBalance = await connection.getBalance(toPubkey);
|
const toBalance = await connection.getBalance(toPubkey);
|
||||||
expect(toBalance).to.eq(2 * minimumAmount);
|
expect(toBalance).to.eq(2 * minimumAmount);
|
||||||
@ -545,7 +545,7 @@ describe('SystemProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
allocateWithSeedTransaction,
|
allocateWithSeedTransaction,
|
||||||
[baseAccount],
|
[baseAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
let account = await connection.getAccountInfo(toPubkey);
|
let account = await connection.getAccountInfo(toPubkey);
|
||||||
if (account === null) {
|
if (account === null) {
|
||||||
@ -568,7 +568,7 @@ describe('SystemProgram', () => {
|
|||||||
connection,
|
connection,
|
||||||
assignWithSeedTransaction,
|
assignWithSeedTransaction,
|
||||||
[baseAccount],
|
[baseAccount],
|
||||||
{preflightCommitment: 'singleGossip'},
|
{preflightCommitment: 'confirmed'},
|
||||||
);
|
);
|
||||||
account = await connection.getAccountInfo(toPubkey);
|
account = await connection.getAccountInfo(toPubkey);
|
||||||
if (account === null) {
|
if (account === null) {
|
||||||
|
@ -75,7 +75,7 @@ describe('Transaction Payer', () => {
|
|||||||
connection,
|
connection,
|
||||||
transaction,
|
transaction,
|
||||||
signers: [accountPayer, accountFrom],
|
signers: [accountPayer, accountFrom],
|
||||||
commitment: 'singleGossip',
|
commitment: 'confirmed',
|
||||||
});
|
});
|
||||||
|
|
||||||
const signature = base58.encode(transaction.signature);
|
const signature = base58.encode(transaction.signature);
|
||||||
@ -103,7 +103,7 @@ describe('Transaction Payer', () => {
|
|||||||
|
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getBalance',
|
method: 'getBalance',
|
||||||
params: [accountPayer.publicKey.toBase58(), {commitment: 'singleGossip'}],
|
params: [accountPayer.publicKey.toBase58(), {commitment: 'confirmed'}],
|
||||||
value: LAMPORTS_PER_SOL - 1,
|
value: LAMPORTS_PER_SOL - 1,
|
||||||
withContext: true,
|
withContext: true,
|
||||||
});
|
});
|
||||||
@ -112,7 +112,7 @@ describe('Transaction Payer', () => {
|
|||||||
// (exact amount less depends on the current cluster fees)
|
// (exact amount less depends on the current cluster fees)
|
||||||
const balance = await connection.getBalance(
|
const balance = await connection.getBalance(
|
||||||
accountPayer.publicKey,
|
accountPayer.publicKey,
|
||||||
'singleGossip',
|
'confirmed',
|
||||||
);
|
);
|
||||||
expect(balance).to.be.greaterThan(0);
|
expect(balance).to.be.greaterThan(0);
|
||||||
expect(balance).to.be.at.most(LAMPORTS_PER_SOL);
|
expect(balance).to.be.at.most(LAMPORTS_PER_SOL);
|
||||||
@ -120,12 +120,12 @@ describe('Transaction Payer', () => {
|
|||||||
// accountFrom should have exactly 2, since it didn't pay for the transaction
|
// accountFrom should have exactly 2, since it didn't pay for the transaction
|
||||||
await mockRpcResponse({
|
await mockRpcResponse({
|
||||||
method: 'getBalance',
|
method: 'getBalance',
|
||||||
params: [accountFrom.publicKey.toBase58(), {commitment: 'singleGossip'}],
|
params: [accountFrom.publicKey.toBase58(), {commitment: 'confirmed'}],
|
||||||
value: minimumAmount + 2,
|
value: minimumAmount + 2,
|
||||||
withContext: true,
|
withContext: true,
|
||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
await connection.getBalance(accountFrom.publicKey, 'singleGossip'),
|
await connection.getBalance(accountFrom.publicKey, 'confirmed'),
|
||||||
).to.eq(minimumAmount + 2);
|
).to.eq(minimumAmount + 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user