Skip to content

Commit

Permalink
deep equal
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Oct 17, 2024
1 parent 642cf03 commit e273568
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions sequencing/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"reflect"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -597,9 +598,7 @@ func (c *Sequencer) GetNextBatch(ctx context.Context, req sequencing.GetNextBatc
lastBatchHash := c.lastBatchHash
c.lastBatchHashMutex.RUnlock()

if (lastBatchHash == nil && req.LastBatchHash != nil) || (lastBatchHash != nil && req.LastBatchHash == nil) {
return nil, fmt.Errorf("nil mismatch: lastBatchHash = %v, req.LastBatchHash = %v", lastBatchHash, req.LastBatchHash)
} else if lastBatchHash != nil && !bytes.Equal(lastBatchHash, req.LastBatchHash) {
if !reflect.DeepEqual(lastBatchHash, req.LastBatchHash) {
return nil, fmt.Errorf("batch hash mismatch: lastBatchHash = %x, req.LastBatchHash = %x", lastBatchHash, req.LastBatchHash)
}

Expand Down
2 changes: 1 addition & 1 deletion sequencing/sequencer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestSequencer_GetNextBatch_LastBatchNilMismatch(t *testing.T) {

// Test case where lastBatchHash is nil but seq.lastBatchHash is not
res, err := seq.GetNextBatch(context.Background(), sequencing.GetNextBatchRequest{RollupId: seq.rollupId, LastBatchHash: nil})
assert.ErrorContains(t, err, "nil mismatch")
assert.ErrorContains(t, err, "batch hash mismatch")
assert.Nil(t, res)
}

Expand Down

0 comments on commit e273568

Please sign in to comment.