From b5522db96c5f5f9e330b90e30783333d7e7c5219 Mon Sep 17 00:00:00 2001 From: FelixFan1992 Date: Tue, 4 Feb 2025 15:28:12 -0500 Subject: [PATCH] cleanups --- src/localFunctionsTestnet.ts | 12 +++++++----- test/integration/localFunctionsTestnet.test.ts | 4 ++-- test/utils/index.ts | 8 +------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/localFunctionsTestnet.ts b/src/localFunctionsTestnet.ts index cc608e4..f8f64f0 100644 --- a/src/localFunctionsTestnet.ts +++ b/src/localFunctionsTestnet.ts @@ -45,11 +45,13 @@ export const startLocalFunctionsTestnet = async ( await anvil.start() console.log(`Anvil started on port ${port} with chain ID 1337`) - // this is a private key provided by anvil - const admin = new Wallet( - 'ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', - new providers.JsonRpcProvider(`http://127.0.0.1:${port}`), - ) + let privateKey = process.env.PRIVATE_KEY + if (!privateKey) { + // this is a private key provided by anvil + privateKey = 'ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' + } + + const admin = new Wallet(privateKey, new providers.JsonRpcProvider(`http://127.0.0.1:${port}`)) const contracts = await deployFunctionsOracle(admin) diff --git a/test/integration/localFunctionsTestnet.test.ts b/test/integration/localFunctionsTestnet.test.ts index a5ab975..6497fc4 100644 --- a/test/integration/localFunctionsTestnet.test.ts +++ b/test/integration/localFunctionsTestnet.test.ts @@ -304,14 +304,14 @@ describe('Local Functions Testnet', () => { }) it('getFunds throws error for invalid weiAmount', async () => { - expect(async () => { + await expect(async () => { // @ts-ignore await getFunds('0xc0ffee254729296a45a3885639AC7E10F9d54979', { weiAmount: 1 }) }).rejects.toThrow(/weiAmount must be a BigInt or string/) }) it('getFunds throws error for invalid juelsAmount', async () => { - expect(async () => { + await expect(async () => { // @ts-ignore await getFunds('0xc0ffee254729296a45a3885639AC7E10F9d54979', { juelsAmount: 1 }) }).rejects.toThrow(/juelsAmount must be a BigInt or string/) diff --git a/test/utils/index.ts b/test/utils/index.ts index dbd6309..2f39aa5 100644 --- a/test/utils/index.ts +++ b/test/utils/index.ts @@ -44,8 +44,7 @@ export const setupLocalTestnetFixture = async ( utils.formatBytes32String(localFunctionsTestnet.donId), ) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [_admin, user_A, user_B_NoLINK, subFunder, _] = createTestWallets(port) + const [user_A, user_B_NoLINK, subFunder] = createTestWallets(port) const juelsAmount = BigInt(utils.parseUnits('100', 'ether').toString()) await localFunctionsTestnet.getFunds(user_A.address, { @@ -91,11 +90,6 @@ const createTestWallets = (port = 8545): Wallet[] => { provider, ), ) - wallets.push( - new Wallet('47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a').connect( - provider, - ), - ) return wallets }