From 08567ff20e372e4f4204a91ca64a371538742bed Mon Sep 17 00:00:00 2001 From: Simon Warta <2603011+webmaster128@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:09:14 +0100 Subject: [PATCH] Improve block time estimation to satbilize system tests (#1838) --- tests/system/system.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/system/system.go b/tests/system/system.go index 1fc25313..f89ce421 100644 --- a/tests/system/system.go +++ b/tests/system/system.go @@ -39,11 +39,13 @@ var ( // SystemUnderTest blockchain provisioning type SystemUnderTest struct { - ExecBinary string - blockListener *EventListener - currentHeight int64 - chainID string - outputDir string + ExecBinary string + blockListener *EventListener + currentHeight int64 + chainID string + outputDir string + // blockTime is the the expected/desired block time. This is not going to be very precise + // since Tendermint consensus does not allow specifying it directly. blockTime time.Duration rpcAddr string initialNodesCount int @@ -94,6 +96,9 @@ func (s *SystemUnderTest) SetupChain() { panic(err.Error()) } + // The commit timeout is a lower bound for the block time. We try to set it to a level that allows us to reach the expected block time. + commitTimeout := time.Duration((int64(s.blockTime) * 90) / 100) // leave 10% for all other operations + args := []string{ "testnet", "init-files", @@ -101,7 +106,7 @@ func (s *SystemUnderTest) SetupChain() { "--output-dir=" + s.outputDir, "--v=" + strconv.Itoa(s.initialNodesCount), "--keyring-backend=test", - "--commit-timeout=" + s.blockTime.String(), + "--commit-timeout=" + commitTimeout.String(), "--minimum-gas-prices=" + s.minGasPrice, "--starting-ip-address", "", // empty to use host systems "--single-host",