Skip to content

Commit 319861e

Browse files
authored
Merge pull request #1716 from smartcontractkit/DS-1142-llo-channeldefinitioncache
pkg/types/llo: ChannelDefinitionCache accepts the previous definition
2 parents 4659b78 + 427ef2c commit 319861e

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

pkg/types/llo/types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ type ChannelDefinition struct {
279279
}
280280

281281
func (a ChannelDefinition) Equals(b ChannelDefinition) bool {
282+
if a.Tombstone != b.Tombstone {
283+
return false
284+
}
285+
286+
if a.Source != b.Source {
287+
return false
288+
}
289+
282290
if a.ReportFormat != b.ReportFormat {
283291
return false
284292
}
@@ -359,7 +367,7 @@ func (c ChannelDefinitions) Value() (driver.Value, error) {
359367
type ChannelID = uint32
360368

361369
type ChannelDefinitionCache interface {
362-
Definitions() ChannelDefinitions
370+
Definitions(previous ChannelDefinitions) ChannelDefinitions
363371
services.Service
364372
}
365373

pkg/types/llo/types_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,37 @@ func Test_ChannelDefinition_Equals(t *testing.T) {
101101
}
102102
assert.False(t, a.Equals(b))
103103
})
104+
t.Run("different Tombstone", func(t *testing.T) {
105+
a := ChannelDefinition{
106+
ReportFormat: ReportFormatJSON,
107+
Streams: []Stream{{0, AggregatorMedian}, {1, AggregatorMode}},
108+
Opts: nil,
109+
}
110+
b := ChannelDefinition{
111+
ReportFormat: ReportFormatJSON,
112+
Streams: []Stream{{0, AggregatorMedian}, {1, AggregatorMode}},
113+
Opts: nil,
114+
Tombstone: true,
115+
}
116+
assert.False(t, a.Equals(b))
117+
})
118+
119+
t.Run("different Source", func(t *testing.T) {
120+
a := ChannelDefinition{
121+
ReportFormat: ReportFormatJSON,
122+
Streams: []Stream{{0, AggregatorMedian}, {1, AggregatorMode}},
123+
Opts: nil,
124+
Source: 1,
125+
}
126+
b := ChannelDefinition{
127+
ReportFormat: ReportFormatJSON,
128+
Streams: []Stream{{0, AggregatorMedian}, {1, AggregatorMode}},
129+
Opts: nil,
130+
Source: 2,
131+
}
132+
assert.False(t, a.Equals(b))
133+
})
134+
104135
t.Run("equal", func(t *testing.T) {
105136
a := ChannelDefinition{
106137
ReportFormat: ReportFormatJSON,

0 commit comments

Comments
 (0)