Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit f8d0675

Browse files
mergify[bot]Alex Johnson
andauthored
refactor(tests): use grpc instead of cli for all network testing (backport #301) (#302)
* refactor(tests): use grpc instead of cli for all network testing (#301) * update * use grpc (cherry picked from commit af3bb52) # Conflicts: # go.mod # go.sum # tests/integration/network_test.go # testutils/networksuite/networksuite.go * fix --------- Co-authored-by: Alex Johnson <alex@skip.money>
1 parent d583032 commit f8d0675

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/gorilla/mux v1.8.1
2121
github.com/grpc-ecosystem/grpc-gateway v1.16.0
2222
github.com/huandu/skiplist v1.2.0
23-
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051
23+
github.com/skip-mev/chaintestutil v0.0.0-20231213230652-c159341203f6
2424
github.com/spf13/cobra v1.8.0
2525
github.com/spf13/viper v1.16.0
2626
github.com/stretchr/testify v1.8.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,8 @@ github.com/sivchari/nosnakecase v1.7.0 h1:7QkpWIRMe8x25gckkFd2A5Pi6Ymo0qgr4JrhGt
11851185
github.com/sivchari/nosnakecase v1.7.0/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY=
11861186
github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak=
11871187
github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg=
1188-
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051 h1:ZTD4dFUTv+h+BgGTv4PtXnSxgMTUrCvGX+NQjNo/hqA=
1189-
github.com/skip-mev/chaintestutil v0.0.0-20231207155412-975710cc9051/go.mod h1:P7icBoBSf+Ci1b2moqSXQZTThtBs33eJ8dPajce2ViQ=
1188+
github.com/skip-mev/chaintestutil v0.0.0-20231213230652-c159341203f6 h1:aTqi6gmYxnzlTWep3zEaJfXXJTdMf4eoKjVyFWzut5I=
1189+
github.com/skip-mev/chaintestutil v0.0.0-20231213230652-c159341203f6/go.mod h1:P7icBoBSf+Ci1b2moqSXQZTThtBs33eJ8dPajce2ViQ=
11901190
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
11911191
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
11921192
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=

tests/integration/network_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
package integration_test
22

33
import (
4+
"context"
45
"fmt"
56
"testing"
67

78
tmcli "github.com/cometbft/cometbft/libs/cli"
8-
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
99
"github.com/stretchr/testify/require"
1010
"github.com/stretchr/testify/suite"
1111
"google.golang.org/grpc/status"
1212

1313
"github.com/skip-mev/block-sdk/testutils/networksuite"
14-
auctioncli "github.com/skip-mev/block-sdk/x/auction/client/cli"
1514
auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"
1615
)
1716

@@ -28,8 +27,6 @@ func TestNetworkTestSuite(t *testing.T) {
2827
func (s *NetworkTestSuite) TestGetAuctionParams() {
2928
s.T().Parallel()
3029

31-
val := s.Network.Validators[0]
32-
3330
common := []string{
3431
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
3532
}
@@ -48,18 +45,27 @@ func (s *NetworkTestSuite) TestGetAuctionParams() {
4845
} {
4946
s.T().Run(tc.name, func(t *testing.T) {
5047
tc := tc
51-
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, auctioncli.CmdQueryParams(), tc.args)
48+
resp, err := s.QueryAuctionParams()
5249
if tc.err != nil {
5350
stat, ok := status.FromError(tc.err)
5451
require.True(t, ok)
5552
require.ErrorIs(t, stat.Err(), tc.err)
5653
} else {
5754
require.NoError(t, err)
58-
var resp auctiontypes.QueryParamsResponse
59-
require.NoError(t, s.Network.Config.Codec.UnmarshalJSON(out.Bytes(), &resp.Params))
6055
require.NotNil(t, resp)
6156
require.Equal(t, tc.obj, resp.Params)
6257
}
6358
})
6459
}
6560
}
61+
62+
func (s *NetworkTestSuite) QueryAuctionParams() (*auctiontypes.QueryParamsResponse, error) {
63+
s.T().Helper()
64+
65+
cc, closeConn, err := s.NetworkSuite.GetGRPC()
66+
s.Require().NoError(err)
67+
defer closeConn()
68+
69+
client := auctiontypes.NewQueryClient(cc)
70+
return client.Params(context.Background(), &auctiontypes.QueryParamsRequest{})
71+
}

testutils/networksuite/networksuite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ var (
3737
}
3838
)
3939

40-
// NetworkTestSuite is a test suite for query tests that initializes a network instance.
40+
// NetworkTestSuite is a test suite for tests that initializes a network instance.
4141
type NetworkTestSuite struct {
4242
suite.Suite
4343

44-
Network *network.Network
44+
NetworkSuite *network.TestSuite
4545
AuctionState auctiontypes.GenesisState
4646
}
4747

@@ -63,7 +63,7 @@ func (nts *NetworkTestSuite) SetupSuite() {
6363
nts.AuctionState = populateAuction(r, nts.AuctionState)
6464
updateGenesisConfigState(auctiontypes.ModuleName, &nts.AuctionState)
6565

66-
nts.Network = network.New(nts.T(), cfg)
66+
nts.NetworkSuite = network.NewSuite(nts.T(), cfg)
6767
}
6868

6969
func populateAuction(_ *rand.Rand, auctionState auctiontypes.GenesisState) auctiontypes.GenesisState {

0 commit comments

Comments
 (0)