test(systemtests): fix failing tests (backport #22145) (#22154)

Co-authored-by: Alexander Peters <alpe@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
mergify[bot] 2024-10-07 15:42:11 +02:00 committed by GitHub
parent 090efc9f3b
commit 3fea483df8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 4 deletions

View File

@ -79,9 +79,9 @@ func GetRequestWithHeaders(t *testing.T, url string, headers map[string]string,
defer func() {
_ = res.Body.Close()
}()
require.Equal(t, expCode, res.StatusCode, "status code should be %d, got: %d", expCode, res.StatusCode)
body, err := io.ReadAll(res.Body)
require.NoError(t, err)
require.Equal(t, expCode, res.StatusCode, "status code should be %d, got: %d, %s", expCode, res.StatusCode, body)
return body
}

View File

@ -766,6 +766,11 @@ func (s *SystemUnderTest) CurrentHeight() int64 {
return s.currentHeight.Load()
}
// NodesCount returns the number of node instances used
func (s *SystemUnderTest) NodesCount() int {
return s.nodesCount
}
type Node struct {
ID string
IP string

View File

@ -51,6 +51,20 @@ func NewSingleHostTestnetCmdInitializer(
}
}
// InitializerWithBinary creates new SingleHostTestnetCmdInitializer from sut with given binary
func InitializerWithBinary(binary string, sut *SystemUnderTest) TestnetInitializer {
return NewSingleHostTestnetCmdInitializer(
binary,
WorkDir,
sut.chainID,
sut.outputDir,
sut.initialNodesCount,
sut.minGasPrice,
sut.CommitTimeout(),
sut.Log,
)
}
func (s SingleHostTestnetCmdInitializer) Initialize() {
args := []string{
"testnet",

View File

@ -28,14 +28,14 @@ func TestChainUpgrade(t *testing.T) {
currentBranchBinary := sut.execBinary
currentInitializer := sut.testnetInitializer
sut.SetExecBinary(legacyBinary)
sut.SetTestnetInitializer(NewModifyConfigYamlInitializer(legacyBinary, sut))
sut.SetTestnetInitializer(InitializerWithBinary(legacyBinary, sut))
sut.SetupChain()
votingPeriod := 5 * time.Second // enough time to vote
sut.ModifyGenesisJSON(t, SetGovVotingPeriod(t, votingPeriod))
const (
upgradeHeight int64 = 22
upgradeName = "v050-to-v051"
upgradeName = "v050-to-v052" // must match UpgradeName in simapp/upgrades.go
)
sut.StartChain(t, fmt.Sprintf("--halt-height=%d", upgradeHeight+1))