-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add null check for return value of GetDefaultOracleQuote (#939
- Loading branch information
1 parent
1cb185c
commit 1f3ec77
Showing
6 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package contract_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pundiai/fx-core/v8/contract" | ||
"github.com/pundiai/fx-core/v8/testutil/helpers" | ||
fxtypes "github.com/pundiai/fx-core/v8/types" | ||
ethtypes "github.com/pundiai/fx-core/v8/x/eth/types" | ||
) | ||
|
||
func TestBridgeFeeQuoteKeeper_GetDefaultOracleQuote(t *testing.T) { | ||
app, ctx := helpers.NewAppWithValNumber(t, 1) | ||
keeper := contract.NewBridgeFeeQuoteKeeper(app.EvmKeeper) | ||
quote, err := keeper.GetDefaultOracleQuote(ctx, contract.MustStrToByte32(ethtypes.ModuleName), contract.MustStrToByte32(fxtypes.DefaultDenom)) | ||
require.NoError(t, err) | ||
require.Empty(t, quote) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
|
||
evmtypes "github.com/evmos/ethermint/x/evm/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pundiai/fx-core/v8/contract" | ||
) | ||
|
||
type BridgeFeeSuite struct { | ||
require *require.Assertions | ||
err error | ||
|
||
contract.BridgeFeeQuoteKeeper | ||
contract.BridgeFeeOracleKeeper | ||
} | ||
|
||
func NewBridgeFeeSuite(require *require.Assertions, caller contract.Caller) BridgeFeeSuite { | ||
return BridgeFeeSuite{ | ||
require: require, | ||
BridgeFeeQuoteKeeper: contract.NewBridgeFeeQuoteKeeper(caller), | ||
BridgeFeeOracleKeeper: contract.NewBridgeFeeOracleKeeper(caller), | ||
} | ||
} | ||
|
||
func (s BridgeFeeSuite) WithError(err error) BridgeFeeSuite { | ||
suite := s | ||
suite.err = err | ||
return suite | ||
} | ||
|
||
func (s BridgeFeeSuite) requireError(err error) { | ||
if s.err != nil { | ||
s.require.ErrorIs(err, evmtypes.ErrVMExecution.Wrap(s.err.Error())) | ||
return | ||
} | ||
s.require.NoError(err) | ||
} | ||
|
||
func (s BridgeFeeSuite) Quote(ctx context.Context, args contract.IBridgeFeeQuoteQuoteInput) *evmtypes.MsgEthereumTxResponse { | ||
defOracle, err := s.BridgeFeeOracleKeeper.DefaultOracle(ctx) | ||
s.require.NoError(err) | ||
|
||
res, err := s.BridgeFeeQuoteKeeper.Quote(ctx, defOracle, []contract.IBridgeFeeQuoteQuoteInput{args}) | ||
s.requireError(err) | ||
return res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters