-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parallel Comp (LLO) cleanup and minor optimizations (#15368)
* Parallel Comp (LLO) cleanup and minor optimizations - Add ChannelDefinitionCacheFactory tests - Cleanup TODOs/FIXMEs - Add comments/docs - Include Don ID in LLO extra hash - Optimize log poller calls * Fix test * Fix linter issue re: append * Update core/services/llo/evm/report_codec_premium_legacy.go Co-authored-by: msuchacz-cll <170782674+msuchacz-cll@users.noreply.github.com> --------- Co-authored-by: msuchacz-cll <170782674+msuchacz-cll@users.noreply.github.com>
- Loading branch information
1 parent
b79da55
commit d77db32
Showing
25 changed files
with
304 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
core/services/llo/channel_definition_cache_factory_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package llo | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
lloconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/llo/config" | ||
) | ||
|
||
func Test_ChannelDefinitionCacheFactory(t *testing.T) { | ||
lggr := logger.TestLogger(t) | ||
cdcFactory := NewChannelDefinitionCacheFactory(lggr, nil, nil, nil) | ||
|
||
t.Run("NewCache", func(t *testing.T) { | ||
t.Run("when ChannelDefinitions is present, returns static cache", func(t *testing.T) { | ||
_, err := cdcFactory.NewCache(lloconfig.PluginConfig{ChannelDefinitions: "..."}) | ||
require.EqualError(t, err, "failed to unmarshal static channel definitions: invalid character '.' looking for beginning of value") | ||
|
||
cdc, err := cdcFactory.NewCache(lloconfig.PluginConfig{ChannelDefinitions: "{}"}) | ||
require.NoError(t, err) | ||
require.IsType(t, &staticCDC{}, cdc) | ||
}) | ||
t.Run("when ChannelDefinitions is not present, returns dynamic cache", func(t *testing.T) { | ||
cdc, err := cdcFactory.NewCache(lloconfig.PluginConfig{ | ||
ChannelDefinitionsContractAddress: common.HexToAddress("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
DonID: 1, | ||
}) | ||
require.NoError(t, err) | ||
require.IsType(t, &channelDefinitionCache{}, cdc) | ||
|
||
// returns error if you try to do it again with the same addr/donID | ||
_, err = cdcFactory.NewCache(lloconfig.PluginConfig{ | ||
ChannelDefinitionsContractAddress: common.HexToAddress("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
DonID: 1, | ||
}) | ||
require.EqualError(t, err, "cache already exists for contract address 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa and don ID 1") | ||
|
||
// is fine if you do it again with different addr | ||
cdc, err = cdcFactory.NewCache(lloconfig.PluginConfig{ | ||
ChannelDefinitionsContractAddress: common.HexToAddress("0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), | ||
DonID: 1, | ||
}) | ||
require.NoError(t, err) | ||
require.IsType(t, &channelDefinitionCache{}, cdc) | ||
|
||
// is fine if you do it again with different don ID | ||
cdc, err = cdcFactory.NewCache(lloconfig.PluginConfig{ | ||
ChannelDefinitionsContractAddress: common.HexToAddress("0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), | ||
DonID: 2, | ||
}) | ||
require.NoError(t, err) | ||
require.IsType(t, &channelDefinitionCache{}, cdc) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.