Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jun 28, 2024
1 parent c7cfb73 commit d01b3b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion zetaclient/chains/evm/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 343 in zetaclient/chains/evm/observer/observer.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/observer.go#L343

Added line #L343 was not covered by tests

// GAS PRICE
Expand Down
12 changes: 10 additions & 2 deletions zetaclient/chains/evm/signer/outbound_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
12 changes: 12 additions & 0 deletions zetaclient/chains/evm/signer/outbound_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}

0 comments on commit d01b3b3

Please sign in to comment.