Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Jan 24, 2025
1 parent 343ced8 commit 831a9e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
17 changes: 9 additions & 8 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3032,15 +3032,16 @@ func TestPoseidonCodeHash(t *testing.T) {
var callCreate2Code = common.Hex2Bytes("f4754f660000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005c6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220707985753fcb6578098bb16f3709cf6d012993cba6dd3712661cf8f57bbc0d4d64736f6c6343000807003300000000")

var (
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
db = rawdb.NewMemoryDatabase()
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}}
genesis = gspec.MustCommit(db)
signer = types.LatestSigner(gspec.Config)
engine = ethash.NewFaker()
blockchain, _ = NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil)
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
db = rawdb.NewMemoryDatabase()
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000000)}}}
signer = types.LatestSigner(gspec.Config)
engine = ethash.NewFaker()
)
gspec.Config.Scroll.UseZktrie = true
genesis := gspec.MustCommit(db)
blockchain, _ := NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, nil, nil)

defer blockchain.Stop()

Expand Down
3 changes: 2 additions & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/scroll-tech/go-ethereum/ethdb"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/fees"
"github.com/scroll-tech/go-ethereum/trie"
)

// BlockGen creates blocks for testing.
Expand Down Expand Up @@ -264,7 +265,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
return nil, nil
}
for i := 0; i < n; i++ {
statedb, err := state.New(parent.Root(), state.NewDatabase(db), nil)
statedb, err := state.New(parent.Root(), state.NewDatabaseWithConfig(db, &trie.Config{Zktrie: config.Scroll.ZktrieEnabled()}), nil)
if err != nil {
panic(err)
}
Expand Down
9 changes: 9 additions & 0 deletions miner/scroll_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func testGenerateBlockWithL1Msg(t *testing.T, isClique bool) {
NumL1MessagesPerBlock: 1,
}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true

chainConfig.LondonBlock = big.NewInt(0)
w, b := newTestWorker(t, chainConfig, engine, db, 0)
Expand Down Expand Up @@ -344,6 +345,7 @@ func TestAcceptableTxlimit(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)

// Set maxTxPerBlock = 4, which >= non-l1msg + non-skipped l1msg txs
Expand Down Expand Up @@ -404,6 +406,7 @@ func TestUnacceptableTxlimit(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)

// Set maxTxPerBlock = 3, which < non-l1msg + l1msg txs
Expand Down Expand Up @@ -463,6 +466,7 @@ func TestL1MsgCorrectOrder(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)

maxTxPerBlock := 4
Expand Down Expand Up @@ -525,6 +529,7 @@ func l1MessageTest(t *testing.T, msgs []types.L1MessageTx, withL2Tx bool, callba

chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)
maxTxPerBlock := 4
chainConfig.Scroll.MaxTxPerBlock = &maxTxPerBlock
Expand Down Expand Up @@ -879,6 +884,7 @@ func TestPrioritizeOverflowTx(t *testing.T) {
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.LondonBlock = big.NewInt(0)
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine := clique.New(chainConfig.Clique, db)

w, b := newTestWorker(t, chainConfig, engine, db, 0)
Expand Down Expand Up @@ -1036,6 +1042,7 @@ func TestPending(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)
w, b := newTestWorker(t, chainConfig, engine, db, 0)
defer w.close()
Expand Down Expand Up @@ -1080,6 +1087,7 @@ func TestReorg(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000, RelaxedPeriod: true}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)

maxTxPerBlock := 2
Expand Down Expand Up @@ -1194,6 +1202,7 @@ func TestRestartHeadCCC(t *testing.T) {
chainConfig = params.AllCliqueProtocolChanges
chainConfig.Clique = &params.CliqueConfig{Period: 1, Epoch: 30000, RelaxedPeriod: true}
chainConfig.Scroll.FeeVaultAddress = &common.Address{}
chainConfig.Scroll.UseZktrie = true
engine = clique.New(chainConfig.Clique, db)

maxTxPerBlock := 2
Expand Down

0 comments on commit 831a9e6

Please sign in to comment.