-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(e2e): improved the e2esuite (#97)
* refactor: moved chainconfig * imp: improved types * refactor: more code * refactor: tests * style: ran golangci-lint * docs: changed godocs * refactor: removed useless line * imp: fix errors * fix: wasm test * test: better grpc queries * deps: ran 'go mod tidy' * fix: wasm test * style: ran golangci-lint * deps: ran 'go mod tidy' * fix: attempt 1 * fix: attempt 3 * fix: wasm test * style: added wasmd to linter * imp: use custom encoding everywhere * refactor: renamed testsuite to e2esuite * style: ran golangci-lint * imp: remove uneeded log
- Loading branch information
Showing
25 changed files
with
910 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
e2e/interchaintest/testsuite/constants.go → e2e/interchaintest/e2esuite/constants.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package testsuite | ||
package e2esuite | ||
|
||
const ( | ||
// hermesRelayerImage = "ghcr.io/informalsystems/hermes" | ||
|
2 changes: 1 addition & 1 deletion
2
e2e/interchaintest/testsuite/diagnostics.go → e2e/interchaintest/e2esuite/diagnostics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package testsuite | ||
package e2esuite | ||
|
||
import ( | ||
"archive/tar" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package e2esuite | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/cosmos/gogoproto/proto" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
pb "google.golang.org/protobuf/proto" | ||
|
||
msgv1 "cosmossdk.io/api/cosmos/msg/v1" | ||
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" | ||
|
||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" | ||
) | ||
|
||
var queryReqToPath = make(map[string]string) | ||
|
||
func populateQueryReqToPath(ctx context.Context, chain *cosmos.CosmosChain) error { | ||
resp, err := queryFileDescriptors(ctx, chain) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, fileDescriptor := range resp.Files { | ||
for _, service := range fileDescriptor.GetService() { | ||
// Skip services that are annotated with the "cosmos.msg.v1.service" option. | ||
if ext := pb.GetExtension(service.GetOptions(), msgv1.E_Service); ext != nil && ext.(bool) { | ||
continue | ||
} | ||
|
||
for _, method := range service.GetMethod() { | ||
// trim the first character from input which is a dot | ||
queryReqToPath[method.GetInputType()[1:]] = fileDescriptor.GetPackage() + "." + service.GetName() + "/" + method.GetName() | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// Queries the chain with a query request and deserializes the response to T | ||
func GRPCQuery[T any](ctx context.Context, chain *cosmos.CosmosChain, req proto.Message, opts ...grpc.CallOption) (*T, error) { | ||
path, ok := queryReqToPath[proto.MessageName(req)] | ||
if !ok { | ||
return nil, fmt.Errorf("no path found for %s", proto.MessageName(req)) | ||
} | ||
|
||
// Create a connection to the gRPC server. | ||
grpcConn, err := grpc.Dial( | ||
chain.GetHostGRPCAddress(), | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer grpcConn.Close() | ||
|
||
resp := new(T) | ||
err = grpcConn.Invoke(ctx, path, req, resp, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return resp, nil | ||
} | ||
|
||
func queryFileDescriptors(ctx context.Context, chain *cosmos.CosmosChain) (*reflectionv1.FileDescriptorsResponse, error) { | ||
// Create a connection to the gRPC server. | ||
grpcConn, err := grpc.Dial( | ||
chain.GetHostGRPCAddress(), | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer grpcConn.Close() | ||
|
||
resp := new(reflectionv1.FileDescriptorsResponse) | ||
err = grpcConn.Invoke( | ||
ctx, reflectionv1.ReflectionService_FileDescriptors_FullMethodName, | ||
&reflectionv1.FileDescriptorsRequest{}, resp, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.