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

[OTE-730] Add E2E tests for revshare #2283

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { MarketMapperRevenueShareParams, MarketMapperRevenueShareParamsSDKType } from "./params";
import { UnconditionalRevShareConfig, UnconditionalRevShareConfigSDKType } from "./revshare";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisState {
/** params is the market mapper revenue share params. */
params?: MarketMapperRevenueShareParams;
/** unconditional_rev_share_config is the unconditional rev share config. */

unconditionalRevShareConfig?: UnconditionalRevShareConfig;
}
/** GenesisState defines `x/revshare`'s genesis state. */

export interface GenesisStateSDKType {
/** params is the market mapper revenue share params. */
params?: MarketMapperRevenueShareParamsSDKType;
/** unconditional_rev_share_config is the unconditional rev share config. */

unconditional_rev_share_config?: UnconditionalRevShareConfigSDKType;
}

function createBaseGenesisState(): GenesisState {
return {
params: undefined
params: undefined,
unconditionalRevShareConfig: undefined
};
}

Expand All @@ -24,6 +34,10 @@ export const GenesisState = {
MarketMapperRevenueShareParams.encode(message.params, writer.uint32(10).fork()).ldelim();
}

if (message.unconditionalRevShareConfig !== undefined) {
UnconditionalRevShareConfig.encode(message.unconditionalRevShareConfig, writer.uint32(18).fork()).ldelim();
}

return writer;
},

Expand All @@ -40,6 +54,10 @@ export const GenesisState = {
message.params = MarketMapperRevenueShareParams.decode(reader, reader.uint32());
break;

case 2:
message.unconditionalRevShareConfig = UnconditionalRevShareConfig.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -52,6 +70,7 @@ export const GenesisState = {
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? MarketMapperRevenueShareParams.fromPartial(object.params) : undefined;
message.unconditionalRevShareConfig = object.unconditionalRevShareConfig !== undefined && object.unconditionalRevShareConfig !== null ? UnconditionalRevShareConfig.fromPartial(object.unconditionalRevShareConfig) : undefined;
return message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
import { Params, ParamsSDKType } from "./params";
import { UserStats, UserStatsSDKType } from "./stats";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines the stats module's genesis state. */

export interface GenesisState {
/** The parameters of the module. */
params?: Params;
addressToUserStats: AddressToUserStats[];
}
/** GenesisState defines the stats module's genesis state. */

export interface GenesisStateSDKType {
/** The parameters of the module. */
params?: ParamsSDKType;
address_to_user_stats: AddressToUserStatsSDKType[];
}
/** AddressToUserStats is a struct that contains the user stats for an address. */

export interface AddressToUserStats {
/** The address of the user. */
address: string;
/** The user stats for the address. */

userStats?: UserStats;
}
/** AddressToUserStats is a struct that contains the user stats for an address. */

export interface AddressToUserStatsSDKType {
/** The address of the user. */
address: string;
/** The user stats for the address. */

user_stats?: UserStatsSDKType;
}

function createBaseGenesisState(): GenesisState {
return {
params: undefined
params: undefined,
addressToUserStats: []
};
}

Expand All @@ -26,6 +48,10 @@ export const GenesisState = {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}

for (const v of message.addressToUserStats) {
AddressToUserStats.encode(v!, writer.uint32(18).fork()).ldelim();
}

return writer;
},

Expand All @@ -42,6 +68,10 @@ export const GenesisState = {
message.params = Params.decode(reader, reader.uint32());
break;

case 2:
message.addressToUserStats.push(AddressToUserStats.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -54,6 +84,62 @@ export const GenesisState = {
fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
message.addressToUserStats = object.addressToUserStats?.map(e => AddressToUserStats.fromPartial(e)) || [];
return message;
}

};

function createBaseAddressToUserStats(): AddressToUserStats {
return {
address: "",
userStats: undefined
};
}

export const AddressToUserStats = {
encode(message: AddressToUserStats, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.address !== "") {
writer.uint32(10).string(message.address);
}

if (message.userStats !== undefined) {
UserStats.encode(message.userStats, writer.uint32(18).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): AddressToUserStats {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAddressToUserStats();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.address = reader.string();
break;

case 2:
message.userStats = UserStats.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<AddressToUserStats>): AddressToUserStats {
const message = createBaseAddressToUserStats();
message.address = object.address ?? "";
message.userStats = object.userStats !== undefined && object.userStats !== null ? UserStats.fromPartial(object.userStats) : undefined;
return message;
}

Expand Down
4 changes: 4 additions & 0 deletions proto/dydxprotocol/revshare/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package dydxprotocol.revshare;

import "gogoproto/gogo.proto";
import "dydxprotocol/revshare/params.proto";
import "dydxprotocol/revshare/revshare.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types";

// GenesisState defines `x/revshare`'s genesis state.
message GenesisState {
// params is the market mapper revenue share params.
MarketMapperRevenueShareParams params = 1 [ (gogoproto.nullable) = false ];
// unconditional_rev_share_config is the unconditional rev share config.
UnconditionalRevShareConfig unconditional_rev_share_config = 2 [ (gogoproto.nullable) = false ];
}
11 changes: 11 additions & 0 deletions proto/dydxprotocol/stats/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ syntax = "proto3";
package dydxprotocol.stats;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "dydxprotocol/stats/params.proto";
import "dydxprotocol/stats/stats.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/stats/types";

// GenesisState defines the stats module's genesis state.
message GenesisState {
// The parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
repeated AddressToUserStats address_to_user_stats = 2;
}

// AddressToUserStats is a struct that contains the user stats for an address.
message AddressToUserStats {
// The address of the user.
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// The user stats for the address.
UserStats user_stats = 2;
}
6 changes: 5 additions & 1 deletion protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@
"address": "dydx17xpfvakm2amg962yls6f84z3kell8c5leqdyt2",
"revenue_share_ppm": 0,
"valid_days": 0
},
"unconditional_rev_share_config": {
"configs": []
}
},
"rewards": {
Expand Down Expand Up @@ -475,7 +478,8 @@
"stats": {
"params": {
"window_duration": "2592000s"
}
},
"address_to_user_stats": []
},
"subaccounts": {
"subaccounts": []
Expand Down
6 changes: 5 additions & 1 deletion protocol/scripts/genesis/sample_pregenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3876,6 +3876,9 @@
"address": "dydx17xpfvakm2amg962yls6f84z3kell8c5leqdyt2",
"revenue_share_ppm": 0,
"valid_days": 0
},
"unconditional_rev_share_config": {
"configs": []
}
},
"rewards": {
Expand Down Expand Up @@ -3917,6 +3920,7 @@
"validators": []
},
"stats": {
"address_to_user_stats": [],
"params": {
"window_duration": "2592000s"
}
Expand Down Expand Up @@ -3980,7 +3984,7 @@
]
}
},
"app_version": "5.2.1-103-g5c95dd72",
"app_version": "5.2.1-119-g77487f61",
"chain_id": "dydx-sample-1",
"consensus": {
"params": {
Expand Down
6 changes: 5 additions & 1 deletion protocol/testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/dydxprotocol/v4-chain/protocol/testutil/appoptions"
"github.com/dydxprotocol/v4-chain/protocol/testutil/constants"
testlog "github.com/dydxprotocol/v4-chain/protocol/testutil/logger"
affiliatestypes "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types"
assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types"
blocktimetypes "github.com/dydxprotocol/v4-chain/protocol/x/blocktime/types"
bridgetypes "github.com/dydxprotocol/v4-chain/protocol/x/bridge/types"
Expand Down Expand Up @@ -207,7 +208,8 @@ type GenesisStates interface {
govplus.GenesisState |
vaulttypes.GenesisState |
revsharetypes.GenesisState |
marketmapmoduletypes.GenesisState
marketmapmoduletypes.GenesisState |
affiliatestypes.GenesisState
}

// UpdateGenesisDocWithAppStateForModule updates the supplied genesis doc using the provided function. The function
Expand Down Expand Up @@ -269,6 +271,8 @@ func UpdateGenesisDocWithAppStateForModule[T GenesisStates](genesisDoc *types.Ge
moduleName = marketmapmoduletypes.ModuleName
case listingtypes.GenesisState:
moduleName = listingtypes.ModuleName
case affiliatestypes.GenesisState:
moduleName = affiliatestypes.ModuleName
default:
panic(fmt.Errorf("Unsupported type %T", t))
}
Expand Down
Loading
Loading