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

chore: upgrade tests #2222

Merged
2 changes: 1 addition & 1 deletion app/client/cli/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestInitCmd(t *testing.T) {
err = os.Mkdir(nodeHome, 0755)
require.NoError(t, err)

rootCmd, _ := cli.NewRootCmd()
rootCmd := cli.NewRootCmd()
rootCmd.SetArgs([]string{
"init",
"test",
Expand Down
29 changes: 3 additions & 26 deletions app/simulation/app_after_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import (
"testing"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
"github.com/stretchr/testify/require"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli"

regen "github.com/regen-network/regen-ledger/v5/app"
Expand All @@ -32,17 +29,7 @@ func TestAppAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

app := regen.NewRegenApp(
logger,
db,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
fauxMerkleModeOpt,
)
app := regen.NewRegenApp(logger, db, nil, true, simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{})
require.Equal(t, regen.AppName, app.Name())

// run randomized simulation
Expand All @@ -64,7 +51,7 @@ func TestAppAfterImport(t *testing.T) {

fmt.Printf("exporting genesis...\n")

exported, err := app.ExportAppStateAndValidators(true, []string{})
exported, err := app.ExportAppStateAndValidators(true, []string{}, []string{})
require.NoError(t, err)

fmt.Printf("importing genesis...\n")
Expand All @@ -77,17 +64,7 @@ func TestAppAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(newDir))
}()

newApp := regen.NewRegenApp(
log.NewNopLogger(),
newDB,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
fauxMerkleModeOpt,
)
newApp := regen.NewRegenApp(logger, db, nil, true, simcli.FlagPeriodValue, simtestutil.EmptyAppOptions{})
require.Equal(t, regen.AppName, newApp.Name())

newApp.InitChain(abci.RequestInitChain{
Expand Down
6 changes: 3 additions & 3 deletions app/simulation/app_determinism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/stretchr/testify/require"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
Expand Down Expand Up @@ -46,24 +47,23 @@ func TestAppDeterminism(t *testing.T) {
}

db := dbm.NewMemDB()

app := regen.NewRegenApp(
logger,
db,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
interBlockCacheOpt(),
baseapp.SetChainID(SimAppChainID),
)
require.Equal(t, regen.AppName, app.Name())

fmt.Printf(
"running app-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",
config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed,
)

_, _, err := simulateFromSeed(t, app, config)

require.NoError(t, err)
Expand Down
10 changes: 3 additions & 7 deletions app/simulation/app_import_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"

regen "github.com/regen-network/regen-ledger/v5/app"
"github.com/regen-network/regen-ledger/x/data/v3"
Expand All @@ -53,8 +53,6 @@ func TestAppImportExport(t *testing.T) {
db,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
fauxMerkleModeOpt,
Expand All @@ -75,7 +73,7 @@ func TestAppImportExport(t *testing.T) {

fmt.Printf("exporting genesis...\n")

exported, err := app.ExportAppStateAndValidators(false, []string{})
exported, err := app.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err)

fmt.Printf("importing genesis...\n")
Expand All @@ -93,8 +91,6 @@ func TestAppImportExport(t *testing.T) {
newDB,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
fauxMerkleModeOpt,
Expand Down Expand Up @@ -145,7 +141,7 @@ func TestAppImportExport(t *testing.T) {
}},

// ibc modules
{app.GetKey(ibchost.StoreKey), newApp.GetKey(ibchost.StoreKey), [][]byte{}},
{app.GetKey(ibcexported.StoreKey), newApp.GetKey(ibcexported.StoreKey), [][]byte{}},
{app.GetKey(ibctransfertypes.StoreKey), newApp.GetKey(ibctransfertypes.StoreKey), [][]byte{}},

// regen modules
Expand Down
4 changes: 1 addition & 3 deletions app/simulation/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

func TestApp(t *testing.T) {
config := simcli.NewConfigFromFlags()
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "app", "simulation".false, true)
db, dir, logger, skip, err := simtestutil.SetupSimulation(config, "app", "simulation", false, true)
if skip {
t.Skip("skipping app simulation")
}
Expand All @@ -31,8 +31,6 @@ func TestApp(t *testing.T) {
db,
nil,
true,
map[int64]bool{},
regen.DefaultNodeHome,
simcli.FlagPeriodValue,
simtestutil.EmptyAppOptions{},
fauxMerkleModeOpt,
Expand Down
23 changes: 10 additions & 13 deletions app/testsuite/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@ import (
"os"
"testing"

"github.com/stretchr/testify/require"
dbm "github.com/cometbft/cometbft-db"
"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/libs/log"

"github.com/regen-network/regen-ledger/v5/app"
)

func TestSimAppExportAndBlockedAddrs(t *testing.T) {
encCfg := app.MakeEncodingConfig()
db := dbm.NewMemDB()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
regenApp := NewAppWithCustomOptions(t, false, SetupOptions{
Logger: logger,
DB: db,
InvCheckPeriod: 0,
EncConfig: encCfg,
HomePath: app.DefaultNodeHome,
SkipUpgradeHeights: map[int64]bool{},
AppOpts: EmptyAppOptions{},
})
setupOptions := SetupOptions{
Logger: logger,
DB: db,
InvCheckPeriod: 0,
AppOpts: EmptyAppOptions{},
}
regenApp := NewAppWithCustomOptions(t, false, setupOptions)

for acc := range app.GetMaccPerms() {
require.Equal(t, true, regenApp.BankKeeper.BlockedAddr(regenApp.AccountKeeper.GetModuleAddress(acc)),
Expand All @@ -34,7 +31,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
regenApp.Commit()

// Making a new app object with the db, so that initchain hasn't been called
app2 := app.NewRegenApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, app.DefaultNodeHome, 0, encCfg, EmptyAppOptions{})
_, err := app2.ExportAppStateAndValidators(false, []string{})
app2 := app.NewRegenApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, setupOptions.InvCheckPeriod, EmptyAppOptions{})
_, err := app2.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}
5 changes: 3 additions & 2 deletions app/testsuite/modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ package testsuite
import (
"testing"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/stretchr/testify/suite"

data "github.com/regen-network/regen-ledger/x/data/v3/client/testsuite"
ecocredit "github.com/regen-network/regen-ledger/x/ecocredit/v3/client/testsuite"
)

func TestDataIntegration(t *testing.T) {
cfg := DefaultConfig()
cfg := network.DefaultConfig(NewTestNetworkFixture)
suite.Run(t, data.NewIntegrationTestSuite(cfg))
}

func TestEcocreditIntegration(t *testing.T) {
cfg := DefaultConfig()
cfg := network.DefaultConfig(NewTestNetworkFixture)
suite.Run(t, ecocredit.NewIntegrationTestSuite(cfg))
}
2 changes: 1 addition & 1 deletion scripts/generate_cli_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// generate documentation for all regen app commands
func main() {
rootCmd, _ := cli.NewRootCmd()
rootCmd := cli.NewRootCmd()
err := doc.GenMarkdownTree(rootCmd, "commands")
if err != nil {
log.Fatal(err)
Expand Down
37 changes: 37 additions & 0 deletions scripts/start_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Set environment variables
export coins="10000000000stake,100000000000samoleans"
export coinsV="5000000000stake"
export REGEN_KEYRING_BACKEND=test
export CHAINID=regen-local
export TMCFG=~/.regen/config/config.toml
export APPCFG=~/.regen/config/app.toml

# Remove existing regen configuration
rm -rf ~/.regen

# Add a new key for the validator
./build/regen keys add validator --keyring-backend test

# Initialize the chain
./build/regen init dev-val --chain-id $CHAINID

# Add genesis account
./build/regen genesis add-genesis-account validator --keyring-backend test $coins

# Generate a genesis transaction
./build/regen genesis gentx validator $coinsV --chain-id $CHAINID --keyring-backend test

# Collect genesis transactions
./build/regen genesis collect-gentxs

# Validate genesis file
./build/regen genesis validate-genesis

# Modify configuration files
perl -i -pe 's|timeout_commit = ".*?"|timeout_commit = "2s"|g' $TMCFG
perl -i -pe 's|minimum-gas-prices = ""|minimum-gas-prices = "0stake"|g' $APPCFG

# Start the node
./build/regen start --api.enable true --grpc.address="0.0.0.0:9090"
19 changes: 10 additions & 9 deletions x/data/server/testsuite/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkmodules "github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -33,7 +32,6 @@ func setup(t *testing.T) fixture.Factory {
ff := fixture.NewFixtureFactory(t, 8)
baseApp := ff.BaseApp()
cdc := ff.Codec()
amino := codec.NewLegacyAmino()

authtypes.RegisterInterfaces(cdc.InterfaceRegistry())
params.RegisterInterfaces(cdc.InterfaceRegistry())
Expand All @@ -52,22 +50,25 @@ func setup(t *testing.T) fixture.Factory {
baseApp.MountStore(paramsKey, storetypes.StoreTypeIAVL)
baseApp.MountStore(tkey, storetypes.StoreTypeTransient)

authSubspace := paramstypes.NewSubspace(cdc, amino, paramsKey, tkey, authtypes.ModuleName)
bankSubspace := paramstypes.NewSubspace(cdc, amino, paramsKey, tkey, banktypes.ModuleName)

maccPerms := map[string][]string{
minttypes.ModuleName: {authtypes.Minter},
}

authority := authtypes.NewModuleAddress("gov")

accountKeeper := authkeeper.NewAccountKeeper(
cdc, authKey, authSubspace, authtypes.ProtoBaseAccount, maccPerms, "regen",
cdc,
authKey,
authtypes.ProtoBaseAccount,
maccPerms,
"regen",
authority.String(),
)

bankKeeper := bankkeeper.NewBaseKeeper(
cdc, bankKey, accountKeeper, bankSubspace, nil,
)
bankKeeper := bankkeeper.NewBaseKeeper(cdc, bankKey, accountKeeper, nil, authority.String())

dataMod := datamodule.NewModule(dataKey, accountKeeper, bankKeeper)
dataMod.RegisterInterfaces(cdc.InterfaceRegistry())
ff.SetModules([]sdkmodules.AppModule{dataMod})

return ff
Expand Down
2 changes: 2 additions & 0 deletions x/ecocredit/base/simulation/msg_add_class_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ func SimulateMsgAddClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.BankKee
}

msg := &govtypes.MsgSubmitProposal{
Title: simtypes.RandStringOfLength(r, 10),
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Summary: simtypes.RandStringOfLength(r, 10),
}

txCtx := simulation.OperationInput{
Expand Down
2 changes: 2 additions & 0 deletions x/ecocredit/base/simulation/msg_add_credit_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ func SimulateMsgAddCreditType(ak ecocredit.AccountKeeper, bk ecocredit.BankKeepe
}

msg := &govtypes.MsgSubmitProposal{
Title: simtypes.RandStringOfLength(r, 10),
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Summary: simtypes.RandStringOfLength(r, 10),
}

txCtx := simulation.OperationInput{
Expand Down
2 changes: 2 additions & 0 deletions x/ecocredit/base/simulation/msg_remove_class_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ func SimulateMsgRemoveClassCreator(ak ecocredit.AccountKeeper, bk ecocredit.Bank
}

msg := &govtypes.MsgSubmitProposal{
Title: simtypes.RandStringOfLength(r, 10),
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Summary: simtypes.RandStringOfLength(r, 10),
}

txCtx := simulation.OperationInput{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ func SimulateMsgSetClassCreatorAllowlist(ak ecocredit.AccountKeeper, bk ecocredi
}

msg := &govtypes.MsgSubmitProposal{
Title: simtypes.RandStringOfLength(r, 10),
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Summary: simtypes.RandStringOfLength(r, 10),
}

txCtx := simulation.OperationInput{
Expand Down
2 changes: 2 additions & 0 deletions x/ecocredit/base/simulation/msg_update_class_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ func SimulateMsgUpdateClassFee(ak ecocredit.AccountKeeper, bk ecocredit.BankKeep
}

msg := &govtypes.MsgSubmitProposal{
Title: simtypes.RandStringOfLength(r, 10),
Messages: []*codectypes.Any{anyMsg},
InitialDeposit: deposit,
Proposer: proposerAddr,
Metadata: simtypes.RandStringOfLength(r, 10),
Summary: simtypes.RandStringOfLength(r, 10),
}

txCtx := simulation.OperationInput{
Expand Down
Loading
Loading