-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented cli tests for pricefeed + minor bugfixes #604
Conversation
52fd862
to
45b972c
Compare
45b972c
to
c999977
Compare
x/pricefeed/client/cli/cli_test.go
Outdated
Create a new wallet and attempt to fill it with the required balance. | ||
Tokens are sent by the validator, 'val'. | ||
*/ | ||
func (s IntegrationTestSuite) fillWalletFromValidator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using the shared one at
Line 217 in c999977
func FillWalletFromValidator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
x/pricefeed/client/cli/cli_test.go
Outdated
expectedPrice sdk.Dec | ||
expectErr bool | ||
respType proto.Message | ||
expectedCode uint32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is expectedCode
used anywhere?
x/pricefeed/client/cli/cli_test.go
Outdated
txResp := tc.respType.(*pftypes.QueryPriceResponse) | ||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), txResp) | ||
s.Require().NoError(err) | ||
s.Require().Equal(tc.expectedPrice, txResp.Price.Price) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assert the response's pairId just to be pathological.
x/pricefeed/client/cli/cli_test.go
Outdated
txResp := tc.respType.(*pftypes.QueryRawPricesResponse) | ||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), txResp) | ||
s.Require().NoError(err) | ||
s.Require().Equal(tc.expectedPrice, txResp.RawPrices[0].Price) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assert the other fields (pairID, oracle, expiry) also.
x/pricefeed/client/cli/cli_test.go
Outdated
|
||
for _, p := range txResp.Pairs { | ||
found := false | ||
for _, ep := range tc.expectedPairs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do s.Require().Contains(tc.expectedPairs, p)
to make this easier to read.
x/pricefeed/client/cli/cli_test.go
Outdated
|
||
for _, pp := range txResp.Prices { | ||
found := false | ||
for _, epp := range tc.expectedPricePairs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with s.Require().Contains()
.
In general, I would use |
wctx := sdk.WrapSDKContext(ctx) | ||
params := types.Params{ | ||
Pairs: []types.Pair{ | ||
{Token1: "btc", Token0: "usd", Oracles: nil, Active: true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) we normally have the stablecoin as token1
and the crypto asset as token0
.
Co-authored-by: Walter White <101130700+NibiruHeisenberg@users.noreply.github.com>
Looks good! |
x/pricefeed/client/cli/cli_test.go
Outdated
"github.com/cosmos/cosmos-sdk/crypto/hd" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a rule of thumb with imports the convention is to use 3 blocks ordered by:
- go standard imports
- external imports
- project imports
No description provided.