-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
258 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
syntax = "proto3"; | ||
package dydxprotocol.affiliates; | ||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "dydxprotocol/affiliates/affiliates.proto"; | ||
|
||
option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types"; | ||
|
||
// GenesisState defines generis state of `x/affiliates` | ||
message GenesisState {} | ||
message GenesisState { | ||
// The list of affiliate tiers | ||
AffiliateTiers affiliate_tiers = 1 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package cli_test | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants" | ||
"github.com/dydxprotocol/v4-chain/protocol/testutil/network" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/affiliates/client/cli" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types" | ||
) | ||
|
||
// Prevent strconv unused error | ||
var _ = strconv.IntSize | ||
|
||
func setupNetwork(t *testing.T) (*network.Network, client.Context) { | ||
t.Helper() | ||
cfg := network.DefaultConfig(nil) | ||
|
||
// Init state. | ||
state := types.GenesisState{} | ||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) | ||
|
||
// Modify default genesis state | ||
state = *types.DefaultGenesis() | ||
|
||
// Add test affiliate tiers | ||
state.AffiliateTiers = types.DefaultAffiliateTiers | ||
|
||
buf, err := cfg.Codec.MarshalJSON(&state) | ||
require.NoError(t, err) | ||
cfg.GenesisState[types.ModuleName] = buf | ||
net := network.New(t, cfg) | ||
ctx := net.Validators[0].ClientCtx | ||
|
||
return net, ctx | ||
} | ||
|
||
func TestQueryAffiliateTiers(t *testing.T) { | ||
net, ctx := setupNetwork(t) | ||
|
||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryAffiliateTiers(), []string{}) | ||
require.NoError(t, err) | ||
|
||
var resp types.AllAffiliateTiersResponse | ||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) | ||
require.Equal(t, types.DefaultAffiliateTiers, resp.Tiers) | ||
} | ||
|
||
func TestQueryAffiliateInfo(t *testing.T) { | ||
net, ctx := setupNetwork(t) | ||
|
||
testAddress := constants.AliceAccAddress.String() | ||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryAffiliateInfo(), []string{testAddress}) | ||
require.NoError(t, err) | ||
|
||
var resp types.AffiliateInfoResponse | ||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) | ||
} | ||
|
||
func TestQueryReferredBy(t *testing.T) { | ||
net, ctx := setupNetwork(t) | ||
|
||
testAddress := constants.AliceAccAddress.String() | ||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryReferredBy(), []string{testAddress}) | ||
require.NoError(t, err) | ||
|
||
var resp types.ReferredByResponse | ||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.