mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-20 21:16:37 +00:00

* adjust issuePoPRewards to mint stagedCRDDL * add GetChallengeRange * add resolveStagedClaims on ReissueRDDLResult msg * move claim resolve to distribution result * add StagedDenom and ClaimDenom to config * added the prepare4linting.sh script * renamed PoPEpochs to PopEpochs * renamed DistributionAddressPoP to DistributionAddressPop * added config value ReIssuanceEpochs * detached the re-issuance from the distribution process and schedule them independently * changed logging messages * added an explicit util/kv_serialize.go file to have all KV serialization done * switched to Bigendian serialization of int64 to have the ordered list on the kvstore * added ComputeReIssuanceValue to enable re-issuances once a day or defined by ReIssuanceEpoch * integrated a ReIssuanceValue computation test case * adjusted the challenges test cases to be epoch-dependent * added ReIssuances per ReIssuanceEpoch * extended the Reissue message * checking ReIssuanceProposal in the ante handler * added precision setter for the UINT to RDDL token converter (and test cases) * add e2e test case for pop rewards Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com>
81 lines
2.6 KiB
Go
81 lines
2.6 KiB
Go
package keeper
|
|
|
|
import (
|
|
"testing"
|
|
|
|
tmdb "github.com/cometbft/cometbft-db"
|
|
"github.com/cometbft/cometbft/libs/log"
|
|
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
"github.com/cosmos/cosmos-sdk/store"
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
"github.com/golang/mock/gomock"
|
|
"github.com/planetmint/planetmint-go/x/dao/keeper"
|
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
daotestutil "github.com/planetmint/planetmint-go/x/dao/testutil"
|
|
)
|
|
|
|
func DaoKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
|
storeKey := sdk.NewKVStoreKey(types.StoreKey)
|
|
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
|
|
challengeStoreKey := storetypes.NewMemoryStoreKey(types.ChallengeKey)
|
|
mintRequestHashStoreKey := storetypes.NewMemoryStoreKey(types.MintRequestHashKey)
|
|
mintRequestAddressStoreKey := storetypes.NewMemoryStoreKey(types.MintRequestAddressKey)
|
|
|
|
db := tmdb.NewMemDB()
|
|
stateStore := store.NewCommitMultiStore(db)
|
|
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db)
|
|
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
|
|
stateStore.MountStoreWithDB(challengeStoreKey, storetypes.StoreTypeIAVL, db)
|
|
stateStore.MountStoreWithDB(mintRequestHashStoreKey, storetypes.StoreTypeIAVL, db)
|
|
stateStore.MountStoreWithDB(mintRequestAddressStoreKey, storetypes.StoreTypeIAVL, db)
|
|
|
|
require.NoError(t, stateStore.LoadLatestVersion())
|
|
|
|
registry := codectypes.NewInterfaceRegistry()
|
|
cdc := codec.NewProtoCodec(registry)
|
|
|
|
paramsSubspace := typesparams.NewSubspace(cdc,
|
|
types.Amino,
|
|
storeKey,
|
|
memStoreKey,
|
|
"DaoParams",
|
|
)
|
|
|
|
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())
|
|
|
|
ctrl := gomock.NewController(t)
|
|
bk := daotestutil.NewMockBankKeeper(ctrl)
|
|
|
|
bk.EXPECT().MintCoins(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
|
bk.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
|
|
|
k := keeper.NewKeeper(
|
|
cdc,
|
|
storeKey,
|
|
memStoreKey,
|
|
challengeStoreKey,
|
|
mintRequestHashStoreKey,
|
|
mintRequestAddressStoreKey,
|
|
paramsSubspace,
|
|
bk,
|
|
nil,
|
|
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
|
)
|
|
|
|
// Initialize params
|
|
err := k.SetParams(ctx, types.DefaultParams())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return k, ctx
|
|
}
|