Skip to content

Commit

Permalink
refactor: export test chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Dec 6, 2024
1 parent f11a169 commit 5edec3d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
4 changes: 1 addition & 3 deletions app/benchmarks/benchmark_ibc_update_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ func generateUpdateClientTransaction(b *testing.B, app *app.App, signer user.Sig
return msgs
}

var chainID = "test"

func makeState(nVals, height int) (sm.State, dbm.DB, map[string]types0.PrivValidator) {
vals := make([]types0.GenesisValidator, nVals)
privVals := make(map[string]types0.PrivValidator, nVals)
Expand All @@ -459,7 +457,7 @@ func makeState(nVals, height int) (sm.State, dbm.DB, map[string]types0.PrivValid
privVals[valAddr.String()] = types0.NewMockPVWithParams(pk, false, false)
}
s, _ := sm.MakeGenesisState(&types0.GenesisDoc{
ChainID: chainID,
ChainID: appconsts.TestChainID,
Validators: vals,
AppHash: nil,
})
Expand Down
2 changes: 1 addition & 1 deletion app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App,
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeight, util.EmptyAppOptions{})
genesis := genesis.NewDefaultGenesis().
WithChainID("test").
WithChainID(appconsts.TestChainID).
WithValidators(genesis.NewDefaultValidator(testnode.DefaultValidatorAccountName)).
WithConsensusParams(app.DefaultInitialConsensusParams())
genDoc, err := genesis.Export()
Expand Down
2 changes: 2 additions & 0 deletions pkg/appconsts/chain_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package appconsts

const (
ArabicaChainID = "arabica-11"
// TestChainID is the chain ID used for testing.
TestChainID = "test"
)
2 changes: 1 addition & 1 deletion pkg/appconsts/versioned_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func GetTimeoutCommit(v uint64) time.Duration {

// UpgradeHeightDelay returns the delay in blocks after a quorum has been reached that the chain should upgrade to the new version.
func UpgradeHeightDelay(chainID string, v uint64) int64 {
if chainID == "test" {
if chainID == TestChainID {
return 3
}
switch v {
Expand Down
4 changes: 2 additions & 2 deletions pkg/appconsts/versioned_consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ func TestUpgradeHeightDelay(t *testing.T) {
},
{
name: "the upgrade delay for chainID 'test' should be 3 regardless of the version",
chainID: "test",
chainID: appconsts.TestChainID,
version: 3,
expectedUpgradeHeightDelay: 3,
},
{
name: "the upgrade delay for chainID 'test' should be 3 regardless of the version",
chainID: "test",
chainID: appconsts.TestChainID,
version: 4,
expectedUpgradeHeightDelay: 3,
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var bigBlockManifest = Manifest{
ChainID: "test",
ChainID: appconsts.TestChainID,
Validators: 2,
TxClients: 2,
ValidatorResource: testnet.Resources{
Expand Down
5 changes: 2 additions & 3 deletions x/signal/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ func TestUpgradeIntegration(t *testing.T) {
cp := app.DefaultConsensusParams()
cp.Version.AppVersion = v2.Version
app, _ := testutil.SetupTestAppWithGenesisValSet(cp)
chainID := "test"
ctx := sdk.NewContext(app.CommitMultiStore(), tmtypes.Header{
Version: tmversion.Consensus{
App: v2.Version,
},
ChainID: chainID,
ChainID: appconsts.TestChainID,
}, false, tmlog.NewNopLogger())
goCtx := sdk.WrapSDKContext(ctx)
ctx = sdk.UnwrapSDKContext(goCtx)
Expand Down Expand Up @@ -89,7 +88,7 @@ func TestUpgradeIntegration(t *testing.T) {
require.False(t, shouldUpgrade)
require.EqualValues(t, 0, version)

ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(chainID, version))
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(appconsts.TestChainID, version))

shouldUpgrade, version = app.SignalKeeper.ShouldUpgrade(ctx)
require.True(t, shouldUpgrade)
Expand Down
6 changes: 3 additions & 3 deletions x/signal/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestTallyingLogic(t *testing.T) {
require.False(t, shouldUpgrade) // should be false because upgrade height hasn't been reached.
require.Equal(t, uint64(0), version)

ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay("test", version))
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + appconsts.UpgradeHeightDelay(appconsts.TestChainID, version))

shouldUpgrade, version = upgradeKeeper.ShouldUpgrade(ctx)
require.True(t, shouldUpgrade) // should be true because upgrade height has been reached.
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestGetUpgrade(t *testing.T) {
got, err := upgradeKeeper.GetUpgrade(ctx, &types.QueryGetUpgradeRequest{})
require.NoError(t, err)
assert.Equal(t, v2.Version, got.Upgrade.AppVersion)
assert.Equal(t, appconsts.UpgradeHeightDelay("test", v2.Version), got.Upgrade.UpgradeHeight)
assert.Equal(t, appconsts.UpgradeHeightDelay(appconsts.TestChainID, v2.Version), got.Upgrade.UpgradeHeight)
})
}

Expand Down Expand Up @@ -477,7 +477,7 @@ func setup(t *testing.T) (signal.Keeper, sdk.Context, *mockStakingKeeper) {
Block: 1,
App: 1,
},
ChainID: "test",
ChainID: appconsts.TestChainID,
}, false, log.NewNopLogger())
mockStakingKeeper := newMockStakingKeeper(
map[string]int64{
Expand Down

0 comments on commit 5edec3d

Please sign in to comment.