Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: export test chain id #4089

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4,4 +4,6 @@ const (
ArabicaChainID = "arabica-11"
MochaChainID = "mocha-4"
MainnetChainID = "celestia"
// 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
Loading