diff --git a/test/e2e/benchmark/benchmark.go b/test/e2e/benchmark/benchmark.go index 39872f1da8..356bc870e7 100644 --- a/test/e2e/benchmark/benchmark.go +++ b/test/e2e/benchmark/benchmark.go @@ -100,8 +100,10 @@ func (b *BenchmarkTest) SetupNodes() error { // Run runs the benchmark test for the specified duration in the manifest. func (b *BenchmarkTest) Run() error { - log.Println("Starting testnet") - err := b.Start() + log.Println("Starting benchmark testnet") + + log.Println("Starting nodes") + err := b.StartNodes() if err != nil { return fmt.Errorf("failed to start testnet: %v", err) } @@ -116,6 +118,20 @@ func (b *BenchmarkTest) Run() error { } } + // wait for the nodes to sync + log.Println("Waiting for nodes to sync") + err = b.WaitToSync() + if err != nil { + return err + } + + // start tx clients + log.Println("Starting tx clients") + err = b.StartTxClients() + if err != nil { + return fmt.Errorf("failed to start tx clients: %v", err) + } + // wait some time for the tx clients to submit transactions time.Sleep(b.manifest.TestDuration) diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index 2e20386ae8..4b3beebe99 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -323,30 +323,15 @@ func (t *Testnet) RemoteRPCEndpoints() ([]string, error) { return rpcEndpoints, nil } -func (t *Testnet) Start() error { +// WaitToSync waits for the started nodes to sync with the network and move +// past the genesis block. +func (t *Testnet) WaitToSync() error { genesisNodes := make([]*Node, 0) for _, node := range t.nodes { if node.StartHeight == 0 { genesisNodes = append(genesisNodes, node) } } - // start genesis nodes asynchronously - for _, node := range genesisNodes { - err := node.StartAsync() - if err != nil { - return fmt.Errorf("node %s failed to start: %w", node.Name, err) - } - } - log.Info().Msg("forwarding ports for genesis nodes") - // wait for instances to be running - for _, node := range genesisNodes { - err := node.WaitUntilStartedAndForwardPorts() - if err != nil { - return fmt.Errorf("node %s failed to start: %w", node.Name, err) - } - } - // wait for nodes to sync - log.Info().Msg("waiting for genesis nodes to sync") for _, node := range genesisNodes { log.Info().Str("name", node.Name).Msg( "waiting for node to sync") @@ -373,6 +358,50 @@ func (t *Testnet) Start() error { time.Sleep(time.Duration(i) * time.Second) } } + return nil +} + +// StartNodes starts the testnet nodes and forwards the ports. +// It does not wait for the nodes to produce blocks. +// For that, use WaitToSync. +func (t *Testnet) StartNodes() error { + genesisNodes := make([]*Node, 0) + for _, node := range t.nodes { + if node.StartHeight == 0 { + genesisNodes = append(genesisNodes, node) + } + } + // start genesis nodes asynchronously + for _, node := range genesisNodes { + err := node.StartAsync() + if err != nil { + return fmt.Errorf("node %s failed to start: %w", node.Name, err) + } + } + log.Info().Msg("forwarding ports for genesis nodes") + // wait for instances to be running + for _, node := range genesisNodes { + err := node.WaitUntilStartedAndForwardPorts() + if err != nil { + return fmt.Errorf("node %s failed to start: %w", node.Name, err) + } + } + return nil +} + +func (t *Testnet) Start() error { + // start nodes and forward ports + err := t.StartNodes() + if err != nil { + return err + } + // wait for nodes to sync + log.Info().Msg("waiting for genesis nodes to sync") + err = t.WaitToSync() + if err != nil { + return err + } + return t.StartTxClients() }