Skip to content

Commit 8876f6d

Browse files
test: migrate e2e/mint to system tests
1 parent 553e110 commit 8876f6d

File tree

4 files changed

+97
-134
lines changed

4 files changed

+97
-134
lines changed

tests/e2e/mint/cli_test.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/e2e/mint/grpc.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

tests/e2e/mint/suite.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/systemtests/mint_test.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package systemtests
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"testing"
7+
8+
"github.com/stretchr/testify/require"
9+
"github.com/tidwall/sjson"
10+
)
11+
12+
func TestMintQueries(t *testing.T) {
13+
// scenario: test mint grpc queries
14+
// given a running chain
15+
16+
sut.ResetChain(t)
17+
cli := NewCLIWrapper(t, sut, verbose)
18+
19+
sut.ModifyGenesisJSON(t,
20+
func(genesis []byte) []byte {
21+
state, err := sjson.Set(string(genesis), "app_state.mint.minter.inflation", "1.00")
22+
require.NoError(t, err)
23+
return []byte(state)
24+
},
25+
func(genesis []byte) []byte {
26+
state, err := sjson.Set(string(genesis), "app_state.mint.params.inflation_max", "1.00")
27+
require.NoError(t, err)
28+
return []byte(state)
29+
},
30+
)
31+
32+
sut.StartChain(t)
33+
34+
sut.AwaitNextBlock(t)
35+
36+
baseurl := sut.APIAddress()
37+
blockHeightHeader := "x-cosmos-block-height"
38+
queryAtHeight := "1"
39+
40+
// TODO: check why difference in values basequeryAtH on height between v1 and v2
41+
if isV2() {
42+
queryAtHeight = "2"
43+
}
44+
45+
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"}}`
46+
inflationResp := `{"inflation":"1.000000000000000000"}`
47+
annualProvisionsResp := `{"annual_provisions":"2000000000.000000000000000000"}`
48+
49+
testCases := []struct {
50+
name string
51+
url string
52+
headers map[string]string
53+
expOut string
54+
}{
55+
{
56+
"gRPC request params",
57+
fmt.Sprintf("%s/cosmos/mint/v1beta1/params", baseurl),
58+
map[string]string{},
59+
paramsResp,
60+
},
61+
{
62+
"gRPC request inflation",
63+
fmt.Sprintf("%s/cosmos/mint/v1beta1/inflation", baseurl),
64+
map[string]string{},
65+
inflationResp,
66+
},
67+
{
68+
"gRPC request annual provisions",
69+
fmt.Sprintf("%s/cosmos/mint/v1beta1/annual_provisions", baseurl),
70+
map[string]string{
71+
blockHeightHeader: queryAtHeight,
72+
},
73+
annualProvisionsResp,
74+
},
75+
}
76+
77+
for _, tc := range testCases {
78+
t.Run(tc.name, func(t *testing.T) {
79+
// TODO: remove below check once grpc gateway is implemented in v2
80+
if isV2() {
81+
return
82+
}
83+
resp := GetRequestWithHeaders(t, tc.url, tc.headers, http.StatusOK)
84+
require.JSONEq(t, tc.expOut, string(resp))
85+
})
86+
}
87+
88+
// test cli queries
89+
rsp := cli.CustomQuery("q", "mint", "params")
90+
require.JSONEq(t, paramsResp, rsp)
91+
92+
rsp = cli.CustomQuery("q", "mint", "inflation")
93+
require.JSONEq(t, inflationResp, rsp)
94+
95+
rsp = cli.CustomQuery("q", "mint", "annual-provisions", "--height="+queryAtHeight)
96+
require.JSONEq(t, annualProvisionsResp, rsp)
97+
}

0 commit comments

Comments
 (0)