From d513407485206203752555823123b3a00846e90d Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 13 May 2022 21:16:39 -0700 Subject: [PATCH] test: getEstimatedFee change runs only in live environment now (#25210) Co-authored-by: Marc Jaramillo --- web3.js/test/transaction.test.ts | 39 +++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/web3.js/test/transaction.test.ts b/web3.js/test/transaction.test.ts index f09a3024a..73e3eab6c 100644 --- a/web3.js/test/transaction.test.ts +++ b/web3.js/test/transaction.test.ts @@ -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();