diff --git a/.vscode/launch.json b/.vscode/launch.json index 1f580137..85f6a729 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -45,5 +45,16 @@ "preLaunchTask": "rebuild-contracts", "cwd": "${workspaceFolder}" }, + { + "name": "E2E Tests", + "type": "node", + "request": "launch", + "console": "integratedTerminal", + "cwd": "${workspaceFolder}/e2e-tests", + "runtimeExecutable": "yarn", + "runtimeArgs": [ + "test" + ] + }, ] } \ No newline at end of file diff --git a/e2e-tests/test/evm-apis.test.ts b/e2e-tests/test/evm-apis.test.ts index 97a1cda6..8bf06c4e 100644 --- a/e2e-tests/test/evm-apis.test.ts +++ b/e2e-tests/test/evm-apis.test.ts @@ -21,6 +21,7 @@ xdescribe("evm_mine", function () { }); }); +// TODO: Investigate why this fails on new node with no transactions describe("evm_increaseTime", function () { it("Should increase current timestamp of the node", async function () { // Arrange diff --git a/e2e-tests/test/main.test.ts b/e2e-tests/test/main.test.ts index 8a59a904..6109e875 100644 --- a/e2e-tests/test/main.test.ts +++ b/e2e-tests/test/main.test.ts @@ -9,6 +9,7 @@ import { expectThrowsAsync, getTestProvider, } from "../helpers/utils"; +import { TransactionReceipt } from "zksync-web3/build/src/types"; const provider = getTestProvider(); @@ -53,7 +54,6 @@ describe("Greeter Smart Contract", function () { }); it("Should produce event logs", async function () { - // TODO: Figure out a test for this const wallet = new Wallet(RichAccounts[0].PrivateKey); const deployer = new Deployer(hre, wallet); @@ -61,10 +61,16 @@ describe("Greeter Smart Contract", function () { expect(await greeter.greet()).to.eq("Hi"); - const setGreetingTx = await greeter.setGreeting("Hola, mundo!"); - // wait until the transaction is mined - await setGreetingTx.wait(); - - expect(await greeter.greet()).to.equal("Hola, mundo!"); + const setGreetingTx = await greeter.setGreeting("Luke Skywalker"); + const receipt: TransactionReceipt = await setGreetingTx.wait(); + + // Validate log is created + expect(receipt.logs.length).to.greaterThanOrEqual(1); + const setGreetingLog = receipt.logs[1]; + expect(setGreetingLog.address).to.equal(greeter.address); + const normalizedSetGreetingLogData = ethers.utils.toUtf8String(setGreetingLog.data) + .replaceAll("\u0000", "") + .replace(" +", ""); + expect(normalizedSetGreetingLogData).to.equal("Greeting is being updated to Luke Skywalker"); }); });