Skip to content

Commit

Permalink
fix(integration): waiting for node readiness
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
gfanton committed Oct 19, 2023
1 parent 19cfdb0 commit f597eda
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions gno.land/pkg/integration/testing_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"sync"
"testing"
"time"

"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/tm2/pkg/bft/config"
Expand Down Expand Up @@ -115,9 +116,8 @@ func SetupGnolandTestScript(t *testing.T, txtarDir string) testscript.Params {
// Create the Node
nodecfg := gnoland.NewInMemoryNodeConfig(cfg)

node, err := gnoland.NewInMemoryNode(logger, nodecfg)
if err != nil {
err = fmt.Errorf("unable to start node: %w", err)
var node *node.Node
if node, err = execInMemoryGnoland(ts); err != nil {
break
}

Expand All @@ -133,6 +133,7 @@ func SetupGnolandTestScript(t *testing.T, txtarDir string) testscript.Params {
}
})


// Register cleanup.
nodes[sid] = &testNode{
Node: node,
Expand Down Expand Up @@ -208,6 +209,27 @@ func SetupGnolandTestScript(t *testing.T, txtarDir string) testscript.Params {
}
}


func execInMemoryGnoland(ts *testscript.Params) (*node.Node, error) {
node, err = gnoland.NewInMemoryNode(logger, nodecfg)
if err != nil {
return nil, fmt.Errorf("unable to create node: %w", err)
}

if err = node.Start(); err = nil {
return nil, fmt.Errorf("unable to start node: %w", err)
}

select {
case <-time.After(time.Second * 6):
_ = node.Close()
return errors.New("timeout while waiting for the node to start")
case <-waitForNodeReadiness(node): // ok
return nil
}
}


func getSessionID(ts *testscript.TestScript) string {
works := ts.Getenv("WORK")
sum := crc32.ChecksumIEEE([]byte(works))
Expand Down

0 comments on commit f597eda

Please sign in to comment.