From 79310f6276316a07c98a11649324e33c1bde2f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20G=C3=B6ktu=C4=9F=20=C3=96ZT=C3=9CRK?= Date: Wed, 3 Feb 2021 00:43:40 -0800 Subject: [PATCH 1/2] feat(relayer): make Chain.logger configurable --- cmd/config.go | 2 +- relayer/chain.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 2966d3fef..8f4c7cdec 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -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) } } diff --git a/relayer/chain.go b/relayer/chain.go index 0d4ac4199..044a5e515 100644 --- a/relayer/chain.go +++ b/relayer/chain.go @@ -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 @@ -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 } From f4e3fc9d1de1016ebf14e46c46c0d3837c451698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20G=C3=B6ktu=C4=9F=20=C3=96ZT=C3=9CRK?= Date: Wed, 3 Feb 2021 00:52:45 -0800 Subject: [PATCH 2/2] fix tests --- test/test_setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_setup.go b/test/test_setup.go index 173e51ed4..ed4565b4b 100644 --- a/test/test_setup.go +++ b/test/test_setup.go @@ -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())