diff --git a/app/app.go b/app/app.go index 1676818832..b8c68384b8 100644 --- a/app/app.go +++ b/app/app.go @@ -272,7 +272,6 @@ func New( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, - blobmoduletypes.StoreKey, bsmoduletypes.StoreKey, ibctransfertypes.StoreKey, ibchost.StoreKey, @@ -402,8 +401,6 @@ func New( app.BlobKeeper = *blobmodulekeeper.NewKeeper( appCodec, - keys[blobmoduletypes.StoreKey], - keys[blobmoduletypes.MemStoreKey], app.GetSubspace(blobmoduletypes.ModuleName), ) blobmod := blobmodule.NewAppModule(appCodec, app.BlobKeeper) diff --git a/test/util/keeper/blob.go b/test/util/keeper/blob.go deleted file mode 100644 index 40b7b791a9..0000000000 --- a/test/util/keeper/blob.go +++ /dev/null @@ -1,53 +0,0 @@ -package keeper - -import ( - "testing" - - testutil "github.com/celestiaorg/celestia-app/test/util" - "github.com/celestiaorg/celestia-app/x/blob/keeper" - "github.com/celestiaorg/celestia-app/x/blob/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" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmdb "github.com/tendermint/tm-db" -) - -func BlobKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { - storeKey := sdk.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - - db := tmdb.NewMemDB() - stateStore := store.NewCommitMultiStore(db) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - registry := codectypes.NewInterfaceRegistry() - cdc := codec.NewProtoCodec(registry) - - paramsSubspace := typesparams.NewSubspace(cdc, - testutil.MakeTestCodec(), - storeKey, - memStoreKey, - "Blob", - ) - k := keeper.NewKeeper( - cdc, - storeKey, - memStoreKey, - paramsSubspace, - ) - - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - - // Initialize params - k.SetParams(ctx, types.DefaultParams()) - - return k, ctx -} diff --git a/x/blob/keeper/gas_test.go b/x/blob/keeper/gas_test.go index ee4df5760a..90c9593bda 100644 --- a/x/blob/keeper/gas_test.go +++ b/x/blob/keeper/gas_test.go @@ -1,53 +1,15 @@ -package keeper +package keeper_test import ( "testing" "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/x/blob/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" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmdb "github.com/tendermint/tm-db" ) -func keeper(t *testing.T) (*Keeper, store.CommitMultiStore) { - storeKey := sdk.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - - db := tmdb.NewMemDB() - stateStore := store.NewCommitMultiStore(db) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - registry := codectypes.NewInterfaceRegistry() - cdc := codec.NewProtoCodec(registry) - tempCtx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) - - aminoCdc := codec.NewLegacyAmino() - paramsSubspace := typesparams.NewSubspace(cdc, - aminoCdc, - storeKey, - memStoreKey, - "Blob", - ) - k := NewKeeper( - cdc, - storeKey, - memStoreKey, - paramsSubspace, - ) - k.SetParams(tempCtx, types.DefaultParams()) - - return k, stateStore -} - func TestPayForBlobGas(t *testing.T) { type testCase struct { name string @@ -87,7 +49,7 @@ func TestPayForBlobGas(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - k, stateStore := keeper(t) + k, stateStore, _ := CreateKeeper(t) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) _, err := k.PayForBlobs(sdk.WrapSDKContext(ctx), &tc.msg) require.NoError(t, err) @@ -100,7 +62,7 @@ func TestPayForBlobGas(t *testing.T) { func TestChangingGasParam(t *testing.T) { msg := types.MsgPayForBlobs{BlobSizes: []uint32{1024}} - k, stateStore := keeper(t) + k, stateStore, _ := CreateKeeper(t) tempCtx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) ctx1 := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) diff --git a/x/blob/genesis_test.go b/x/blob/keeper/genesis_test.go similarity index 77% rename from x/blob/genesis_test.go rename to x/blob/keeper/genesis_test.go index c21ebfba20..5dc450c55e 100644 --- a/x/blob/genesis_test.go +++ b/x/blob/keeper/genesis_test.go @@ -1,9 +1,8 @@ -package blob_test +package keeper_test import ( "testing" - keepertest "github.com/celestiaorg/celestia-app/test/util/keeper" "github.com/celestiaorg/celestia-app/x/blob" "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/stretchr/testify/require" @@ -14,7 +13,7 @@ func TestGenesis(t *testing.T) { Params: types.DefaultParams(), } - k, ctx := keepertest.BlobKeeper(t) + k, _, ctx := CreateKeeper(t) blob.InitGenesis(ctx, *k, genesisState) got := blob.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/blob/keeper/grpc_query_params_test.go b/x/blob/keeper/grpc_query_params_test.go index 2fa47a714c..3398c8ecae 100644 --- a/x/blob/keeper/grpc_query_params_test.go +++ b/x/blob/keeper/grpc_query_params_test.go @@ -3,14 +3,13 @@ package keeper_test import ( "testing" - testkeeper "github.com/celestiaorg/celestia-app/test/util/keeper" "github.com/celestiaorg/celestia-app/x/blob/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.BlobKeeper(t) + keeper, _, ctx := CreateKeeper(t) wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, params) diff --git a/x/blob/keeper/keeper.go b/x/blob/keeper/keeper.go index 5111bd70ae..bb69acfd29 100644 --- a/x/blob/keeper/keeper.go +++ b/x/blob/keeper/keeper.go @@ -6,7 +6,6 @@ import ( "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" @@ -19,15 +18,11 @@ const ( // Keeper handles all the state changes for the blob module. type Keeper struct { cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey paramStore paramtypes.Subspace } func NewKeeper( cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, ps paramtypes.Subspace, ) *Keeper { if !ps.HasKeyTable() { @@ -36,8 +31,6 @@ func NewKeeper( return &Keeper{ cdc: cdc, - storeKey: storeKey, - memKey: memKey, paramStore: ps, } } diff --git a/x/blob/keeper/keeper_test.go b/x/blob/keeper/keeper_test.go index 44dcc4a0cb..abe48a2ce0 100644 --- a/x/blob/keeper/keeper_test.go +++ b/x/blob/keeper/keeper_test.go @@ -1,4 +1,4 @@ -package keeper +package keeper_test import ( "bytes" @@ -8,18 +8,27 @@ import ( "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/pkg/blob" appns "github.com/celestiaorg/celestia-app/pkg/namespace" + testutil "github.com/celestiaorg/celestia-app/test/util" + "github.com/celestiaorg/celestia-app/x/blob/keeper" "github.com/celestiaorg/celestia-app/x/blob/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" proto "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + tmversion "github.com/tendermint/tendermint/proto/tendermint/version" + tmdb "github.com/tendermint/tm-db" ) // TestPayForBlobs verifies the attributes on the emitted event. func TestPayForBlobs(t *testing.T) { - k, stateStore := keeper(t) - ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) + k, _, ctx := CreateKeeper(t) signer := "celestia15drmhzw5kwgenvemy30rqqqgq52axf5wwrruf7" namespace := appns.MustNewV0(bytes.Repeat([]byte{1}, appns.NamespaceVersionZeroIDSize)) namespaces := [][]byte{namespace.Bytes()} @@ -62,3 +71,37 @@ func createMsgPayForBlob(t *testing.T, signer string, namespace appns.Namespace, require.NoError(t, err) return msg } + +func CreateKeeper(t *testing.T) (*keeper.Keeper, store.CommitMultiStore, sdk.Context) { + storeKey := sdk.NewKVStoreKey(paramtypes.StoreKey) + tStoreKey := storetypes.NewTransientStoreKey(paramtypes.TStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(tStoreKey, storetypes.StoreTypeTransient, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + ctx := sdk.NewContext(stateStore, tmproto.Header{ + Version: tmversion.Consensus{ + Block: 1, + App: 1, + }, + }, false, nil) + + paramsSubspace := paramtypes.NewSubspace(cdc, + testutil.MakeTestCodec(), + storeKey, + tStoreKey, + types.ModuleName, + ) + k := keeper.NewKeeper( + cdc, + paramsSubspace, + ) + k.SetParams(ctx, types.DefaultParams()) + + return k, stateStore, ctx +} diff --git a/x/blob/keeper/params_test.go b/x/blob/keeper/params_test.go index 01abbbbec5..95a533d880 100644 --- a/x/blob/keeper/params_test.go +++ b/x/blob/keeper/params_test.go @@ -3,13 +3,12 @@ package keeper_test import ( "testing" - testkeeper "github.com/celestiaorg/celestia-app/test/util/keeper" "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { - k, ctx := testkeeper.BlobKeeper(t) + k, _, ctx := CreateKeeper(t) params := types.DefaultParams() k.SetParams(ctx, params)