diff --git a/app/sim_bench_test.go b/app/sim_bench_test.go index 08beffd0..25d76577 100644 --- a/app/sim_bench_test.go +++ b/app/sim_bench_test.go @@ -15,6 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ignite/network/app" + networktypes "github.com/ignite/network/pkg/types" ) // Profile with: @@ -45,7 +46,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { bApp, err := app.New(logger, db, nil, true, appOptions, interBlockCacheOpt()) require.NoError(b, err) - require.Equal(b, app.Name, bApp.Name()) + require.Equal(b, networktypes.Name, bApp.Name()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -102,7 +103,7 @@ func BenchmarkInvariants(b *testing.B) { bApp, err := app.New(logger, db, nil, true, appOptions, interBlockCacheOpt()) require.NoError(b, err) - require.Equal(b, app.Name, bApp.Name()) + require.Equal(b, networktypes.Name, bApp.Name()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/app/sim_test.go b/app/sim_test.go index 1c65c607..3ff043ba 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -32,6 +32,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ignite/network/app" + networktypes "github.com/ignite/network/pkg/types" ) const ( @@ -89,7 +90,7 @@ func BenchmarkSimulation(b *testing.B) { bApp, err := app.New(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.NoError(b, err) - require.Equal(b, app.Name, bApp.Name()) + require.Equal(b, networktypes.Name, bApp.Name()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -135,7 +136,7 @@ func TestAppImportExport(t *testing.T) { bApp, err := app.New(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.NoError(t, err) - require.Equal(t, app.Name, bApp.Name()) + require.Equal(t, networktypes.Name, bApp.Name()) // Run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -176,7 +177,7 @@ func TestAppImportExport(t *testing.T) { newApp, err := app.New(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.NoError(t, err) - require.Equal(t, app.Name, newApp.Name()) + require.Equal(t, networktypes.Name, newApp.Name()) var genesisState app.GenesisState err = json.Unmarshal(exported.AppState, &genesisState) @@ -254,7 +255,7 @@ func TestAppSimulationAfterImport(t *testing.T) { bApp, err := app.New(logger, db, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.NoError(t, err) - require.Equal(t, app.Name, bApp.Name()) + require.Equal(t, networktypes.Name, bApp.Name()) // Run randomized simulation stopEarly, simParams, simErr := simulation.SimulateFromSeed( @@ -300,7 +301,7 @@ func TestAppSimulationAfterImport(t *testing.T) { newApp, err := app.New(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.NoError(t, err) - require.Equal(t, app.Name, newApp.Name()) + require.Equal(t, networktypes.Name, newApp.Name()) _, err = newApp.InitChain(&abci.RequestInitChain{ AppStateBytes: exported.AppState, diff --git a/x/launch/keeper/query_genesis_account.go b/x/launch/keeper/query_genesis_account.go index 120b0be0..314437f0 100644 --- a/x/launch/keeper/query_genesis_account.go +++ b/x/launch/keeper/query_genesis_account.go @@ -43,7 +43,7 @@ func (q queryServer) GetGenesisAccount(ctx context.Context, req *types.QueryGetG address, err := q.k.addressCodec.StringToBytes(req.Address) if err != nil { - return nil, status.Error(codes.Internal, "internal error") + return nil, status.Error(codes.InvalidArgument, "invalid address") } val, err := q.k.GenesisAccount.Get(ctx, collections.Join(req.LaunchID, sdk.AccAddress(address))) diff --git a/x/launch/keeper/query_genesis_validator.go b/x/launch/keeper/query_genesis_validator.go index a283fecd..dca73e4b 100644 --- a/x/launch/keeper/query_genesis_validator.go +++ b/x/launch/keeper/query_genesis_validator.go @@ -43,7 +43,7 @@ func (q queryServer) GetGenesisValidator(ctx context.Context, req *types.QueryGe address, err := q.k.addressCodec.StringToBytes(req.Address) if err != nil { - return nil, status.Error(codes.Internal, "internal error") + return nil, status.Error(codes.InvalidArgument, "invalid address") } val, err := q.k.GenesisValidator.Get(ctx, collections.Join(req.LaunchID, sdk.AccAddress(address))) diff --git a/x/launch/keeper/query_vesting_account.go b/x/launch/keeper/query_vesting_account.go index 0ab47e9f..760ea861 100644 --- a/x/launch/keeper/query_vesting_account.go +++ b/x/launch/keeper/query_vesting_account.go @@ -43,7 +43,7 @@ func (q queryServer) GetVestingAccount(ctx context.Context, req *types.QueryGetV address, err := q.k.addressCodec.StringToBytes(req.Address) if err != nil { - return nil, status.Error(codes.Internal, "internal error") + return nil, status.Error(codes.InvalidArgument, "invalid address") } val, err := q.k.VestingAccount.Get(ctx, collections.Join(req.LaunchID, sdk.AccAddress(address))) diff --git a/x/participation/keeper/msg_update_params_test.go b/x/participation/keeper/msg_update_params_test.go index ee8308bf..4f592dff 100644 --- a/x/participation/keeper/msg_update_params_test.go +++ b/x/participation/keeper/msg_update_params_test.go @@ -37,7 +37,11 @@ func TestMsgUpdateParams(t *testing.T) { name: "send enabled param", input: &types.MsgUpdateParams{ Authority: k.GetAuthority(), - Params: types.Params{}, + Params: types.Params{ + AllocationPrice: types.DefaultAllocationPrice, + RegistrationPeriod: types.DefaultRegistrationPeriod, + WithdrawalDelay: types.DefaultWithdrawalDelay, + }, }, expErr: false, }, diff --git a/x/participation/keeper/query_auction_used_allocations.go b/x/participation/keeper/query_auction_used_allocations.go index 96167e3c..433713a5 100644 --- a/x/participation/keeper/query_auction_used_allocations.go +++ b/x/participation/keeper/query_auction_used_allocations.go @@ -43,7 +43,7 @@ func (q queryServer) GetAuctionUsedAllocations(ctx context.Context, req *types.Q address, err := q.k.addressCodec.StringToBytes(req.Address) if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") + return nil, status.Error(codes.InvalidArgument, "invalid address") } val, err := q.k.AuctionUsedAllocations.Get(ctx, collections.Join(sdk.AccAddress(address), req.AuctionID)) diff --git a/x/participation/keeper/query_auction_used_allocations_test.go b/x/participation/keeper/query_auction_used_allocations_test.go index aa7e3666..968b1293 100644 --- a/x/participation/keeper/query_auction_used_allocations_test.go +++ b/x/participation/keeper/query_auction_used_allocations_test.go @@ -20,9 +20,9 @@ import ( func createNAuctionUsedAllocations(keeper keeper.Keeper, ctx context.Context, n int) []types.AuctionUsedAllocations { items := make([]types.AuctionUsedAllocations, n) + auctionID := uint64(0) for i := range items { address := sample.AccAddress(r) - auctionID := uint64(i) items[i].Address = address.String() items[i].AuctionID = auctionID items[i].NumAllocations = sample.Int(r) @@ -45,24 +45,35 @@ func TestAuctionUsedAllocationsQuerySingle(t *testing.T) { { desc: "First", request: &types.QueryGetAuctionUsedAllocationsRequest{ - Address: msgs[0].Address, + AuctionID: msgs[0].AuctionID, + Address: msgs[0].Address, }, response: &types.QueryGetAuctionUsedAllocationsResponse{AuctionUsedAllocations: msgs[0]}, }, { desc: "Second", request: &types.QueryGetAuctionUsedAllocationsRequest{ - Address: msgs[1].Address, + AuctionID: msgs[1].AuctionID, + Address: msgs[1].Address, }, response: &types.QueryGetAuctionUsedAllocationsResponse{AuctionUsedAllocations: msgs[1]}, }, { desc: "KeyNotFound", request: &types.QueryGetAuctionUsedAllocationsRequest{ - Address: strconv.Itoa(100000), + AuctionID: 100, + Address: sample.Address(r), }, err: status.Error(codes.NotFound, "not found"), }, + { + desc: "InvalidAddress", + request: &types.QueryGetAuctionUsedAllocationsRequest{ + AuctionID: 100, + Address: strconv.Itoa(100000), + }, + err: status.Error(codes.InvalidArgument, "invalid address"), + }, { desc: "InvalidRequest", err: status.Error(codes.InvalidArgument, "invalid request"), diff --git a/x/participation/keeper/query_used_allocations_test.go b/x/participation/keeper/query_used_allocations_test.go index 7e249e8c..6325f95b 100644 --- a/x/participation/keeper/query_used_allocations_test.go +++ b/x/participation/keeper/query_used_allocations_test.go @@ -12,6 +12,7 @@ import ( keepertest "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/nullify" + "github.com/ignite/network/testutil/sample" "github.com/ignite/network/x/participation/keeper" "github.com/ignite/network/x/participation/types" ) @@ -20,6 +21,7 @@ func createNUsedAllocations(keeper keeper.Keeper, ctx context.Context, n int) [] items := make([]types.UsedAllocations, n) for i := range items { items[i].Address = strconv.Itoa(i) + items[i].NumAllocations = sample.Int(r) _ = keeper.UsedAllocations.Set(ctx, items[i].Address, items[i]) } diff --git a/x/profile/keeper/query_coordinator.go b/x/profile/keeper/query_coordinator.go index 4add4dc1..9661e96b 100644 --- a/x/profile/keeper/query_coordinator.go +++ b/x/profile/keeper/query_coordinator.go @@ -57,7 +57,7 @@ func (q queryServer) GetCoordinatorByAddress(ctx context.Context, req *types.Que address, err := q.k.addressCodec.StringToBytes(req.Address) if err != nil { - return nil, status.Error(codes.Internal, "internal error") + return nil, status.Error(codes.InvalidArgument, "invalid address") } coordinatorByAddress, err := q.k.CoordinatorByAddress.Get(ctx, address)