From 188676aaf38cdcc1457e66c6d978c8c8feb8d1d7 Mon Sep 17 00:00:00 2001 From: Tarek Mohamed Abdalla Date: Tue, 31 Dec 2024 14:17:06 +0200 Subject: [PATCH] fix: contract tests. --- .../test-contract/test-contract-error.ts | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/test/suites/dev/moonbase/test-contract/test-contract-error.ts b/test/suites/dev/moonbase/test-contract/test-contract-error.ts index 67c2563ccd..fcc135f139 100644 --- a/test/suites/dev/moonbase/test-contract/test-contract-error.ts +++ b/test/suites/dev/moonbase/test-contract/test-contract-error.ts @@ -6,21 +6,24 @@ import { describeSuite, expect, } from "@moonwall/cli"; -import { ALITH_ADDRESS, createEthersTransaction } from "@moonwall/util"; -import { encodeFunctionData, type Abi } from "viem"; -import { verifyLatestBlockFees } from "../../../../helpers"; +import {CHARLETH_PRIVATE_KEY, CHARLETH_ADDRESS, createEthersTransaction} from "@moonwall/util"; +import {encodeFunctionData, type Abi} from "viem"; +import {verifyLatestBlockFees} from "../../../../helpers"; // TODO: expand these tests to do multiple txn types when added to viem describeSuite({ id: "D010603", title: "Contract loop error", foundationMethods: "dev", - testCases: ({ context, it, log }) => { + testCases: ({context, it, log}) => { let looperAddress: `0x${string}`; let looperAbi: Abi; beforeAll(async () => { - const { contractAddress, abi } = await deployCreateCompiledContract(context, "Looper"); + const { + contractAddress, + abi + } = await deployCreateCompiledContract(context, "Looper", {privateKey: CHARLETH_PRIVATE_KEY}); looperAddress = contractAddress; looperAbi = abi; @@ -34,9 +37,9 @@ describeSuite({ expect( async () => await context.viem().call({ - account: ALITH_ADDRESS, + account: CHARLETH_ADDRESS, to: looperAddress, - data: encodeFunctionData({ abi: looperAbi, functionName: "infinite", args: [] }), + data: encodeFunctionData({abi: looperAbi, functionName: "infinite", args: []}), gas: 12_000_000n, }), "Execution succeeded but should have failed" @@ -49,15 +52,16 @@ describeSuite({ title: `should fail with OutOfGas on infinite loop ${txnType} transaction`, test: async function () { const rawSigned = await createEthersTransaction(context, { + privateKey: CHARLETH_PRIVATE_KEY, to: looperAddress, - data: encodeFunctionData({ abi: looperAbi, functionName: "infinite", args: [] }), + data: encodeFunctionData({abi: looperAbi, functionName: "infinite", args: []}), txnType, }); - const { result } = await context.createBlock(rawSigned); + const {result} = await context.createBlock(rawSigned); const receipt = await context .viem("public") - .getTransactionReceipt({ hash: result!.hash as `0x${string}` }); + .getTransactionReceipt({hash: result!.hash as `0x${string}`}); expect(receipt.status).toBe("reverted"); }, }); @@ -67,8 +71,9 @@ describeSuite({ title: `should fail with OutOfGas on infinite loop ${txnType} transaction - check fees`, test: async function () { const rawSigned = await createEthersTransaction(context, { + privateKey: CHARLETH_PRIVATE_KEY, to: looperAddress, - data: encodeFunctionData({ abi: looperAbi, functionName: "infinite", args: [] }), + data: encodeFunctionData({abi: looperAbi, functionName: "infinite", args: []}), txnType, });