Skip to content

Commit

Permalink
fix GetNextBatch of dummy sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Aug 8, 2024
1 parent 4a58a77 commit 9591858
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,28 @@ func (d *DummySequencer) SubmitRollupTransaction(ctx context.Context, rollupId [

// GetNextBatch implements sequencing.Sequencer.
func (d *DummySequencer) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch) (*sequencing.Batch, error) {
if d.lastBatchHash == nil {
if lastBatch != nil {
return nil, errors.New("lastBatch is supposed to be nil")
}
} else if lastBatch == nil {
return nil, errors.New("lastBatch is not supposed to be nil")
} else {
lastBatchBytes, err := lastBatch.Marshal()
if err != nil {
return nil, err
}
if !bytes.Equal(d.lastBatchHash, hashSHA256(lastBatchBytes)) {
return nil, errors.New("supplied lastBatch does not match with sequencer last batch")
}
}

batch := d.tq.GetNextBatch()
batchBytes, err := batch.Marshal()
if err != nil {
return nil, err
}

d.lastBatchHash = hashSHA256(batchBytes)
d.seenBatches[string(d.lastBatchHash)] = struct{}{}
return &batch, nil
Expand Down

0 comments on commit 9591858

Please sign in to comment.