Skip to content

Commit

Permalink
Enable bootstrap check on teardown for coreth testing
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Nov 9, 2023
1 parent ebaf9d4 commit eae6f43
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func AddEphemeralNode(network testnet.Network, flags testnet.FlagsMap) testnet.N

// Wait for the given node to report healthy.
func WaitForHealthy(node testnet.Node) {
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(DefaultContext(), node))
// Need to use explicit context (vs DefaultContext()) to support use with DeferCleanup
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(ctx, node))
}

// Sends an eth transaction, waits for the transaction receipt to be issued
Expand Down Expand Up @@ -195,12 +198,25 @@ func WithSuggestedGasPrice(ethClient ethclient.Client) common.Option {

// Verify that a new node can bootstrap into the network.
func CheckBootstrapIsPossible(network testnet.Network) {
require := require.New(ginkgo.GinkgoT())

if len(os.Getenv(SkipBootstrapChecksEnvName)) > 0 {
tests.Outf("{{yellow}}Skipping bootstrap check due to the %s env var being set", SkipBootstrapChecksEnvName)
return
}
ginkgo.By("checking if bootstrap is possible with the current network state")
node := AddEphemeralNode(network, testnet.FlagsMap{})

// Call network.AddEphemeralNode instead of AddEphemeralNode for compatibility
// with ginkgo.DeferCleanup. It's not possible to call DeferCleanup from
// within a function called by DeferCleanup.
node, err := network.AddEphemeralNode(ginkgo.GinkgoWriter, testnet.FlagsMap{})
defer func() {
if node != nil {
tests.Outf("Shutting down ephemeral node %s\n", node.GetID())
require.NoError(node.Stop())
}
}()
require.NoError(err)
WaitForHealthy(node)
}

Expand Down

0 comments on commit eae6f43

Please sign in to comment.