Skip to content

Commit

Permalink
extracts app version from one of the validators
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Mar 20, 2024
1 parent 077785c commit 9f359db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1"
"github.com/celestiaorg/celestia-app/test/txsim"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/stretchr/testify/require"
Expand All @@ -23,7 +22,7 @@ var latestVersion = "latest"
// and MsgSends over 30 seconds and then asserts that at least 10 transactions were
// committed.
func TestE2ESimple(t *testing.T) {
if os.Getenv("KNUU_NAMESPACE") != "test" {
if os.Getenv("KNUU_NAMESPACE") != "test-sanaz" {
t.Skip("skipping e2e test")
}

Expand Down Expand Up @@ -64,12 +63,16 @@ func TestE2ESimple(t *testing.T) {
err = txsim.Run(ctx, testnet.GRPCEndpoints()[0], kr, encCfg, opts, sequences...)
require.True(t, errors.Is(err, context.DeadlineExceeded), err.Error())

expectedAppVersion, err := testnode.ReadAppVersion(context.Background(),
testnet.Node(0).AddressRPC())
require.NoError(t, err)

blockchain, err := testnode.ReadBlockchain(context.Background(), testnet.Node(0).AddressRPC())
require.NoError(t, err)

totalTxs := 0
for _, block := range blockchain {
require.Equal(t, v1.Version, block.Version.App)
require.Equal(t, expectedAppVersion, block.Version.App)
totalTxs += len(block.Data.Txs)
}
require.Greater(t, totalTxs, 10)
Expand Down
13 changes: 13 additions & 0 deletions test/util/testnode/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ func ReadBlockchain(ctx context.Context, rpcAddress string) ([]*types.Block, err
return nil, err
}
return ReadBlockHeights(ctx, rpcAddress, 1, status.SyncInfo.LatestBlockHeight)

}

func ReadAppVersion(ctx context.Context, rpcAddress string) (uint64, error) {
client, err := http.New(rpcAddress, "/abci_info")
if err != nil {
return 0, err
}
resp, err := client.ABCIInfo(ctx)
if err != nil {
return 0, err
}
return resp.Response.AppVersion, nil
}

func ReadBlockHeights(ctx context.Context, rpcAddress string, fromHeight, toHeight int64) ([]*types.Block, error) {
Expand Down

0 comments on commit 9f359db

Please sign in to comment.