-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc_query_test.go
101 lines (94 loc) · 2.31 KB
/
grpc_query_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package keeper_test
import (
"context"
"github.com/ingenuity-build/quicksilver/x/claimsmanager/types"
)
func (suite *KeeperTestSuite) TestKeeper_Queries() {
k := suite.GetQuicksilverApp(suite.chainA).ClaimsManagerKeeper
// now that we have a kepper set the chainID of chainB
testClaims[0].ChainId = suite.chainB.ChainID
testClaims[1].ChainId = suite.chainB.ChainID
testClaims[2].ChainId = suite.chainB.ChainID
testClaims[3].ChainId = suite.chainB.ChainID
tests := []struct {
name string
malleate func()
req *types.QueryClaimsRequest
queryFn func(context.Context, *types.QueryClaimsRequest) (*types.QueryClaimsResponse, error)
expectLength int
}{
{
"Claims_chainB",
func() {},
&types.QueryClaimsRequest{
ChainId: suite.chainB.ChainID,
},
k.Claims,
4,
},
{
"Claims_cosmoshub",
func() {},
&types.QueryClaimsRequest{
ChainId: "cosmoshub-4",
},
k.Claims,
2,
},
{
"UserClaims_testAddress",
func() {},
&types.QueryClaimsRequest{
Address: testAddress,
},
k.UserClaims,
3,
},
{
"LastEpochClaims_chainB",
func() {
k.ArchiveAndGarbageCollectClaims(suite.chainA.GetContext(), suite.chainB.ChainID)
},
&types.QueryClaimsRequest{
ChainId: suite.chainB.ChainID,
},
k.LastEpochClaims,
4,
},
{
"LastEpochClaims_cosmoshub",
func() {
},
&types.QueryClaimsRequest{
ChainId: "cosmoshub-4",
},
k.LastEpochClaims,
0, // none expected as this zone was not archived
},
{
"UserLastEpochClaims_testAddress",
func() {
},
&types.QueryClaimsRequest{
Address: testAddress,
},
k.UserLastEpochClaims,
2, // 2 expected from chainB, 1 ommited as it was not archived
},
}
k.SetClaim(suite.chainA.GetContext(), &testClaims[0])
k.SetClaim(suite.chainA.GetContext(), &testClaims[1])
k.SetClaim(suite.chainA.GetContext(), &testClaims[2])
k.SetClaim(suite.chainA.GetContext(), &testClaims[3])
k.SetClaim(suite.chainA.GetContext(), &testClaims[4])
k.SetClaim(suite.chainA.GetContext(), &testClaims[5])
for _, tt := range tests {
suite.Run(tt.name, func() {
tt.malleate()
resp, err := tt.queryFn(suite.chainA.GetContext(), tt.req)
suite.Require().NoError(err)
suite.Require().NotNil(resp.Claims)
suite.Require().Equal(tt.expectLength, len(resp.Claims))
})
}
}