mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-15 00:48:01 -05:00
Co-authored-by: Richard Zhang <rzhang139@gmail.com> Co-authored-by: georgehao <haohongfan@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Co-authored-by: HAOYUatHZ <haoyu@protonmail.com>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package watcher
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"scroll-tech/bridge/internal/config"
|
|
"scroll-tech/bridge/internal/orm"
|
|
bridgeTypes "scroll-tech/bridge/internal/types"
|
|
"scroll-tech/bridge/internal/utils"
|
|
)
|
|
|
|
// TODO: Add unit tests that the limits are enforced correctly.
|
|
func testChunkProposer(t *testing.T) {
|
|
db := setupDB(t)
|
|
defer utils.CloseDB(db)
|
|
|
|
l2BlockOrm := orm.NewL2Block(db)
|
|
err := l2BlockOrm.InsertL2Blocks(context.Background(), []*bridgeTypes.WrappedBlock{wrappedBlock1, wrappedBlock2})
|
|
assert.NoError(t, err)
|
|
|
|
cp := NewChunkProposer(context.Background(), &config.ChunkProposerConfig{
|
|
MaxTxGasPerChunk: 1000000000,
|
|
MaxL2TxNumPerChunk: 10000,
|
|
MaxL1CommitGasPerChunk: 50000000000,
|
|
MaxL1CommitCalldataSizePerChunk: 1000000,
|
|
MinL1CommitCalldataSizePerChunk: 0,
|
|
ChunkTimeoutSec: 300,
|
|
}, db)
|
|
cp.TryProposeChunk()
|
|
|
|
expectedChunk := &bridgeTypes.Chunk{
|
|
Blocks: []*bridgeTypes.WrappedBlock{wrappedBlock1, wrappedBlock2},
|
|
}
|
|
expectedHash, err := expectedChunk.Hash(0)
|
|
assert.NoError(t, err)
|
|
|
|
chunkOrm := orm.NewChunk(db)
|
|
chunks, err := chunkOrm.GetUnbatchedChunks(context.Background())
|
|
assert.NoError(t, err)
|
|
assert.Len(t, chunks, 1)
|
|
assert.Equal(t, expectedHash.Hex(), chunks[0].Hash)
|
|
}
|