Skip to content

Commit

Permalink
Fix ocr3 exec unit test. (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
winder authored Jun 4, 2024
1 parent 9cf06a6 commit 4de8351
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-spiders-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": patch
---

#internal Fix unit tests in ocr3 exec plugin
24 changes: 21 additions & 3 deletions core/services/ocr3/plugins/ccip/execute/plugin_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,32 @@ func filterOutExecutedMessages(reports []model.ExecutePluginCommitData, executed
break
}

reportIdx++
if executed.End() < reportRange.Start() {
// add report that has non-executed messages.
reportIdx++
filtered = append(filtered, reports[i])
continue
}

if reportRange.Start() >= executed.Start() && reportRange.End() <= executed.End() {
// fully executed report
// skip fully executed report.
reportIdx++
continue
}

filtered = append(filtered, reports[i])
s := executed.Start()
if reportRange.Start() > executed.Start() {
s = reportRange.Start()
}
for ; s <= executed.End(); s++ {
// This range runs into the next report.
if s > reports[i].SequenceNumberRange.End() {
reportIdx++
filtered = append(filtered, reports[i])
break
}
reports[i].ExecutedMessages = append(reports[i].ExecutedMessages, s)
}
}
}

Expand Down
20 changes: 16 additions & 4 deletions core/services/ocr3/plugins/ccip/execute/plugin_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,14 @@ func Test_filterOutFullyExecutedMessages(t *testing.T) {
},
},
want: []model.ExecutePluginCommitData{
{SequenceNumberRange: model.NewSeqNumRange(10, 20)},
{SequenceNumberRange: model.NewSeqNumRange(30, 40)},
{
SequenceNumberRange: model.NewSeqNumRange(10, 20),
ExecutedMessages: []model.SeqNum{15, 16, 17, 18, 19, 20},
},
{
SequenceNumberRange: model.NewSeqNumRange(30, 40),
ExecutedMessages: []model.SeqNum{30, 31, 32, 33, 34, 35},
},
{SequenceNumberRange: model.NewSeqNumRange(50, 60)},
},
wantErr: assert.NoError,
Expand All @@ -402,8 +408,14 @@ func Test_filterOutFullyExecutedMessages(t *testing.T) {
},
},
want: []model.ExecutePluginCommitData{
{SequenceNumberRange: model.NewSeqNumRange(10, 20)},
{SequenceNumberRange: model.NewSeqNumRange(50, 60)},
{
SequenceNumberRange: model.NewSeqNumRange(10, 20),
ExecutedMessages: []model.SeqNum{15, 16, 17, 18, 19, 20},
},
{
SequenceNumberRange: model.NewSeqNumRange(50, 60),
ExecutedMessages: []model.SeqNum{50, 51, 52, 53, 54, 55},
},
},
wantErr: assert.NoError,
},
Expand Down

0 comments on commit 4de8351

Please sign in to comment.