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 hardhat chain #377

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions test/functional/dive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
time.Sleep(2 * time.Second)
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetail(service_path[0], dive.HARDHAT_SERVICENAME)

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

ginkgo.It("should output user that chain is already running when trying to run hardhat chain that is already running", func() {
Expand All @@ -732,6 +739,13 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
defer dive.Clean(enclaveName)
err := cmd.Run()
gomega.Expect(err).To(gomega.HaveOccurred())
time.Sleep(2 * time.Second)
service_path, _ := filepath.Glob(fmt.Sprintf("output/%s/services_%s_*.json", enclaveName, enclaveName))
endpoint := dive.GetServiceDetail(service_path[0], dive.HARDHAT_SERVICENAME)

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

Expand Down
24 changes: 19 additions & 5 deletions test/functional/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21.4

require (
github.com/cosmos/cosmos-sdk v0.50.6
github.com/ethereum/go-ethereum v1.14.3
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
Expand All @@ -27,10 +28,13 @@ require (
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.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/bits-and-blooms/bitset v1.10.0 // 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
Expand All @@ -45,6 +49,8 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.6 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
Expand All @@ -54,9 +60,10 @@ require (
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // 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/deckarep/golang-set/v2 v2.1.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 @@ -66,7 +73,7 @@ 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/ethereum/c-kzg-4844 v1.0.0 // 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
Expand All @@ -79,7 +86,7 @@ require (
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-ole/go-ole v1.3.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
Expand All @@ -88,7 +95,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
Expand All @@ -109,6 +116,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/holiman/uint256 v1.2.4 // 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
Expand Down Expand Up @@ -136,6 +144,7 @@ require (
github.com/mholt/archiver v3.1.1+incompatible // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
Expand All @@ -153,13 +162,13 @@ 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
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
Expand All @@ -170,10 +179,13 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
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/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // 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
Expand All @@ -186,6 +198,7 @@ require (
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
Expand All @@ -205,5 +218,6 @@ require (
gotest.tools/v3 v3.5.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v1.1.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
15 changes: 15 additions & 0 deletions test/functional/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dive

import (
"bytes"
"context"
"encoding/json"
"fmt"
"os"
Expand All @@ -11,6 +12,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/google/uuid"
iconclient "github.com/icon-project/icon-bridge/cmd/iconbridge/chain/icon"
iconlog "github.com/icon-project/icon-bridge/common/log"
Expand Down Expand Up @@ -69,6 +71,19 @@ func GetLatestBlockIcon(nodeURI string) (height int64, err error) {
return height, nil
}

func GetHardhatLatestBlock(nodeURI string) (height uint64, err error) {
ctx := context.Background()
client, err:=ethclient.Dial(nodeURI)
if err!=nil{
return 0, fmt.Errorf("error in receiving client")
}
height, err=client.BlockNumber(ctx)
if err!=nil{
return 0, fmt.Errorf("error in receiving last block")
}
return height, nil
}

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