Skip to content

Commit

Permalink
Improve tests (#733)
Browse files Browse the repository at this point in the history
Improve tests based on feedback from #712
  • Loading branch information
nytzuga authored Jul 18, 2023
1 parent fca9bac commit 8b2271d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
42 changes: 22 additions & 20 deletions tests/utils/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ import (
"github.com/onsi/gomega"
)

const (
// Timeout to boot the AvalancheGo node
bootAvalancheNodeTimeout = 5 * time.Minute

// Timeout for the health API to check the AvalancheGo is ready
healthCheckTimeout = 5 * time.Second
)

// At boot time subnets are created, one for each test suite. This global
// variable has all the subnets IDs that can be used.
//
// One process creates the AvalancheGo node and all the subnets, and these
// subnets IDs are passed to all other processes and stored in this global
// variable
var BlockchainIDs map[string]string

// RunCommand starts the command [bin] with the given [args] and returns the command to the caller
// TODO cmd package mentions we can do this more efficiently with cmd.NewCmdOptions rather than looping
// and calling Status().
Expand Down Expand Up @@ -60,32 +76,18 @@ func RegisterPingTest() {
})
}

// At boot time subnets are created, one for each test suite. This global
// variable has all the subnets IDs that can be used.
//
// One process creates the AvalancheGo node and all the subnets, and these
// subnets IDs are passed to all other processes and stored in this global
// variable
var BlockchainIDs map[string]string

// Timeout to boot the AvalancheGo node
var bootAvalancheNodeTimeout = 5 * time.Minute

// Timeout for the health API to check the AvalancheGo is ready
var healthCheckTimeout = 5 * time.Second

func RegisterNodeRun() {
// Keep track of the AvalancheGo external bash script, it is null for most
// processes except the first process that starts AvalancheGo
var startCmd *cmd.Cmd

// Our test suite runs in a separated processes, ginkgo hasI
// SynchronizedBeforeSuite() which is promised to run once, and its output is
// passed over to each worker.
// Our test suite runs in separate processes, ginkgo has
// SynchronizedBeforeSuite() which runs once, and its return value is passed
// over to each worker.
//
// In here an AvalancheGo node instance is started, and subnets are created for
// each test case. Each test case has its own subnet, therefore all tests can
// run in parallel without any issue.
// Here an AvalancheGo node instance is started, and subnets are created for
// each test case. Each test case has its own subnet, therefore all tests
// can run in parallel without any issue.
//
// This function also compiles all the solidity contracts
var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
Expand Down
8 changes: 6 additions & 2 deletions tests/utils/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ func GetDefaultChainURI(blockchainID string) string {
// 3. npx is available in the ./contracts directory
func RunDefaultHardhatTests(ctx context.Context, blockchainID string, test string) {
chainURI := GetDefaultChainURI(blockchainID)
log.Info("Executing HardHat tests on a new blockchain", "blockchainID", blockchainID, "test", test)
log.Info("Using subnet", "ChainURI", chainURI)
log.Info(
"Executing HardHat tests on a new blockchain",
"blockchainID", blockchainID,
"test", test,
"ChainURI", chainURI,
)

cmdPath := "./contracts"
// test path is relative to the cmd path
Expand Down

0 comments on commit 8b2271d

Please sign in to comment.