test: perform upgrade test from v53 (#24749)

This commit is contained in:
Alex | Interchain Labs
2025-05-16 17:50:29 +00:00
committed by GitHub
parent def657dafa
commit 30eaefc25b
4 changed files with 17 additions and 127 deletions
-63
View File
@@ -3,7 +3,6 @@
package systemtests
import (
"fmt"
"testing"
"time"
@@ -60,65 +59,3 @@ func TestUnorderedTXDuplicate(t *testing.T) {
return cli.QueryBalance(account2Addr, "stake") == 5000
}, 10*systest.Sut.BlockTime(), 200*time.Millisecond, "TX was not executed before timeout")
}
func TestTxBackwardsCompatability(t *testing.T) {
// Scenario:
// A transaction generated from a v0.53 chain without unordered and timeout_timestamp flags set should succeed.
// Conversely, a transaction generated from a v0.53 chain with unordered and timeout_timestamp flags set should fail.
var (
denom = "stake"
transferAmount int64 = 1000
)
systest.Sut.ResetChain(t)
v53CLI := systest.NewCLIWrapper(t, systest.Sut, systest.Verbose)
// we just get val addr for an address to send things to.
valAddr := v53CLI.GetKeyAddr("node0")
require.NotEmpty(t, valAddr)
// generate a deterministic account. we'll use this seed again later in the v50 chain.
senderAddr := v53CLI.AddKeyFromSeed("account1", testSeed)
v50CLI, legacySut := createLegacyBinary(t, initAccount{
address: senderAddr,
balance: "10000000000stake",
})
legacySut.StartChain(t)
bankSendCmdArgs := []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct"}
res, ok := v53CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
response, ok := v50CLI.AwaitTxCommitted(res, 15*time.Second)
require.True(t, ok)
code := gjson.Get(response, "code").Int()
require.Equal(t, int64(0), code)
bankSendCmdArgs = []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct", "--unordered", "--timeout-duration=8m"}
res, ok = v53CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
code = gjson.Get(res, "code").Int()
require.Equal(t, int64(2), code)
require.Contains(t, res, "errUnknownField")
legacySut.StopChain()
// Now start a v53 chain, and send a transaction from a v50 client.
// generate a deterministic account. we'll use this seed again later in the v50 chain.
systest.Sut.SetupChain()
systest.Sut.ModifyGenesisCLI(t,
// we need our sender to be account 5 because that's how it was signed in the v53 scenario.
[]string{"genesis", "add-genesis-account", senderAddr, "10000000000stake"},
)
systest.Sut.StartChain(t)
senderAddr = v50CLI.AddKeyFromSeed("account1", testSeed)
bankSendCmdArgs = []string{"tx", "bank", "send", senderAddr, valAddr, fmt.Sprintf("%d%s", transferAmount, denom), "--chain-id=" + v50CLI.ChainID(), "--fees=10stake", "--sign-mode=direct"}
res, ok = v50CLI.RunOnly(bankSendCmdArgs...)
require.True(t, ok)
response, ok = v53CLI.AwaitTxCommitted(res, 15*time.Second)
require.True(t, ok)
code = gjson.Get(response, "code").Int()
require.Equal(t, int64(0), code)
}
+2 -44
View File
@@ -20,50 +20,9 @@ import (
const (
testSeed = "scene learn remember glide apple expand quality spawn property shoe lamp carry upset blossom draft reject aim file trash miss script joy only measure"
upgradeHeight int64 = 22
upgradeName = "v050-to-v053" // must match UpgradeName in simapp/upgrades.go
upgradeName = "v053-to-v054" // must match UpgradeName in simapp/upgrades.go
)
type initAccount struct {
address string
balance string
}
func createLegacyBinary(t *testing.T, extraAccounts ...initAccount) (*systest.CLIWrapper, *systest.SystemUnderTest) {
t.Helper()
legacyBinary := systest.WorkDir + "/binaries/v0.50/simd"
//// Now we're going to switch to a v.50 chain.
t.Logf("+++ legacy binary: %s\n", legacyBinary)
// setup the v50 chain. v53 made some changes to testnet command, so we'll have to adjust here.
// this only uses 1 node.
legacySut := systest.NewSystemUnderTest("simd", systest.Verbose, 1, 1*time.Second)
// we need to explicitly set this here as the constructor infers the exec binary is in the "binaries" directory.
legacySut.SetExecBinary(legacyBinary)
legacySut.SetTestnetInitializer(systest.LegacyInitializerWithBinary(legacyBinary, legacySut))
legacySut.SetupChain()
v50CLI := systest.NewCLIWrapper(t, legacySut, systest.Verbose)
v50CLI.AddKeyFromSeed("account1", testSeed)
// Typically, SystemUnderTest will create a node with 4 validators. In the legacy setup, we create run a single validator network.
// This means we need to add 3 more accounts in order to make further account additions map to the same account number in state
modifications := [][]string{
{"genesis", "add-genesis-account", v50CLI.AddKey("foo"), "10000000000stake"},
{"genesis", "add-genesis-account", v50CLI.AddKey("bar"), "10000000000stake"},
{"genesis", "add-genesis-account", v50CLI.AddKey("baz"), "10000000000stake"},
}
for _, extraAccount := range extraAccounts {
modifications = append(modifications, []string{"genesis", "add-genesis-account", extraAccount.address, extraAccount.balance})
}
legacySut.ModifyGenesisCLI(t,
modifications...,
)
return v50CLI, legacySut
}
func TestChainUpgrade(t *testing.T) {
// Scenario:
// start a legacy chain with some state
@@ -74,9 +33,8 @@ func TestChainUpgrade(t *testing.T) {
currentBranchBinary := systest.Sut.ExecBinary()
currentInitializer := systest.Sut.TestnetInitializer()
legacyBinary := systest.WorkDir + "/binaries/v0.50/simd"
legacyBinary := systest.WorkDir + "/binaries/v0.53/simd"
systest.Sut.SetExecBinary(legacyBinary)
systest.Sut.SetTestnetInitializer(systest.NewModifyConfigYamlInitializer(legacyBinary, systest.Sut))
systest.Sut.SetupChain()
votingPeriod := 5 * time.Second // enough time to vote