Skip to content

Commit

Permalink
feat(relayer): make Chain.logger configurable (#402)
Browse files Browse the repository at this point in the history
* feat(relayer): make Chain.logger configurable

* fix tests
  • Loading branch information
ilgooz authored Feb 3, 2021
1 parent 2f1a812 commit cb3edfc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit cb3edfc

Please sign in to comment.