Skip to content

Commit

Permalink
test: updated test scripts for validating blocks in icon chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Indu-CR committed May 8, 2024
1 parent de4371c commit 718e5e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 40 deletions.
18 changes: 9 additions & 9 deletions test/functional/dive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
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.GetServiceDetailsIcon(service_path[0], dive.ICON_CONFIG0_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand All @@ -551,7 +551,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
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.GetServiceDetailsIcon(service_path[0], dive.ICON_CONFIG0_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand All @@ -566,7 +566,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
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.GetServiceDetailsIcon(service_path[0], dive.ICON_CONFIG0_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand All @@ -581,7 +581,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
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.GetServiceDetailsIcon(service_path[0], dive.ICON_CONFIG1_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ICON_CONFIG1_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand All @@ -599,7 +599,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
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.GetServiceDetailsIcon(service_path[0], dive.ICON_CONFIG0_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ICON_CONFIG0_SERVICENAME)

height, err := dive.GetLatestBlockIcon(endpoint)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand Down Expand Up @@ -743,7 +743,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
err := cmd.Run()
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_ARCHWAY_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.DEFAULT_ARCHWAY_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
Expand All @@ -758,7 +758,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
err := cmd.Run()
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.ARCHWAY_CONFIG0_SERVICENAME)
endpoint := dive.GetServiceDetail(service_path[0], dive.ARCHWAY_CONFIG0_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
Expand Down Expand Up @@ -792,7 +792,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
err := cmd.Run()
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)
endpoint := dive.GetServiceDetail(service_path[0], dive.DEFAULT_NEUTRON_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
Expand All @@ -807,7 +807,7 @@ var _ = ginkgo.Describe("DIVE CLI App", func() {
err := cmd.Run()
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)
endpoint := dive.GetServiceDetail(service_path[0], dive.NEUTRON_CONFIG0_SERVICENAME)

// Get latest block and check if node is producing blocks
height, err := dive.GetCosmosLatestBlock(endpoint)
Expand Down
34 changes: 3 additions & 31 deletions test/functional/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ type NodeInfo struct {
Nid string `json:"nid"`
}

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

type IconNodeInfo struct {
type Node struct {
EndpointPublic string `json:"endpoint_public"`
}

Expand Down Expand Up @@ -238,32 +234,8 @@ func GetServiceDetails(servicesJson string, service string) (serviceName string,

}

func GetServiceDetailsCosmos(servicesJson string, service string) (endpoint string) {
var data map[string]CosmosNodeInfo
mutex3.Lock()
defer mutex3.Unlock()

fileContent2, err := os.ReadFile(servicesJson)
if err != nil {
panic(err)
}

err = json.Unmarshal(fileContent2, &data)
if err != nil {
panic(err)
}

for key, value := range data {
if key == service {
endpoint = value.EndpointPublic
}
}
return endpoint

}

func GetServiceDetailsIcon(servicesJson string, service string) (endpoint string) {
var data map[string]CosmosNodeInfo
func GetServiceDetail(servicesJson string, service string) (endpoint string) {
var data map[string]Node
mutex3.Lock()
defer mutex3.Unlock()

Expand Down

0 comments on commit 718e5e9

Please sign in to comment.