From d01b3b399c8a5ba64a8443e125f40e7bf5af8e8e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 28 Jun 2024 17:48:00 +0200 Subject: [PATCH] Address PR comments --- zetaclient/chains/evm/observer/observer.go | 3 ++- zetaclient/chains/evm/signer/outbound_data.go | 12 ++++++++++-- zetaclient/chains/evm/signer/outbound_data_test.go | 12 ++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/zetaclient/chains/evm/observer/observer.go b/zetaclient/chains/evm/observer/observer.go index 4b7347ed6b..b01bd63fb1 100644 --- a/zetaclient/chains/evm/observer/observer.go +++ b/zetaclient/chains/evm/observer/observer.go @@ -338,7 +338,8 @@ func (ob *Observer) WatchGasPrice() { // PostGasPrice posts gas price to zetacore // TODO(revamp): move to gas price file func (ob *Observer) PostGasPrice() error { - // issue: https://github.com/zeta-chain/node/issues/1160 + // TODO: add ctx to `PostGasPrice(ctx) error` + // https://github.com/zeta-chain/node/issues/1160 ctx := context.Background() // GAS PRICE diff --git a/zetaclient/chains/evm/signer/outbound_data.go b/zetaclient/chains/evm/signer/outbound_data.go index c59018cd74..3e35763ae0 100644 --- a/zetaclient/chains/evm/signer/outbound_data.go +++ b/zetaclient/chains/evm/signer/outbound_data.go @@ -56,8 +56,8 @@ func NewOutboundData( logger zerolog.Logger, ) (*OutboundData, bool, error) { outboundParams := cctx.GetCurrentOutboundParam() - if outboundParams == nil { - return nil, false, errors.New("outboundParams is nil") + if err := validateParams(outboundParams); err != nil { + return nil, false, err } // Check if the CCTX has already been processed @@ -194,3 +194,11 @@ func determineDestination(cctx *types.CrossChainTx, logger zerolog.Logger) (ethc return ethcommon.Address{}, nil, true } + +func validateParams(params *types.OutboundParams) error { + if params == nil || params.GasLimit == 0 { + return errors.New("outboundParams is empty") + } + + return nil +} diff --git a/zetaclient/chains/evm/signer/outbound_data_test.go b/zetaclient/chains/evm/signer/outbound_data_test.go index 9642fbb5ad..688b4d43bb 100644 --- a/zetaclient/chains/evm/signer/outbound_data_test.go +++ b/zetaclient/chains/evm/signer/outbound_data_test.go @@ -132,4 +132,16 @@ func TestNewOutboundData(t *testing.T) { // ASSERT assert.ErrorContains(t, err, "unknown chain") }) + + t.Run("no outbound params", func(t *testing.T) { + // ARRANGE + cctx := getCCTX(t) + cctx.OutboundParams = nil + + // ACT + _, _, err := newOutbound(cctx) + + // ASSERT + assert.ErrorContains(t, err, "outboundParams is empty") + }) }