test: getEstimatedFee change runs only in live environment now (#25210)

Co-authored-by: Marc Jaramillo <mnj.webdeveloper@gmail.com>
This commit is contained in:
Steven Luscher 2022-05-13 21:16:39 -07:00 committed by GitHub
parent 375968da3b
commit d513407485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 18 deletions

View File

@ -13,6 +13,7 @@ import {Message} from '../src/message';
import invariant from '../src/util/assert';
import {toBuffer} from '../src/util/to-buffer';
import {helpers} from './mocks/rpc-http';
import {url} from './url';
describe('Transaction', () => {
describe('compileMessage', () => {
@ -114,27 +115,29 @@ describe('Transaction', () => {
});
});
it('getEstimatedFee', async () => {
const connection = new Connection('https://api.testnet.solana.com');
const accountFrom = Keypair.generate();
const accountTo = Keypair.generate();
if (process.env.TEST_LIVE) {
it('getEstimatedFee', async () => {
const connection = new Connection(url);
const accountFrom = Keypair.generate();
const accountTo = Keypair.generate();
const {blockhash} = await helpers.latestBlockhash({connection});
const {blockhash} = await helpers.latestBlockhash({connection});
const transaction = new Transaction({
feePayer: accountFrom.publicKey,
recentBlockhash: blockhash,
}).add(
SystemProgram.transfer({
fromPubkey: accountFrom.publicKey,
toPubkey: accountTo.publicKey,
lamports: 10,
}),
);
const transaction = new Transaction({
feePayer: accountFrom.publicKey,
recentBlockhash: blockhash,
}).add(
SystemProgram.transfer({
fromPubkey: accountFrom.publicKey,
toPubkey: accountTo.publicKey,
lamports: 10,
}),
);
const fee = await transaction.getEstimatedFee(connection);
expect(fee).to.eq(5000);
}).timeout(60 * 1000);
const fee = await transaction.getEstimatedFee(connection);
expect(fee).to.eq(5000);
});
}
it('partialSign', () => {
const account1 = Keypair.generate();