-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
test: migrate e2e/mint to system tests #22294
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,98 @@ | ||||||||||||||||||
package systemtests | ||||||||||||||||||
|
||||||||||||||||||
import ( | ||||||||||||||||||
"fmt" | ||||||||||||||||||
"net/http" | ||||||||||||||||||
"testing" | ||||||||||||||||||
|
||||||||||||||||||
"github.com/stretchr/testify/require" | ||||||||||||||||||
"github.com/tidwall/sjson" | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
func TestMintQueries(t *testing.T) { | ||||||||||||||||||
// scenario: test mint grpc queries | ||||||||||||||||||
// given a running chain | ||||||||||||||||||
|
||||||||||||||||||
sut.ResetChain(t) | ||||||||||||||||||
cli := NewCLIWrapper(t, sut, verbose) | ||||||||||||||||||
|
||||||||||||||||||
sut.ModifyGenesisJSON(t, | ||||||||||||||||||
func(genesis []byte) []byte { | ||||||||||||||||||
state, err := sjson.Set(string(genesis), "app_state.mint.minter.inflation", "1.00") | ||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||
return []byte(state) | ||||||||||||||||||
}, | ||||||||||||||||||
func(genesis []byte) []byte { | ||||||||||||||||||
state, err := sjson.Set(string(genesis), "app_state.mint.params.inflation_max", "1.00") | ||||||||||||||||||
require.NoError(t, err) | ||||||||||||||||||
return []byte(state) | ||||||||||||||||||
}, | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
sut.StartChain(t) | ||||||||||||||||||
|
||||||||||||||||||
sut.AwaitNextBlock(t) | ||||||||||||||||||
|
||||||||||||||||||
baseurl := sut.APIAddress() | ||||||||||||||||||
blockHeightHeader := "x-cosmos-block-height" | ||||||||||||||||||
queryAtHeight := "1" | ||||||||||||||||||
|
||||||||||||||||||
// TODO: check why difference in values when querying with height between v1 and v2 | ||||||||||||||||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/22302 | ||||||||||||||||||
if isV2() { | ||||||||||||||||||
queryAtHeight = "2" | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
paramsResp := `{"params":{"mint_denom":"stake","inflation_rate_change":"0.130000000000000000","inflation_max":"1.000000000000000000","inflation_min":"0.000000000000000000","goal_bonded":"0.670000000000000000","blocks_per_year":"6311520","max_supply":"0"}}` | ||||||||||||||||||
inflationResp := `{"inflation":"1.000000000000000000"}` | ||||||||||||||||||
annualProvisionsResp := `{"annual_provisions":"2000000000.000000000000000000"}` | ||||||||||||||||||
|
||||||||||||||||||
testCases := []struct { | ||||||||||||||||||
name string | ||||||||||||||||||
url string | ||||||||||||||||||
headers map[string]string | ||||||||||||||||||
expOut string | ||||||||||||||||||
}{ | ||||||||||||||||||
{ | ||||||||||||||||||
"gRPC request params", | ||||||||||||||||||
fmt.Sprintf("%s/cosmos/mint/v1beta1/params", baseurl), | ||||||||||||||||||
map[string]string{}, | ||||||||||||||||||
paramsResp, | ||||||||||||||||||
}, | ||||||||||||||||||
{ | ||||||||||||||||||
"gRPC request inflation", | ||||||||||||||||||
fmt.Sprintf("%s/cosmos/mint/v1beta1/inflation", baseurl), | ||||||||||||||||||
map[string]string{}, | ||||||||||||||||||
inflationResp, | ||||||||||||||||||
}, | ||||||||||||||||||
{ | ||||||||||||||||||
"gRPC request annual provisions", | ||||||||||||||||||
fmt.Sprintf("%s/cosmos/mint/v1beta1/annual_provisions", baseurl), | ||||||||||||||||||
map[string]string{ | ||||||||||||||||||
blockHeightHeader: queryAtHeight, | ||||||||||||||||||
}, | ||||||||||||||||||
annualProvisionsResp, | ||||||||||||||||||
}, | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
for _, tc := range testCases { | ||||||||||||||||||
t.Run(tc.name, func(t *testing.T) { | ||||||||||||||||||
// TODO: remove below check once grpc gateway is implemented in v2 | ||||||||||||||||||
if isV2() { | ||||||||||||||||||
return | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+80
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use Instead of returning early when Apply this change: - return
+ t.Skip("Skipping test until gRPC gateway is implemented in v2")
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
resp := GetRequestWithHeaders(t, tc.url, tc.headers, http.StatusOK) | ||||||||||||||||||
require.JSONEq(t, tc.expOut, string(resp)) | ||||||||||||||||||
}) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// test cli queries | ||||||||||||||||||
rsp := cli.CustomQuery("q", "mint", "params") | ||||||||||||||||||
require.JSONEq(t, paramsResp, rsp) | ||||||||||||||||||
|
||||||||||||||||||
rsp = cli.CustomQuery("q", "mint", "inflation") | ||||||||||||||||||
require.JSONEq(t, inflationResp, rsp) | ||||||||||||||||||
|
||||||||||||||||||
rsp = cli.CustomQuery("q", "mint", "annual-provisions", "--height="+queryAtHeight) | ||||||||||||||||||
require.JSONEq(t, annualProvisionsResp, rsp) | ||||||||||||||||||
} |
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.
lets open an issue about this so we dont forget it
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.
Opened #22302