Skip to content

Commit

Permalink
test(systemtests): fix failing tests (backport #22145) (#22154)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Peters <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Oct 7, 2024
1 parent 090efc9 commit 3fea483
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/systemtests/rest_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions tests/systemtests/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/systemtests/testnet_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/systemtests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3fea483

Please sign in to comment.