Skip to content

Commit bd03513

Browse files
authored
pkg/types/llo: add ChannelDefinition source (#1632)
* pkg/types/llo: add source and tombstone to ChannelDefinition * pkg/types/llo: fix comments
1 parent 7a3012c commit bd03513

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

pkg/types/llo/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,14 @@ type ChannelDefinition struct {
268268
//
269269
// May be nil
270270
Opts ChannelOpts `json:"opts"`
271+
// Source is the source of the channel definition.
272+
// It is set by the LLO channel definitions cache.
273+
// The source is the id of the role that added the channel definition (i.e. the channel adder)
274+
// 1 is always the ChannelConfigStore owner, greater values are adders.
275+
Source uint32 `json:"-"`
276+
// Tombstone indicates if the channel definition is an owner tombstone that
277+
// should be removed from the current channel definitions cache.
278+
Tombstone bool `json:"tombstone"`
271279
}
272280

273281
func (a ChannelDefinition) Equals(b ChannelDefinition) bool {

pkg/types/llo/types_test.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func Test_ChannelDefinitions_Serialization(t *testing.T) {
1717
{"streamId": 1, "aggregator": "median"},
1818
{"streamId": 2, "aggregator": "mode"}
1919
],
20-
"opts": null
20+
"opts": null,
21+
"tombstone": false
2122
},
2223
"1": {
2324
"reportFormat": "evm_premium_legacy",
@@ -31,7 +32,8 @@ func Test_ChannelDefinitions_Serialization(t *testing.T) {
3132
"multiplier": "1000000000000000000",
3233
"feedId": "0x0003aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3334
"baseUSDFee": "0.1"
34-
}
35+
},
36+
"tombstone": false
3537
}
3638
}`
3739
var channelDefinitions ChannelDefinitions
@@ -42,8 +44,6 @@ func Test_ChannelDefinitions_Serialization(t *testing.T) {
4244
require.NoError(t, err)
4345

4446
assert.JSONEq(t, inputJSON, string(marshaledJSON))
45-
46-
assert.Equal(t, `{"0":{"reportFormat":"json","streams":[{"streamId":1,"aggregator":"median"},{"streamId":2,"aggregator":"mode"}],"opts":null},"1":{"reportFormat":"evm_premium_legacy","streams":[{"streamId":1,"aggregator":"median"},{"streamId":2,"aggregator":"median"},{"streamId":3,"aggregator":"quote"}],"opts":{"baseUSDFee":"0.1","expirationWindow":86400,"feedId":"0x0003aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","multiplier":"1000000000000000000"}}}`, string(marshaledJSON))
4747
}
4848

4949
func Test_ChannelDefinition_Equals(t *testing.T) {
@@ -169,6 +169,32 @@ func Test_ChannelDefinitions_Value(t *testing.T) {
169169
}
170170
v, err := c.Value()
171171
require.NoError(t, err)
172-
assert.Equal(t, `{"0":{"reportFormat":"json","streams":[{"streamId":1,"aggregator":"median"},{"streamId":2,"aggregator":"mode"}],"opts":null},"1":{"reportFormat":"evm_premium_legacy","streams":[{"streamId":1,"aggregator":"median"},{"streamId":2,"aggregator":"median"},{"streamId":3,"aggregator":"quote"}],"opts":{"baseUSDFee":"0.1","expirationWindow":86400,"feedId":"0x0003aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","multiplier":"1000000000000000000"}}}`, string(v.([]byte)))
172+
expectedJSON := `{
173+
"0": {
174+
"reportFormat": "json",
175+
"streams": [
176+
{"streamId": 1, "aggregator": "median"},
177+
{"streamId": 2, "aggregator": "mode"}
178+
],
179+
"opts": null,
180+
"tombstone": false
181+
},
182+
"1": {
183+
"reportFormat": "evm_premium_legacy",
184+
"streams": [
185+
{"streamId": 1, "aggregator": "median"},
186+
{"streamId": 2, "aggregator": "median"},
187+
{"streamId": 3, "aggregator": "quote"}
188+
],
189+
"opts": {
190+
"baseUSDFee": "0.1",
191+
"expirationWindow": 86400,
192+
"feedId": "0x0003aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
193+
"multiplier": "1000000000000000000"
194+
},
195+
"tombstone": false
196+
}
197+
}`
198+
assert.JSONEq(t, expectedJSON, string(v.([]byte)))
173199
})
174200
}

0 commit comments

Comments
 (0)