mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-04-23 03:00:50 -04:00
fix tests
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user