Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(relayer): make Chain.logger configurable #402

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func validateConfig(c *Config) error {
}

for _, i := range c.Chains {
if err := i.Init(homePath, to, debug); err != nil {
if err := i.Init(homePath, to, nil, debug); err != nil {
return fmt.Errorf("did you remember to run 'rly config init' error:%w", err)
}
}
Expand Down
9 changes: 7 additions & 2 deletions relayer/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (c *Chain) listenLoop(doneChan chan struct{}, tx, block, data bool) {

// Init initializes the pieces of a chain that aren't set when it parses a config
// NOTE: All validation of the chain should happen here.
func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error {
func (c *Chain) Init(homePath string, timeout time.Duration, logger log.Logger, debug bool) error {
keybase, err := keys.New(c.ChainID, "test", keysDir(homePath, c.ChainID), nil)
if err != nil {
return err
Expand All @@ -222,10 +222,15 @@ func (c *Chain) Init(homePath string, timeout time.Duration, debug bool) error {
c.Client = client
c.HomePath = homePath
c.Encoding = encodingConfig
c.logger = defaultChainLogger()
c.logger = logger
c.timeout = timeout
c.debug = debug
c.faucetAddrs = make(map[string]time.Time)

if c.logger == nil {
c.logger = defaultChainLogger()
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource,
}

// initialize the chain
require.NoError(t, c.Init(dir, tc.t.timeout, debug))
require.NoError(t, c.Init(dir, tc.t.timeout, nil, debug))

// create the test key
require.NoError(t, c.CreateTestKey())
Expand Down