Skip to content

Commit

Permalink
commenting out tests which need to be migrated to interchaintest
Browse files Browse the repository at this point in the history
  • Loading branch information
spoo-bar committed Jun 12, 2024
1 parent f08899d commit 52234cb
Show file tree
Hide file tree
Showing 19 changed files with 5,432 additions and 5,714 deletions.
257 changes: 134 additions & 123 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,86 @@ package app
import (
"fmt"
"testing"
"time"

"cosmossdk.io/log"
math "cosmossdk.io/math"
tmjson "github.com/cometbft/cometbft/libs/json"
tmtypes "github.com/cometbft/cometbft/types"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
tmdb "github.com/cosmos/cosmos-db"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/testutil/mock"
simapp "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"

abci "github.com/cometbft/cometbft/abci/types"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
)

var emptyWasmOpts []wasmkeeper.Option = nil
// import (
// "fmt"
// "testing"
// "time"

// "cosmossdk.io/log"
// math "cosmossdk.io/math"
// tmjson "github.com/cometbft/cometbft/libs/json"
// tmtypes "github.com/cometbft/cometbft/types"
// tmdb "github.com/cosmos/cosmos-db"
// codectypes "github.com/cosmos/cosmos-sdk/codec/types"
// cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
// "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
// "github.com/cosmos/cosmos-sdk/testutil/mock"
// simapp "github.com/cosmos/cosmos-sdk/testutil/sims"
// sdk "github.com/cosmos/cosmos-sdk/types"
// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
// stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
// "github.com/stretchr/testify/require"

// abci "github.com/cometbft/cometbft/abci/types"

// wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
// )

func TestArchwaydExport(t *testing.T) {
db := tmdb.NewMemDB()
logger := log.NewNopLogger()
encoding := MakeEncodingConfig()
gapp := NewArchwayApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding,
EmptyBaseAppOptions{}, emptyWasmOpts)

privValidator := mock.NewPV()
pubKey, err := privValidator.GetPubKey()
require.NoError(t, err)

// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})

// generate genesis account
senderPrivKey := secp256k1.GenPrivKey()
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
balance := banktypes.Balance{
Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000000000000))),
}
var emptyWasmOpts []wasmkeeper.Option = nil

genesisState := NewDefaultGenesisState(gapp.AppCodec())
genesisState = genesisStateWithValSet(t, gapp, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
// init chain must be called to stop deliverState from being nil
stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)

_, err = gapp.InitChain(
&abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: simapp.DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
require.NoError(t, err, "InitChain must not fail")

_, err = gapp.Commit()
require.NoError(t, err, "Commit must not fail")

_, err = gapp.ExportAppStateAndValidators(false, []string{}, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}
// func TestArchwaydExport(t *testing.T) {
// db := tmdb.NewMemDB()
// logger := log.NewNopLogger()
// encoding := MakeEncodingConfig()
// gapp := NewArchwayApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, 0, encoding,
// EmptyBaseAppOptions{}, emptyWasmOpts)

// privValidator := mock.NewPV()
// pubKey, err := privValidator.GetPubKey()
// require.NoError(t, err)

// // create validator set with single validator
// validator := tmtypes.NewValidator(pubKey, 1)
// valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})

// // generate genesis account
// senderPrivKey := secp256k1.GenPrivKey()
// acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0)
// balance := banktypes.Balance{
// Address: acc.GetAddress().String(),
// Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000000000000))),
// }

// genesisState := NewDefaultGenesisState(gapp.AppCodec())
// genesisState = genesisStateWithValSet(t, gapp, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)
// // init chain must be called to stop deliverState from being nil
// stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ")
// require.NoError(t, err)

// _, err = gapp.InitChain(
// &abci.RequestInitChain{
// Validators: []abci.ValidatorUpdate{},
// ConsensusParams: simapp.DefaultConsensusParams,
// AppStateBytes: stateBytes,
// },
// )
// require.NoError(t, err, "InitChain must not fail")

// _, err = gapp.Commit()
// require.NoError(t, err, "Commit must not fail")

// _, err = gapp.ExportAppStateAndValidators(false, []string{}, []string{})
// require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
// }

// ensure that blocked addresses are properly set in bank keeper
func TestBlockedAddrs(t *testing.T) {
Expand Down Expand Up @@ -99,66 +110,66 @@ func TestGetMaccPerms(t *testing.T) {
require.Equal(t, maccPerms, dup, "duplicated module account permissions differed from actual module account permissions")
}

func genesisStateWithValSet(t *testing.T,
app *ArchwayApp, genesisState GenesisState,
valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount,
balances ...banktypes.Balance,
) GenesisState {
t.Helper()
// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)

validators := make([]stakingtypes.Validator, 0, len(valSet.Validators))
delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators))

bondAmt := sdk.DefaultPowerReduction

for _, val := range valSet.Validators {
pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey)
require.NoError(t, err)
pkAny, err := codectypes.NewAnyWithValue(pk)
require.NoError(t, err)
validator := stakingtypes.Validator{
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: stakingtypes.Bonded,
Tokens: bondAmt,
DelegatorShares: math.LegacyOneDec(),
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()),
MinSelfDelegation: math.ZeroInt(),
}
validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), val.Address.String(), math.LegacyOneDec()))
}
// set validators and delegations
stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations)
genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis)

totalSupply := sdk.NewCoins()
for _, b := range balances {
// add genesis acc tokens to total supply
totalSupply = totalSupply.Add(b.Coins...)
}

for range delegations {
// add delegated tokens to total supply
totalSupply = totalSupply.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt))
}

// add bonded amount to bonded pool module account
balances = append(balances, banktypes.Balance{
Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
Coins: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)},
})

// update total supply
bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, banktypes.DefaultGenesisState().SendEnabled)
genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

return genesisState
}
// func genesisStateWithValSet(t *testing.T,
// app *ArchwayApp, genesisState GenesisState,
// valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount,
// balances ...banktypes.Balance,
// ) GenesisState {
// t.Helper()
// // set genesis accounts
// authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
// genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)

// validators := make([]stakingtypes.Validator, 0, len(valSet.Validators))
// delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators))

// bondAmt := sdk.DefaultPowerReduction

// for _, val := range valSet.Validators {
// pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey)
// require.NoError(t, err)
// pkAny, err := codectypes.NewAnyWithValue(pk)
// require.NoError(t, err)
// validator := stakingtypes.Validator{
// OperatorAddress: sdk.ValAddress(val.Address).String(),
// ConsensusPubkey: pkAny,
// Jailed: false,
// Status: stakingtypes.Bonded,
// Tokens: bondAmt,
// DelegatorShares: math.LegacyOneDec(),
// Description: stakingtypes.Description{},
// UnbondingHeight: int64(0),
// UnbondingTime: time.Unix(0, 0).UTC(),
// Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()),
// MinSelfDelegation: math.ZeroInt(),
// }
// validators = append(validators, validator)
// delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), math.LegacyOneDec()))
// }
// // set validators and delegations
// stakingGenesis := stakingtypes.NewGenesisState(stakingtypes.DefaultParams(), validators, delegations)
// genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGenesis)

// totalSupply := sdk.NewCoins()
// for _, b := range balances {
// // add genesis acc tokens to total supply
// totalSupply = totalSupply.Add(b.Coins...)
// }

// for range delegations {
// // add delegated tokens to total supply
// totalSupply = totalSupply.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt))
// }

// // add bonded amount to bonded pool module account
// balances = append(balances, banktypes.Balance{
// Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
// Coins: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)},
// })

// // update total supply
// bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}, banktypes.DefaultGenesisState().SendEnabled)
// genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis)

// return genesisState
// }
60 changes: 0 additions & 60 deletions app/app_upgrades_test.go

This file was deleted.

12 changes: 0 additions & 12 deletions app/app_upgrades_util_test.go

This file was deleted.

Loading

0 comments on commit 52234cb

Please sign in to comment.