forked from cosmos/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquerier_test.go
57 lines (52 loc) · 1.64 KB
/
querier_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package globalfee
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/gaia/v15/x/globalfee/types"
)
func TestQueryMinimumGasPrices(t *testing.T) {
specs := map[string]struct {
setupStore func(ctx sdk.Context, s paramtypes.Subspace)
expMin sdk.DecCoins
}{
"one coin": {
setupStore: func(ctx sdk.Context, s paramtypes.Subspace) {
s.SetParamSet(ctx, &types.Params{
MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())),
})
},
expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt())),
},
"multiple coins": {
setupStore: func(ctx sdk.Context, s paramtypes.Subspace) {
s.SetParamSet(ctx, &types.Params{
MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt()), sdk.NewDecCoin("BLX", sdk.NewInt(2))),
})
},
expMin: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.OneInt()), sdk.NewDecCoin("BLX", sdk.NewInt(2))),
},
"no min gas price set": {
setupStore: func(ctx sdk.Context, s paramtypes.Subspace) {
s.SetParamSet(ctx, &types.Params{})
},
},
"no param set": {
setupStore: func(ctx sdk.Context, s paramtypes.Subspace) {
},
},
}
for name, spec := range specs {
t.Run(name, func(t *testing.T) {
ctx, _, subspace := setupTestStore(t)
spec.setupStore(ctx, subspace)
q := NewGrpcQuerier(subspace)
gotResp, gotErr := q.Params(sdk.WrapSDKContext(ctx), nil)
require.NoError(t, gotErr)
require.NotNil(t, gotResp)
assert.Equal(t, spec.expMin, gotResp.Params.MinimumGasPrices)
})
}
}