Skip to content

Commit

Permalink
Avkr003/protocol revenue (#969)
Browse files Browse the repository at this point in the history
* fixing protocol revenue panic issue

* adding closing ratio to event

* changing default protocol-revenue-address

* optimizing end blocker

* Add asset profile genesis state to test cases

This commit updates various test cases to include the asset profile genesis state with a USDC entry. This ensures consistency across tests and prepares the state with necessary data for more comprehensive testing.

* Update x/masterchef/types/params.go

Co-authored-by: Amit Yadav <amy29981@gmail.com>

* fixing test cases and refactoring names

* fixing query pulsar

---------

Co-authored-by: Amit Yadav <amy29981@gmail.com>
Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent 001425f commit 922d67b
Show file tree
Hide file tree
Showing 33 changed files with 1,085 additions and 661 deletions.
775 changes: 387 additions & 388 deletions api/elys/assetprofile/query.pulsar.go

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions api/elys/assetprofile/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ require (
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid/v5 v5.0.0 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
Expand Down
16 changes: 7 additions & 9 deletions proto/elys/assetprofile/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ service Query {
}

// Queries a list of Entry items.
rpc Entry(QueryGetEntryRequest) returns (QueryGetEntryResponse) {
rpc Entry(QueryEntryRequest) returns (QueryEntryResponse) {
option (google.api.http).get =
"/elys-network/elys/assetprofile/entry/{base_denom}";
}
rpc EntryByDenom(QueryGetEntryByDenomRequest)
returns (QueryGetEntryByDenomResponse) {
rpc EntryByDenom(QueryEntryByDenomRequest)
returns (QueryEntryByDenomResponse) {
option (google.api.http).get =
"/elys-network/elys/assetprofile/entry/{denom}";
}
Expand All @@ -42,15 +42,13 @@ message QueryParamsResponse {
Params params = 1 [ (gogoproto.nullable) = false ];
}

message QueryGetEntryRequest { string base_denom = 1; }
message QueryEntryRequest { string base_denom = 1; }

message QueryGetEntryByDenomRequest { string denom = 1; }
message QueryEntryByDenomRequest { string denom = 1; }

message QueryGetEntryResponse {
Entry entry = 1 [ (gogoproto.nullable) = false ];
}
message QueryEntryResponse { Entry entry = 1 [ (gogoproto.nullable) = false ]; }

message QueryGetEntryByDenomResponse {
message QueryEntryByDenomResponse {
Entry entry = 1 [ (gogoproto.nullable) = false ];
}

Expand Down
28 changes: 28 additions & 0 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package network

import (
"fmt"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"
"testing"
"time"

Expand Down Expand Up @@ -41,6 +42,33 @@ func New(t *testing.T, configs ...network.Config) *network.Network {
} else {
cfg = configs[0]
}
assetProfileGenesisState := assetprofilemoduletypes.DefaultGenesis()
usdcEntry := assetprofilemoduletypes.Entry{
BaseDenom: "uusdc",
Decimals: 6,
Denom: "uusdc",
Path: "",
IbcChannelId: "",
IbcCounterpartyChannelId: "",
DisplayName: "",
DisplaySymbol: "",
Network: "",
Address: "",
ExternalSymbol: "",
TransferLimit: "",
Permissions: nil,
UnitDenom: "",
IbcCounterpartyDenom: "",
IbcCounterpartyChainId: "",
Authority: "",
CommitEnabled: true,
WithdrawEnabled: true,
}
assetProfileGenesisState.EntryList = []assetprofilemoduletypes.Entry{usdcEntry}
buf, err := cfg.Codec.MarshalJSON(assetProfileGenesisState)
require.NoError(t, err)
cfg.GenesisState[assetprofilemoduletypes.ModuleName] = buf

net, err := network.New(t, t.TempDir(), cfg)
require.NoError(t, err)
_, err = net.WaitForHeight(1)
Expand Down
28 changes: 28 additions & 0 deletions x/accountedpool/client/cli/query_accounted_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli_test

import (
"fmt"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"
"testing"

tmcli "github.com/cometbft/cometbft/libs/cli"
Expand Down Expand Up @@ -31,6 +32,33 @@ func networkWithAccountedPoolObjects(t *testing.T, n int) (*network.Network, []t
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf

assetProfileGenesisState := assetprofilemoduletypes.DefaultGenesis()
usdcEntry := assetprofilemoduletypes.Entry{
BaseDenom: "uusdc",
Decimals: 6,
Denom: "uusdc",
Path: "",
IbcChannelId: "",
IbcCounterpartyChannelId: "",
DisplayName: "",
DisplaySymbol: "",
Network: "",
Address: "",
ExternalSymbol: "",
TransferLimit: "",
Permissions: nil,
UnitDenom: "",
IbcCounterpartyDenom: "",
IbcCounterpartyChainId: "",
Authority: "",
CommitEnabled: true,
WithdrawEnabled: true,
}
assetProfileGenesisState.EntryList = []assetprofilemoduletypes.Entry{usdcEntry}
buf, err = cfg.Codec.MarshalJSON(assetProfileGenesisState)
require.NoError(t, err)
cfg.GenesisState[assetprofilemoduletypes.ModuleName] = buf
return network.New(t, cfg), state.AccountedPoolList
}

Expand Down
29 changes: 29 additions & 0 deletions x/amm/client/cli/query_denom_liquidity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli_test
import (
"cosmossdk.io/math"
"fmt"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"
"strconv"
"testing"

Expand Down Expand Up @@ -36,6 +37,34 @@ func networkWithDenomLiquidityObjects(t *testing.T, n int) (*network.Network, []
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf

assetProfileGenesisState := assetprofilemoduletypes.DefaultGenesis()
usdcEntry := assetprofilemoduletypes.Entry{
BaseDenom: "uusdc",
Decimals: 6,
Denom: "uusdc",
Path: "",
IbcChannelId: "",
IbcCounterpartyChannelId: "",
DisplayName: "",
DisplaySymbol: "",
Network: "",
Address: "",
ExternalSymbol: "",
TransferLimit: "",
Permissions: nil,
UnitDenom: "",
IbcCounterpartyDenom: "",
IbcCounterpartyChainId: "",
Authority: "",
CommitEnabled: true,
WithdrawEnabled: true,
}
assetProfileGenesisState.EntryList = []assetprofilemoduletypes.Entry{usdcEntry}
buf, err = cfg.Codec.MarshalJSON(assetProfileGenesisState)
require.NoError(t, err)
cfg.GenesisState[assetprofilemoduletypes.ModuleName] = buf

return network.New(t, cfg), state.DenomLiquidityList
}

Expand Down
29 changes: 29 additions & 0 deletions x/amm/client/cli/query_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli_test
import (
sdkmath "cosmossdk.io/math"
"fmt"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"
"strconv"
"testing"

Expand Down Expand Up @@ -49,6 +50,34 @@ func networkWithPoolObjects(t *testing.T, n int) (*network.Network, []types.Pool
buf, err := cfg.Codec.MarshalJSON(&state)
require.NoError(t, err)
cfg.GenesisState[types.ModuleName] = buf

assetProfileGenesisState := assetprofilemoduletypes.DefaultGenesis()
usdcEntry := assetprofilemoduletypes.Entry{
BaseDenom: "uusdc",
Decimals: 6,
Denom: "uusdc",
Path: "",
IbcChannelId: "",
IbcCounterpartyChannelId: "",
DisplayName: "",
DisplaySymbol: "",
Network: "",
Address: "",
ExternalSymbol: "",
TransferLimit: "",
Permissions: nil,
UnitDenom: "",
IbcCounterpartyDenom: "",
IbcCounterpartyChainId: "",
Authority: "",
CommitEnabled: true,
WithdrawEnabled: true,
}
assetProfileGenesisState.EntryList = []assetprofilemoduletypes.Entry{usdcEntry}
buf, err = cfg.Codec.MarshalJSON(assetProfileGenesisState)
require.NoError(t, err)
cfg.GenesisState[assetprofilemoduletypes.ModuleName] = buf

return network.New(t, cfg), state.PoolList
}

Expand Down
39 changes: 39 additions & 0 deletions x/assetprofile/client/cli/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cli_test

import (
"io"
"testing"

rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock"
"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/bank"
)

type CLITestSuite struct {
suite.Suite

kr keyring.Keyring
encCfg testutilmod.TestEncodingConfig
baseCtx client.Context
}

func TestMigrateTestSuite(t *testing.T) {
suite.Run(t, new(CLITestSuite))
}

func (s *CLITestSuite) SetupSuite() {
s.encCfg = testutilmod.MakeTestEncodingConfig(bank.AppModuleBasic{})
s.kr = keyring.NewInMemory(s.encCfg.Codec)
s.baseCtx = client.Context{}.
WithKeyring(s.kr).
WithTxConfig(s.encCfg.TxConfig).
WithCodec(s.encCfg.Codec).
WithClient(clitestutil.MockCometRPC{Client: rpcclientmock.Client{}}).
WithAccountRetriever(client.MockAccountRetriever{}).
WithOutput(io.Discard)
}
8 changes: 4 additions & 4 deletions x/assetprofile/keeper/query_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (k Keeper) EntryAll(goCtx context.Context, req *types.QueryAllEntryRequest)
return &types.QueryAllEntryResponse{Entry: entrys, Pagination: pageRes}, nil
}

func (k Keeper) Entry(goCtx context.Context, req *types.QueryGetEntryRequest) (*types.QueryGetEntryResponse, error) {
func (k Keeper) Entry(goCtx context.Context, req *types.QueryEntryRequest) (*types.QueryEntryResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
Expand All @@ -50,10 +50,10 @@ func (k Keeper) Entry(goCtx context.Context, req *types.QueryGetEntryRequest) (*
return nil, status.Error(codes.NotFound, "not found")
}

return &types.QueryGetEntryResponse{Entry: val}, nil
return &types.QueryEntryResponse{Entry: val}, nil
}

func (k Keeper) EntryByDenom(goCtx context.Context, req *types.QueryGetEntryByDenomRequest) (*types.QueryGetEntryByDenomResponse, error) {
func (k Keeper) EntryByDenom(goCtx context.Context, req *types.QueryEntryByDenomRequest) (*types.QueryEntryByDenomResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
Expand All @@ -64,5 +64,5 @@ func (k Keeper) EntryByDenom(goCtx context.Context, req *types.QueryGetEntryByDe
return nil, status.Error(codes.NotFound, "not found")
}

return &types.QueryGetEntryByDenomResponse{Entry: val}, nil
return &types.QueryEntryByDenomResponse{Entry: val}, nil
}
Loading

0 comments on commit 922d67b

Please sign in to comment.