mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-14 00:18:03 -05:00
26 lines
641 B
Go
26 lines
641 B
Go
package utils_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/scroll-tech/go-ethereum/core/types"
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"scroll-tech/common/utils"
|
|
)
|
|
|
|
// TestComputeTraceCost test ComputeTraceGasCost function
|
|
func TestComputeTraceCost(t *testing.T) {
|
|
templateBlockTrace, err := os.ReadFile("../testdata/blockTrace_03.json")
|
|
assert.NoError(t, err)
|
|
// unmarshal blockTrace
|
|
blockTrace := &types.BlockTrace{}
|
|
err = json.Unmarshal(templateBlockTrace, blockTrace)
|
|
assert.NoError(t, err)
|
|
var expected = blockTrace.Header.GasUsed
|
|
got := utils.ComputeTraceGasCost(blockTrace)
|
|
assert.Equal(t, expected, got)
|
|
}
|