From 1f47292eb96d6ee01082983bea5fdebb4d94feed Mon Sep 17 00:00:00 2001 From: Indu-CR Date: Fri, 10 May 2024 11:47:22 +0530 Subject: [PATCH 1/2] test: updated test scripts for validating blocks in hardhat chain --- test/functional/go.mod | 20 +++++++++++++++++++- test/functional/helper.go | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/functional/go.mod b/test/functional/go.mod index 43149bd..783af89 100644 --- a/test/functional/go.mod +++ b/test/functional/go.mod @@ -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/onsi/ginkgo/v2 v2.16.0 @@ -26,9 +27,12 @@ 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/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/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect @@ -41,6 +45,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 @@ -50,8 +56,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/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 @@ -61,6 +69,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/c-kzg-4844 v1.0.0 // indirect github.com/fatih/color v1.16.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -70,6 +79,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-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 @@ -77,7 +87,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 @@ -97,6 +107,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/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -119,6 +130,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 @@ -141,6 +153,7 @@ require ( 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 @@ -151,9 +164,12 @@ 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/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/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/zondax/hid v0.9.2 // indirect @@ -162,6 +178,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 @@ -179,5 +196,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 ) diff --git a/test/functional/helper.go b/test/functional/helper.go index 1856701..e6d7f48 100644 --- a/test/functional/helper.go +++ b/test/functional/helper.go @@ -2,6 +2,7 @@ package dive import ( "bytes" + "context" "encoding/json" "fmt" "os" @@ -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" "github.com/onsi/gomega" ) @@ -56,6 +58,19 @@ func GetCosmosLatestBlock(nodeURI string) (height int64, err error) { return height, err } +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) From b71f0e491b484f62d81a2916c3be228f8cfaf0d7 Mon Sep 17 00:00:00 2001 From: Indu-CR Date: Mon, 13 May 2024 16:19:34 +0530 Subject: [PATCH 2/2] test: updated test scripts for validating blocks in hardhat chain --- test/functional/dive_test.go | 14 ++++++++++++++ test/functional/go.mod | 18 +----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/test/functional/dive_test.go b/test/functional/dive_test.go index 3a8ee7e..a6696e8 100644 --- a/test/functional/dive_test.go +++ b/test/functional/dive_test.go @@ -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() { @@ -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)) }) }) diff --git a/test/functional/go.mod b/test/functional/go.mod index b18ac18..71476a8 100644 --- a/test/functional/go.mod +++ b/test/functional/go.mod @@ -63,11 +63,7 @@ require ( 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 -<<<<<<< HEAD github.com/deckarep/golang-set/v2 v2.1.0 // indirect -======= - github.com/deckarep/golang-set v1.8.0 // indirect ->>>>>>> ef1d62d0d9084cbc629ce045313288195eb8e410 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 @@ -77,12 +73,8 @@ 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 -<<<<<<< HEAD github.com/ethereum/c-kzg-4844 v1.0.0 // indirect -======= - github.com/ethereum/go-ethereum v1.10.16 // indirect github.com/evalphobia/logrus_fluent v0.5.4 // indirect ->>>>>>> ef1d62d0d9084cbc629ce045313288195eb8e410 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 @@ -94,11 +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 -<<<<<<< HEAD github.com/go-ole/go-ole v1.3.0 // indirect -======= - github.com/go-stack/stack v1.8.0 // indirect ->>>>>>> ef1d62d0d9084cbc629ce045313288195eb8e410 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 @@ -174,7 +162,6 @@ 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 @@ -196,12 +183,9 @@ 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 -<<<<<<< HEAD + 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/tinylib/msgp v1.1.2 // indirect ->>>>>>> ef1d62d0d9084cbc629ce045313288195eb8e410 github.com/ulikunitz/xz v0.5.11 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect