From 139e10306b0d402335f945afa0d7f6d9946661c1 Mon Sep 17 00:00:00 2001 From: lucac-zilliqa Date: Tue, 18 Jul 2023 18:23:59 +0200 Subject: [PATCH 1/3] Added additional tests to check edge cases --- tests/EvmAcceptanceTests/test/OtterTests.ts | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/EvmAcceptanceTests/test/OtterTests.ts b/tests/EvmAcceptanceTests/test/OtterTests.ts index d457e965cd..e5e0898b21 100644 --- a/tests/EvmAcceptanceTests/test/OtterTests.ts +++ b/tests/EvmAcceptanceTests/test/OtterTests.ts @@ -41,6 +41,22 @@ describe("Otterscan api tests", function () { }); }); + it("When TX succeeds, we can get 0x", async function () { + const METHOD = "ots_getTransactionError"; + + // Create a simple contract creation transaction that will succeed and so API request returns "Ox" + const Contract = await ethers.getContractFactory("Success"); + const contract = await Contract.deploy(); + + await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => { + assert.equal(status, 200, "has status code"); + + let jsonObject = result.result; + + assert.equal(jsonObject, "0x"); + }); + }); + it("We can get the otter internal operations", async function () { const METHOD = "ots_getInternalOperations"; @@ -72,6 +88,23 @@ describe("Otterscan api tests", function () { }); }); + it("When a contract has no internal operations, we get empty list", async function () { + const METHOD = "ots_getInternalOperations"; + + // Create a simple contract creation transaction which involves no internal operations + // so API call returns [] + const Contract = await ethers.getContractFactory("Success"); + const contract = await Contract.deploy(); + + await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => { + assert.equal(status, 200, "has status code"); + + let jsonObject = result.result; + + assert(Array.isArray(jsonObject) && !jsonObject.length); + }); + }); + it("We can get the otter trace transaction", async function () { const METHOD = "ots_traceTransaction"; From 1be5b190335249b491dd40668d8ccf49feb702d4 Mon Sep 17 00:00:00 2001 From: lucac-zilliqa Date: Tue, 18 Jul 2023 19:10:15 +0200 Subject: [PATCH 2/3] Fix ContractFactory string name --- tests/EvmAcceptanceTests/test/OtterTests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/EvmAcceptanceTests/test/OtterTests.ts b/tests/EvmAcceptanceTests/test/OtterTests.ts index e5e0898b21..8de2ae15f7 100644 --- a/tests/EvmAcceptanceTests/test/OtterTests.ts +++ b/tests/EvmAcceptanceTests/test/OtterTests.ts @@ -45,7 +45,7 @@ describe("Otterscan api tests", function () { const METHOD = "ots_getTransactionError"; // Create a simple contract creation transaction that will succeed and so API request returns "Ox" - const Contract = await ethers.getContractFactory("Success"); + const Contract = await ethers.getContractFactory("ZeroParamConstructor"); const contract = await Contract.deploy(); await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => { @@ -93,7 +93,7 @@ describe("Otterscan api tests", function () { // Create a simple contract creation transaction which involves no internal operations // so API call returns [] - const Contract = await ethers.getContractFactory("Success"); + const Contract = await ethers.getContractFactory("ZeroParamConstructor"); const contract = await Contract.deploy(); await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => { From 8e00ac894426b8eb498c6b2488a47a2af185cf5c Mon Sep 17 00:00:00 2001 From: lucac-zilliqa Date: Wed, 19 Jul 2023 12:31:07 +0200 Subject: [PATCH 3/3] Replace ContractFactory string name --- tests/EvmAcceptanceTests/test/OtterTests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/EvmAcceptanceTests/test/OtterTests.ts b/tests/EvmAcceptanceTests/test/OtterTests.ts index 8de2ae15f7..e3ccd4532f 100644 --- a/tests/EvmAcceptanceTests/test/OtterTests.ts +++ b/tests/EvmAcceptanceTests/test/OtterTests.ts @@ -45,7 +45,7 @@ describe("Otterscan api tests", function () { const METHOD = "ots_getTransactionError"; // Create a simple contract creation transaction that will succeed and so API request returns "Ox" - const Contract = await ethers.getContractFactory("ZeroParamConstructor"); + const Contract = await ethers.getContractFactory("SimpleContract"); const contract = await Contract.deploy(); await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => { @@ -93,7 +93,7 @@ describe("Otterscan api tests", function () { // Create a simple contract creation transaction which involves no internal operations // so API call returns [] - const Contract = await ethers.getContractFactory("ZeroParamConstructor"); + const Contract = await ethers.getContractFactory("SimpleContract"); const contract = await Contract.deploy(); await sendJsonRpcRequest(METHOD, 1, [contract.deployTransaction.hash], (result, status) => {