This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into CDK-90-remove-pack-2-usage-in-agglayer
- Loading branch information
Showing
25 changed files
with
405 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
docker/data | ||
.idea | ||
coverage.out | ||
.vscode/launch.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,59 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/mitchellh/mapstructure" | ||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/require" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func TestLoad(t *testing.T) { | ||
ctx := cli.NewContext(nil, nil, nil) | ||
_ = ctx.Set(FlagCfg, "/path/to/config.yaml") | ||
t.Run("default config", func(t *testing.T) { | ||
ctx := cli.NewContext(nil, nil, nil) | ||
_ = ctx.Set(FlagCfg, "/path/to/config.yaml") | ||
|
||
_, err := Load(ctx) | ||
assert.NoError(t, err) | ||
cfg, err := Load(ctx) | ||
require.NoError(t, err) | ||
|
||
defaultCfg, err := Default() | ||
require.NoError(t, err) | ||
require.Equal(t, defaultCfg, cfg) | ||
}) | ||
|
||
t.Run("the agglayer.toml file config", func(t *testing.T) { | ||
const ( | ||
cfgFile = "../docker/data/agglayer/agglayer.toml" | ||
ethTxManagerCfgKey = "EthTxManager" | ||
) | ||
|
||
// simulate command with the cfg flag | ||
flags := new(flag.FlagSet) | ||
cfgPath := "" | ||
flags.StringVar(&cfgPath, | ||
FlagCfg, | ||
cfgFile, | ||
"config file for the agglayer") | ||
ctx := cli.NewContext(nil, flags, nil) | ||
|
||
// read the config independently from the Load function | ||
viper.SetConfigFile(cfgFile) | ||
err := viper.ReadInConfig() | ||
require.NoError(t, err) | ||
|
||
decodeOpts := []viper.DecoderConfigOption{ | ||
viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(mapstructure.TextUnmarshallerHookFunc())), | ||
} | ||
|
||
var ethTxManagerCfg EthTxManagerConfig | ||
err = viper.UnmarshalKey(ethTxManagerCfgKey, ðTxManagerCfg, decodeOpts...) | ||
require.NoError(t, err) | ||
|
||
cfg, err := Load(ctx) | ||
require.NoError(t, err) | ||
require.NotNil(t, cfg) | ||
require.Equal(t, ethTxManagerCfg, cfg.EthTxManager) | ||
}) | ||
} |
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
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.