Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 2261ccc

Browse files
authored
add log0 debug trace e2e tests (#3422)
* add log0 debug trace e2e tests * add log0 debug trace e2e tests
1 parent 1365a55 commit 2261ccc

File tree

5 files changed

+365
-0
lines changed

5 files changed

+365
-0
lines changed

test/contracts/auto/Log0.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
pragma solidity >=0.7.0 <0.9.0;
3+
4+
contract Log0 {
5+
// opcode 0xa0
6+
function opLog0() public payable {
7+
assembly {
8+
log0(0, 32)
9+
}
10+
}
11+
12+
function opLog00() public payable {
13+
assembly {
14+
log0(0, 0)
15+
}
16+
}
17+
18+
function opLog01() public payable {
19+
assembly {
20+
log0(0, 28)
21+
}
22+
}
23+
}

test/contracts/bin/Log0/Log0.go

Lines changed: 266 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/debug_calltracer_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ func TestDebugTraceTransactionCallTracer(t *testing.T) {
104104
{name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
105105
{name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
106106
{name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
107+
{name: "log0 all zeros", prepare: prepareLog0, createSignedTx: createLog0AllZeros},
108+
{name: "log0 empty", prepare: prepareLog0, createSignedTx: createLog0Empty},
109+
{name: "log0 short", prepare: prepareLog0, createSignedTx: createLog0Short},
107110

108111
// failed transactions
109112
{name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},

test/e2e/debug_shared.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/Depth"
2727
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/ERC20"
2828
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/EmitLog"
29+
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/Log0"
2930
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/Memory"
3031
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/OpCallAux"
3132
"github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/Revert2"
@@ -883,3 +884,72 @@ func sendEthTransfersWithoutWaiting(t *testing.T, ctx context.Context, client *e
883884
log.Debugf("sending eth transfer: %v", signedTx.Hash().String())
884885
}
885886
}
887+
888+
func prepareLog0(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client) (map[string]interface{}, error) {
889+
_, tx, sc, err := Log0.DeployLog0(auth, client)
890+
require.NoError(t, err)
891+
892+
err = operations.WaitTxToBeMined(ctx, client, tx, operations.DefaultTimeoutTxToBeMined)
893+
require.NoError(t, err)
894+
895+
return map[string]interface{}{
896+
"sc": sc,
897+
}, nil
898+
}
899+
900+
func createLog0AllZeros(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
901+
scInterface := customData["sc"]
902+
sc := scInterface.(*Log0.Log0)
903+
904+
gasPrice, err := client.SuggestGasPrice(ctx)
905+
require.NoError(t, err)
906+
907+
opts := *auth
908+
opts.NoSend = true
909+
opts.Value = big.NewInt(0).SetUint64(txValue)
910+
opts.GasPrice = gasPrice
911+
opts.GasLimit = fixedTxGasLimit
912+
913+
tx, err := sc.OpLog0(&opts)
914+
require.NoError(t, err)
915+
916+
return tx, nil
917+
}
918+
919+
func createLog0Empty(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
920+
scInterface := customData["sc"]
921+
sc := scInterface.(*Log0.Log0)
922+
923+
gasPrice, err := client.SuggestGasPrice(ctx)
924+
require.NoError(t, err)
925+
926+
opts := *auth
927+
opts.NoSend = true
928+
opts.Value = big.NewInt(0).SetUint64(txValue)
929+
opts.GasPrice = gasPrice
930+
opts.GasLimit = fixedTxGasLimit
931+
932+
tx, err := sc.OpLog00(&opts)
933+
require.NoError(t, err)
934+
935+
return tx, nil
936+
}
937+
938+
func createLog0Short(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
939+
scInterface := customData["sc"]
940+
sc := scInterface.(*Log0.Log0)
941+
942+
gasPrice, err := client.SuggestGasPrice(ctx)
943+
require.NoError(t, err)
944+
945+
opts := *auth
946+
opts.NoSend = true
947+
opts.Value = big.NewInt(0).SetUint64(txValue)
948+
opts.GasPrice = gasPrice
949+
opts.GasLimit = fixedTxGasLimit
950+
951+
tx, err := sc.OpLog01(&opts)
952+
require.NoError(t, err)
953+
954+
return tx, nil
955+
}

test/e2e/debug_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ func TestDebugTraceTransaction(t *testing.T) {
318318
{name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
319319
{name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
320320
{name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
321+
{name: "log0 all zeros", prepare: prepareLog0, createSignedTx: createLog0AllZeros},
322+
{name: "log0 empty", prepare: prepareLog0, createSignedTx: createLog0Empty},
323+
{name: "log0 short", prepare: prepareLog0, createSignedTx: createLog0Short},
321324

322325
// failed transactions
323326
{name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},

0 commit comments

Comments
 (0)