Skip to content

Commit

Permalink
Merge branch 'main' into cal/clean-up-votes
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Dec 1, 2023
2 parents 874aaa0 + 95bda40 commit a8d6e84
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
go.sum
- uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.55.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ If you'd rather not install from source, you can download a pre-built binary fro
<details>
<summary>
Optional: Verify the pre-built binary checksums and signatures
Optional: Verify the pre-built binary checksums and signatures
</summary>
If you use a pre-built binary, you may also want to verify the checksums and signatures.
Expand Down Expand Up @@ -99,6 +99,7 @@ If you use a pre-built binary, you may also want to verify the checksums and sig
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: BF02 F32C C368 6456 0B90 B764 D469 F859 693D C3FA
```
</details>
### Ledger Support
Expand Down Expand Up @@ -146,7 +147,7 @@ This repo attempts to conform to [conventional commits](https://www.conventional
### Tools
1. Install [golangci-lint](https://golangci-lint.run/usage/install/)
1. Install [golangci-lint](https://golangci-lint.run/usage/install/) 1.55.2
1. Install [markdownlint](https://github.com/DavidAnson/markdownlint)
1. Install [hadolint](https://github.com/hadolint/hadolint)
1. Install [yamllint](https://yamllint.readthedocs.io/en/stable/quickstart.html)
Expand Down
3 changes: 0 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
53 changes: 0 additions & 53 deletions test/util/keeper/blob.go

This file was deleted.

44 changes: 3 additions & 41 deletions x/blob/keeper/gas_test.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions x/blob/genesis_test.go → x/blob/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions x/blob/keeper/grpc_query_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions x/blob/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand All @@ -36,8 +31,6 @@ func NewKeeper(

return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
paramStore: ps,
}
}
Expand Down
49 changes: 46 additions & 3 deletions x/blob/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper
package keeper_test

import (
"bytes"
Expand All @@ -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()}
Expand Down Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions x/blob/keeper/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a8d6e84

Please sign in to comment.