516972119c
* evm: unit tests * Add unit tests for DynamicFeeTx.Validate() * Start get and set signature values tests * get set values * Add tests for GetTo() * Add GetNonce test * Add GetValue test * Start copy test * Add WIP newDynamicFeeTx test * Add WIP legacy_tx_test * pair programming session * Add TestLegacyTxValidate * Add TestLegacyTxSetSignatureValues & GetSignatureValues * Add legacyTx tests * Merge main, forgot to save one file * Add AccessList tests * Add chain Config (fork order) * Add invalid genesis account test * Add params tests * Add WIP tracer test * tracer tests * Add FormatLogs tests * Add NewNoOpTracer test * Refactor to test suite * Refactor Tx Test suits to only use TxDataTestSuite * Update link to geth interpreter * Update x/evm/types/params.go * Refactor accessListTx Test suits to use TxDataTestSuite Co-authored-by: Daniel Burckhardt <daniel.m.burckhardt@gmail.com>
84 lines
1.3 KiB
Go
84 lines
1.3 KiB
Go
package types
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/core/vm"
|
|
"github.com/holiman/uint256"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFormatLogs(t *testing.T) {
|
|
zeroUint256 := []uint256.Int{*uint256.NewInt(0)}
|
|
zeroByte := []byte{5}
|
|
zeroStorage := make(map[string]string)
|
|
|
|
testCases := []struct {
|
|
name string
|
|
logs []vm.StructLog
|
|
exp []StructLogRes
|
|
}{
|
|
{
|
|
"empty logs",
|
|
[]vm.StructLog{},
|
|
[]StructLogRes{},
|
|
},
|
|
{
|
|
"non-empty stack",
|
|
[]vm.StructLog{
|
|
{
|
|
Stack: zeroUint256,
|
|
},
|
|
},
|
|
[]StructLogRes{
|
|
{
|
|
Pc: uint64(0),
|
|
Op: "STOP",
|
|
Stack: &[]string{fmt.Sprintf("%x", zeroUint256[0])},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"non-empty memory",
|
|
[]vm.StructLog{
|
|
{
|
|
Memory: zeroByte,
|
|
},
|
|
},
|
|
[]StructLogRes{
|
|
{
|
|
Pc: uint64(0),
|
|
Op: "STOP",
|
|
Memory: &[]string{},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"non-empty storage",
|
|
[]vm.StructLog{
|
|
{
|
|
Storage: make(map[common.Hash]common.Hash),
|
|
},
|
|
},
|
|
[]StructLogRes{
|
|
{
|
|
Pc: uint64(0),
|
|
Op: "STOP",
|
|
Storage: &zeroStorage,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
actual := FormatLogs(tc.logs)
|
|
|
|
require.Equal(t, tc.exp, actual)
|
|
}
|
|
}
|
|
|
|
func TestNewNoOpTracer(t *testing.T) {
|
|
require.Equal(t, &NoOpTracer{}, NewNoOpTracer())
|
|
}
|