-
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
- Add ChannelDefinitionCacheFactory tests - Cleanup TODOs/FIXMEs - Add comments/docs - Include Don ID in LLO extra hash - Optimize log poller calls
- Loading branch information
Showing
22 changed files
with
264 additions
and
184 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/test-go/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.