refactor(tests): testutil.Network as an interface (#18389)

Co-authored-by: Anmol <anmol1696@gmail.com>
This commit is contained in:
Marko
2023-11-08 18:38:57 +00:00
committed by GitHub
co-authored by Anmol
parent 8fbf6166f6
commit 03c3f8e71f
28 changed files with 959 additions and 863 deletions
+5 -5
View File
@@ -40,7 +40,7 @@ type GRPCWebTestSuite struct {
suite.Suite
cfg network.Config
network *network.Network
network network.NetworkI
protoCdc *codec.ProtoCodec
}
@@ -68,7 +68,7 @@ func (s *GRPCWebTestSuite) TearDownSuite() {
}
func (s *GRPCWebTestSuite) Test_Latest_Validators() {
val := s.network.Validators[0]
val := s.network.GetValidators()[0]
for _, contentType := range []string{grpcWebContentType} {
headers, trailers, responses, err := s.makeGrpcRequest(
"/cosmos.base.tendermint.v1beta1.Service/GetLatestValidatorSet",
@@ -84,7 +84,7 @@ func (s *GRPCWebTestSuite) Test_Latest_Validators() {
s.Require().NoError(err)
pubKey, ok := valsSet.Validators[0].PubKey.GetCachedValue().(cryptotypes.PubKey)
s.Require().Equal(true, ok)
s.Require().Equal(pubKey, val.PubKey)
s.Require().Equal(pubKey, val.GetPubKey())
}
}
@@ -128,7 +128,7 @@ func serializeProtoMessages(messages []proto.Message) [][]byte {
func (s *GRPCWebTestSuite) makeRequest(
verb, method string, headers http.Header, body io.Reader, isText bool,
) (*http.Response, error) {
val := s.network.Validators[0]
val := s.network.GetValidators()[0]
contentType := "application/grpc-web"
if isText {
// base64 encode the body
@@ -146,7 +146,7 @@ func (s *GRPCWebTestSuite) makeRequest(
contentType = "application/grpc-web-text"
}
url := fmt.Sprintf("http://%s%s", strings.TrimPrefix(val.AppConfig.API.Address, "tcp://"), method)
url := fmt.Sprintf("http://%s%s", strings.TrimPrefix(val.GetAppConfig().API.Address, "tcp://"), method)
req, err := http.NewRequest(verb, url, body)
s.Require().NoError(err, "failed creating a request")
req.Header = headers