fix tests

This commit is contained in:
jonastheis
2025-03-10 14:03:02 +08:00
parent 47219f2d86
commit 95adcc378f
2 changed files with 23 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package watcher
import (
"context"
"fmt"
"math"
"math/big"
"testing"
@@ -11,6 +12,8 @@ import (
gethTypes "github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/params"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
"scroll-tech/common/database"
"scroll-tech/common/types"
@@ -119,6 +122,24 @@ func testBundleProposerLimitsCodecV4(t *testing.T) {
BundleTimeoutSec: tt.bundleTimeoutSec,
}, encoding.CodecV4, chainConfig, db, nil)
batches, err := batchOrm.GetBatches(context.Background(), map[string]interface{}{}, []string{}, 0)
require.NoError(t, err)
require.Len(t, batches, 3) // genesis batch + batch1 + batch2
batches = batches[1:] // remove genesis batch
// simulate batches 1 and 2 being submitted in separate transactions -> need it to be able to propose bundles
err = db.Transaction(func(dbTX *gorm.DB) error {
if err = batchOrm.UpdateCommitTxHashAndRollupStatus(context.Background(), batches[0].Hash, "0xdefdef", types.RollupCommitted, dbTX); err != nil {
return fmt.Errorf("UpdateCommitTxHashAndRollupStatus failed for batch %d: %s, err %v", batches[0].Index, batches[0].Hash, err)
}
if err = batchOrm.UpdateCommitTxHashAndRollupStatus(context.Background(), batches[1].Hash, "0xabcabc", types.RollupCommitted, dbTX); err != nil {
return fmt.Errorf("UpdateCommitTxHashAndRollupStatus failed for batch %d: %s, err %v", batches[1].Index, batches[1].Hash, err)
}
return nil
})
require.NoError(t, err)
bup.TryProposeBundle()
bundleOrm := orm.NewBundle(db)

View File

@@ -310,6 +310,8 @@ func TestBatchOrm(t *testing.T) {
assert.Equal(t, types.GasOracleImported, types.GasOracleStatus(updatedBatch.OracleStatus))
assert.Equal(t, "oracleTxHash", updatedBatch.OracleTxHash)
err = batchOrm.UpdateCommitTxHashAndRollupStatus(context.Background(), batchHash1, "commitTxHash", types.RollupCommitted)
assert.NoError(t, err)
err = batchOrm.UpdateCommitTxHashAndRollupStatus(context.Background(), batchHash2, "commitTxHash", types.RollupCommitted)
assert.NoError(t, err)
updatedBatch, err = batchOrm.GetLatestBatch(context.Background())