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

Fix unit tests and more SDK v0.47 upgrade changes #304

Merged
merged 6 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

"github.com/cosmos/cosmos-sdk/runtime"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
Expand All @@ -20,6 +22,7 @@
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -744,6 +747,14 @@
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))

reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)
Comment on lines +751 to +755
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider handling the error without panicking, perhaps by logging the error and continuing with a degraded service mode if possible.

- panic(err)
+ log.Errorf("Failed to create reflection service: %v", err)
+ // Continue with degraded service mode or other error handling strategy

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)
reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
log.Errorf("Failed to create reflection service: %v", err)
// Continue with degraded service mode or other error handling strategy
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)


// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
Expand Down Expand Up @@ -966,7 +977,7 @@
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())

Check failure on line 980 in app/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA1019: govtypesv1.ParamKeyTable is deprecated: ParamKeyTable - Key declaration for parameters (staticcheck)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(icaexported.ModuleName)
Expand Down
6 changes: 3 additions & 3 deletions x/auction/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"os"
"testing"

"github.com/cosmos/cosmos-sdk/testutil"
"github.com/peggyjv/sommelier/v7/x/auction/types"

"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/stretchr/testify/require"
)

func TestParseSetTokenPricesProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand All @@ -33,7 +33,7 @@ func TestParseSetTokenPricesProposal(t *testing.T) {

require.Equal(t, "My token proposal", proposal.Title)
require.Equal(t, "Contains a usomm price update", proposal.Description)
require.Equal(t, "denom:\"usomm\" exponent:\"6\" usd_price:\"4200000000000000000\" ", proposal.TokenPrices[0].String())
require.Equal(t, "denom:\"usomm\" exponent:6 usd_price:\"4200000000000000000\" ", proposal.TokenPrices[0].String())
require.Equal(t, "10000usomm", proposal.Deposit)
}

Expand Down
17 changes: 9 additions & 8 deletions x/axelarcork/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"github.com/peggyjv/sommelier/v7/x/axelarcork/types"

"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/stretchr/testify/require"
)

func TestParseAddManagedCellarsProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -42,7 +43,7 @@ func TestParseAddManagedCellarsProposal(t *testing.T) {
}

func TestParseRemoveManagedCellarsProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestParseRemoveManagedCellarsProposal(t *testing.T) {
}

func TestParseSubmitScheduledCorkProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -103,7 +104,7 @@ func TestParseSubmitScheduledCorkProposal(t *testing.T) {
}

func TestParseAxelarCommunityPoolSpendProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -132,7 +133,7 @@ func TestParseAxelarCommunityPoolSpendProposal(t *testing.T) {
}

func TestParseAddChainConfigurationProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -171,7 +172,7 @@ func TestParseAddChainConfigurationProposal(t *testing.T) {
}

func TestParseRemoveChainConfigurationProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand All @@ -196,7 +197,7 @@ func TestParseRemoveChainConfigurationProposal(t *testing.T) {
}

func TestParseUpgradeAxelarProxyContractProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand All @@ -223,7 +224,7 @@ func TestParseUpgradeAxelarProxyContractProposal(t *testing.T) {
}

func TestParseCancelAxelarProxyContractUpgradeProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down
7 changes: 4 additions & 3 deletions x/cork/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
types "github.com/peggyjv/sommelier/v7/x/cork/types/v2"

"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/stretchr/testify/require"
)

func TestParseAddManagedCellarsProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down Expand Up @@ -39,7 +40,7 @@ func TestParseAddManagedCellarsProposal(t *testing.T) {
}

func TestParseRemoveManagedCellarsProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand All @@ -65,7 +66,7 @@ func TestParseRemoveManagedCellarsProposal(t *testing.T) {
}

func TestParseSubmitScheduledCorkProposal(t *testing.T) {
encodingConfig := testutil.TestEncodingConfig()
encodingConfig := moduletestutil.MakeTestEncodingConfig()

okJSON := testutil.WriteToNewTempFile(t, `
{
Expand Down
Loading