Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: updated test scripts for validating blocks in icon chain #374

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
42 changes: 39 additions & 3 deletions test/functional/dive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"testing"
"time"

"github.com/hugobyte/dive/cli/cmd/utility"
"github.com/hugobyte/dive/cli/common"
Expand Down Expand Up @@ -527,12 +528,19 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
})

ginkgo.Describe("Icon chain commands", func() {
ginkgo.It("should run single icon node testing", func() {
ginkgo.It("should run single icon node", func() {
enclaveName := dive.GenerateRandomName()
cmd.Args = append(cmd.Args, "chain", "icon", "--enclaveName", enclaveName)
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(5 * time.Second)
Indu-CR marked this conversation as resolved.
Show resolved Hide resolved
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.ICON_CONFIG0_SERVICENAME)
Indu-CR marked this conversation as resolved.
Show resolved Hide resolved

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(height).Should(gomega.BeNumerically(">", 0))
})

ginkgo.It("should run single icon node along with decentralisation", func() {
Expand All @@ -541,6 +549,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(5 * time.Second)
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(height).Should(gomega.BeNumerically(">", 0))
})

ginkgo.It("should run custom Icon node-0", func() {
Expand All @@ -549,6 +564,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(5 * time.Second)
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(height).Should(gomega.BeNumerically(">", 0))
})

ginkgo.It("should run custom Icon node-1", func() {
Expand All @@ -557,6 +579,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(5 * time.Second)
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.ICON_CONFIG1_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(height).Should(gomega.BeNumerically(">", 0))
})

ginkgo.It("should run icon node first and then decentralise it", func() {
Expand All @@ -568,6 +597,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(5 * time.Second)
service_path, _ = filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(height).Should(gomega.BeNumerically(">", 0))
})

ginkgo.It("should handle invalid input for chain command", func() {
Expand Down Expand Up @@ -757,7 +793,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.DEFAULT_NEUTRON_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand All @@ -772,7 +808,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetailsCosmos(service_path[0], dive.NEUTRON_CONFIG0_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand Down
26 changes: 26 additions & 0 deletions test/functional/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/cosmos/cosmos-sdk v0.50.6
github.com/google/uuid v1.6.0
github.com/hugobyte/dive/cli v0.0.0-20240221033343-40fba2434097
github.com/icon-project/icon-bridge v0.0.11
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
)
Expand All @@ -27,9 +28,12 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/aws/aws-sdk-go v1.44.76 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/briandowns/spinner v1.23.0 // indirect
github.com/bshuster-repo/logrus-logstash-hook v0.4.1 // indirect
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
Expand All @@ -52,6 +56,7 @@ require (
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
Expand All @@ -61,18 +66,24 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/ethereum/go-ethereum v1.10.16 // indirect
github.com/evalphobia/logrus_fluent v0.5.4 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fluent/fluent-logger-golang v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-yaml/yaml v2.1.0+incompatible // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
Expand All @@ -89,6 +100,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/haltingstate/secp256k1-go v0.0.0-20151224084235-572209b26df6 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.3 // indirect
Expand All @@ -98,9 +110,12 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/hugobyte/keygen v0.1.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/icon-project/goloop v1.2.11 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
Expand All @@ -111,6 +126,8 @@ require (
github.com/kurtosis-tech/kurtosis/grpc-file-transfer/golang v0.0.0-20240124210655-a35e0a2cee4b // indirect
github.com/kurtosis-tech/kurtosis/utils v0.0.0-20240124210655-a35e0a2cee4b // indirect
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409 // indirect
github.com/labstack/echo/v4 v4.11.3 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -126,6 +143,7 @@ require (
github.com/oklog/run v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/philhofer/fwd v1.0.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand All @@ -135,6 +153,7 @@ require (
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.8.3 // indirect
github.com/rs/zerolog v1.32.0 // indirect
Expand All @@ -154,7 +173,12 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/tinylib/msgp v1.1.2 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vmihailenco/msgpack/v4 v4.3.11 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
Expand All @@ -168,12 +192,14 @@ require (
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
15 changes: 14 additions & 1 deletion test/functional/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/google/uuid"
iconclient "github.com/icon-project/icon-bridge/cmd/iconbridge/chain/icon"
iconlog "github.com/icon-project/icon-bridge/common/log"
"github.com/onsi/gomega"
)

Expand All @@ -21,7 +23,7 @@ type NodeInfo struct {
Nid string `json:"nid"`
}

type CosmosNodeInfo struct{
type CosmosNodeInfo struct {
EndpointPublic string `json:"endpoint_public"`
}

Expand Down Expand Up @@ -56,6 +58,17 @@ func GetCosmosLatestBlock(nodeURI string) (height int64, err error) {
return height, err
}

func GetLatestBlockIcon(nodeURI string) (height int64, err error) {
var log iconlog.Logger
c:=iconclient.NewClient(nodeURI, log)
lastBlock, err := c.GetLastBlock()
if err!=nil{
return 0, fmt.Errorf("error occurred while receiving last block")
}
height=lastBlock.Height
return height, err
Indu-CR marked this conversation as resolved.
Show resolved Hide resolved
}

func GetBinaryCommand() *exec.Cmd {
binaryPath := GetBinPath()
return exec.Command(binaryPath)
Expand Down
Loading