Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,145 changes: 0 additions & 1,145 deletions tests/e2e/tx/service_test.go

This file was deleted.

1 change: 0 additions & 1 deletion tests/e2e/tx/testdata/tx_amino1.json

This file was deleted.

3 changes: 2 additions & 1 deletion tests/systemtests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ require (
github.com/stretchr/testify v1.9.0
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/grpc v1.67.1
)

require (
cosmossdk.io/math v1.3.0
github.com/cometbft/cometbft v0.38.8
github.com/cometbft/cometbft/api v1.0.0-rc.1
github.com/creachadair/tomledit v0.0.26
github.com/tidwall/gjson v1.14.2
github.com/tidwall/sjson v1.2.5
Expand Down
2 changes: 2 additions & 0 deletions tests/systemtests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ github.com/cometbft/cometbft v0.38.8 h1:XyJ9Cu3xqap6xtNxiemrO8roXZ+KS2Zlu7qQ0w1t
github.com/cometbft/cometbft v0.38.8/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ=
github.com/cometbft/cometbft-db v1.0.1 h1:SylKuLseMLQKw3+i8y8KozZyJcQSL98qEe2CGMCGTYE=
github.com/cometbft/cometbft-db v1.0.1/go.mod h1:EBrFs1GDRiTqrWXYi4v90Awf/gcdD5ExzdPbg4X8+mk=
github.com/cometbft/cometbft/api v1.0.0-rc.1 h1:GtdXwDGlqwHYs16A4egjwylfYOMYyEacLBrs3Zvpt7g=
github.com/cometbft/cometbft/api v1.0.0-rc.1/go.mod h1:NDFKiBBD8HJC6QQLAoUI99YhsiRZtg2+FJWfk6A6m6o=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand Down
80 changes: 80 additions & 0 deletions tests/systemtests/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ package systemtests

import (
"context"
"errors"
"reflect"

Check notice

Code scanning / CodeQL

Sensitive package import

Certain system packages contain functions which may be a possible source of non-determinism
"strconv"
"testing"

abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
rpcclient "github.com/cometbft/cometbft/rpc/client"
client "github.com/cometbft/cometbft/rpc/client/http"
cmtypes "github.com/cometbft/cometbft/types"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
)

// RPCClient is a test helper to interact with a node via the RPC endpoint.
Expand All @@ -31,3 +43,71 @@ func (r RPCClient) Validators() []*cmtypes.Validator {
require.NoError(r.t, err)
return v.Validators
}

func (r RPCClient) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) error {
if reflect.ValueOf(req).IsNil() {
return errors.New("request cannot be nil")
}

ir := types.NewInterfaceRegistry()
cryptocodec.RegisterInterfaces(ir)
cdc := codec.NewProtoCodec(ir).GRPCCodec()

reqBz, err := cdc.Marshal(req)
if err != nil {
return err
}

var height int64
md, _ := metadata.FromOutgoingContext(ctx)
if heights := md.Get(grpctypes.GRPCBlockHeightHeader); len(heights) > 0 {
height, err := strconv.ParseInt(heights[0], 10, 64)
if err != nil {
return err
}
if height < 0 {
return errors.New("height must be greater than or equal to 0")
}
}

abciReq := abci.QueryRequest{
Path: method,
Data: reqBz,
Height: height,
}

abciOpts := rpcclient.ABCIQueryOptions{
Height: height,
Prove: abciReq.Prove,
}

result, err := r.client.ABCIQueryWithOptions(ctx, abciReq.Path, abciReq.Data, abciOpts)
if err != nil {
return err
}

if !result.Response.IsOK() {
return errors.New(result.Response.String())
}

err = cdc.Unmarshal(result.Response.Value, reply)
if err != nil {
return err
}

md = metadata.Pairs(grpctypes.GRPCBlockHeightHeader, strconv.FormatInt(result.Response.Height, 10))
for _, callOpt := range opts {
header, ok := callOpt.(grpc.HeaderCallOption)
if !ok {
continue
}

*header.HeaderAddr = md
}

return types.UnpackInterfaces(reply, ir)
}

func (r RPCClient) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) {
return nil, errors.New("not implemented")
}
32 changes: 32 additions & 0 deletions tests/systemtests/testdata/tx_amino1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "cosmos-sdk/StdTx",
"value": {
"msg": [
{
"type": "cosmos-sdk/MsgSend",
"value": {
"from_address": "cosmos1hzw8v2kk4csg8xr3fhy8ykyymykknm2tdgvf7k",
"to_address": "cosmos1hzw8v2kk4csg8xr3fhy8ykyymykknm2tdgvf7k",
"amount": [
{
"denom": "stake",
"amount": "10"
}
]
}
}
],
"fee": {
"amount": [
{
"denom": "stake",
"amount": "10"
}
],
"gas": "200000"
},
"signatures": [],
"memo": "foobar",
"timeout_height": "0"
}
}
Loading