go-ethereum/rollup/fees/rollup_fee_test.go
Péter Garamvölgyi bfe803001b
feat: update L1 data fee in Curie hard fork (#755)
* update fee calculation

* add missing GPO slots to trace

* add placeholder for contract update logic

* nit

* update fee calculation

* update formula

* update GPO slots

* update L1GPO bytecode

* apply Curie in new worker

* move bytecode to config

* create an empty block for curie hard fork

* initialize L1GasPriceOracle storage slots

* add comments

* add test

* add IsCurie to traces and tests

* group GPO storage slots into a struct

* update unit test

* chore: auto version bump [bot]

* trigger ci

* update bytecode

* remove leading 0x

* update comments

* include rollup fee tests in CI

---------

Co-authored-by: Ömer Faruk Irmak <omerfirmak@gmail.com>
Co-authored-by: Thegaram <Thegaram@users.noreply.github.com>
2024-05-28 14:12:39 +02:00

33 lines
889 B
Go

package fees
import (
"math/big"
"testing"
"github.com/stretchr/testify/assert"
)
func TestL1DataFeeBeforeCurie(t *testing.T) {
l1BaseFee := new(big.Int).SetUint64(15000000)
overhead := new(big.Int).SetUint64(100)
scalar := new(big.Int).SetUint64(10)
data := []byte{0, 10, 1, 0}
expected := new(big.Int).SetUint64(30) // 30.6
actual := calculateEncodedL1DataFee(data, overhead, l1BaseFee, scalar)
assert.Equal(t, expected, actual)
}
func TestL1DataFeeAfterCurie(t *testing.T) {
l1BaseFee := new(big.Int).SetUint64(1500000000)
l1BlobBaseFee := new(big.Int).SetUint64(150000000)
commitScalar := new(big.Int).SetUint64(10)
blobScalar := new(big.Int).SetUint64(10)
data := []byte{0, 10, 1, 0}
expected := new(big.Int).SetUint64(21)
actual := calculateEncodedL1DataFeeCurie(data, l1BaseFee, l1BlobBaseFee, commitScalar, blobScalar)
assert.Equal(t, expected, actual)
}