adding missing endpoints
This commit is contained in:
@@ -124,4 +124,4 @@ generate-typescript:
|
||||
yarn types:lint:fix
|
||||
|
||||
run-validator-tests:
|
||||
cd validator-api/tests/functional_test && yarn test
|
||||
cd nym-api/tests/functional_test && yarn test:qa
|
||||
@@ -138,6 +138,7 @@ describe("Get mixnode data", (): void => {
|
||||
const response = await contract.getActiveMixnodes();
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.rewarding_details.cost_params.profit_margin_percent).toBeTruthy()
|
||||
expect(typeof mixnode.bond_information.layer).toBe('number')
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,14 +12,15 @@ describe("Get gateway data", (): void => {
|
||||
|
||||
it("Get all gateways detailed", async (): Promise<void> => {
|
||||
const response = await status.getDetailedGateways();
|
||||
|
||||
expect(typeof response.owner).toBe("string");
|
||||
response.forEach((x) => {
|
||||
expect(typeof x.gateway_bond.owner).toBe("string");
|
||||
expect(typeof x.performance).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
it("Get a gateway history", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayHistory(identity_key);
|
||||
|
||||
response.history.forEach((x) => {
|
||||
expect(typeof x.date).toBe("string");
|
||||
expect(typeof x.uptime).toBe("number");
|
||||
@@ -32,7 +33,6 @@ describe("Get gateway data", (): void => {
|
||||
it("Get gateway core status count", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayCoreCount(identity_key);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
@@ -40,13 +40,11 @@ describe("Get gateway data", (): void => {
|
||||
it("Get a gateway status report", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayStatusReport(identity_key);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
expect(typeof response.most_recent).toBe("number");
|
||||
expect(typeof response.last_hour).toBe("number");
|
||||
expect(typeof response.last_day).toBe("number");
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,13 +10,18 @@ describe("Get mixnode data", (): void => {
|
||||
config = ConfigHandler.getInstance();
|
||||
});
|
||||
|
||||
it("Get a mixnode report", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStatusReport(identity_key);
|
||||
|
||||
expect(typeof response.last_day).toBe("number");
|
||||
expect(typeof response.owner).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a mixnode stake saturation", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStakeSaturation(identity_key);
|
||||
|
||||
console.log(response.as_at);
|
||||
console.log(response.saturation);
|
||||
|
||||
expect(typeof response.as_at).toBe("number");
|
||||
expect(typeof response.saturation).toBe("string");
|
||||
expect(typeof response.uncapped_saturation).toBe("string");
|
||||
@@ -26,9 +31,6 @@ describe("Get mixnode data", (): void => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeAverageUptime(identity_key);
|
||||
|
||||
console.log(response.avg_uptime);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.avg_uptime).toBe("number");
|
||||
});
|
||||
@@ -40,47 +42,16 @@ describe("Get mixnode data", (): void => {
|
||||
response.history.forEach((x) => {
|
||||
console.log(x.date);
|
||||
console.log(x.uptime);
|
||||
});
|
||||
console.log(response.mix_id);
|
||||
console.log(response.owner);
|
||||
})
|
||||
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a gateway history", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayHistory(identity_key);
|
||||
|
||||
response.history.forEach((x) => {
|
||||
console.log(x.date);
|
||||
console.log(x.uptime);
|
||||
});
|
||||
console.log(response.identity);
|
||||
console.log(response.owner);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a gateway history", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayCoreCount(identity_key);
|
||||
|
||||
console.log(response.count);
|
||||
console.log(response.identity);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
|
||||
it("Get a gateway history", async (): Promise<void> => {
|
||||
it("Get a mixnode core count", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeCoreCount(identity_key);
|
||||
|
||||
console.log(response.count);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
@@ -89,8 +60,6 @@ describe("Get mixnode data", (): void => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStatus(identity_key);
|
||||
|
||||
console.log(response.status);
|
||||
|
||||
expect(response.status).toStrictEqual("active");
|
||||
});
|
||||
|
||||
@@ -98,27 +67,54 @@ describe("Get mixnode data", (): void => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeRewardComputation(identity_key);
|
||||
|
||||
console.log(response.estimated_delegators_reward);
|
||||
console.log(response.estimated_node_profit);
|
||||
console.log(response.estimated_operator_cost);
|
||||
console.log(response.estimated_operator_reward);
|
||||
console.log(response.estimated_total_node_reward);
|
||||
console.log(response.reward_params);
|
||||
console.log(response.as_at);
|
||||
console.log(response);
|
||||
|
||||
//assertions to come
|
||||
//expect(response).toStrictEqual('something');
|
||||
expect(response.reward_params.interval.sybil_resistance).toStrictEqual("0.3");
|
||||
expect(response.reward_params.active_set_size).toStrictEqual(240);
|
||||
expect(typeof response.reward_params.interval.reward_pool).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a mixnode inclusion probability", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeInclusionProbability(identity_key);
|
||||
|
||||
console.log(response.in_active);
|
||||
console.log(response.in_reserve);
|
||||
|
||||
//assertions to come
|
||||
//expect(response).toStrictEqual('something');
|
||||
expect(typeof response.in_active).toBe("string");
|
||||
});
|
||||
|
||||
it("Get all mixnodes inclusion probability", async (): Promise<void> => {
|
||||
const response = await status.getAllMixnodeInclusionProbability();
|
||||
|
||||
expect(response.inclusion_probabilities).toBeTruthy();
|
||||
});
|
||||
|
||||
it("Get all mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedMixnodes();
|
||||
|
||||
expect(typeof response.stake_saturation).toBe("string");
|
||||
});
|
||||
|
||||
it("Get all rewarded mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedRewardedMixnodes();
|
||||
|
||||
expect(typeof response.mixnode_details.rewarding_details.last_rewarded_epoch).toBe("number");
|
||||
});
|
||||
|
||||
it("Get all active mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedActiveMixnodes();
|
||||
|
||||
expect(typeof response.mixnode_details.bond_information.layer).toBe("number");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("Compute mixnode reward estimation", (): void => {
|
||||
beforeAll(async (): Promise<void> => {
|
||||
status = new Status();
|
||||
config = ConfigHandler.getInstance();
|
||||
});
|
||||
it("with correct data", async (): Promise<void> => {
|
||||
const response = await status.sendMixnodeRewardEstimatedComputation(8);
|
||||
const body =
|
||||
|
||||
expect(typeof response.estimation.total_node_reward).toBe("string");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
ComputeRewardEstimation,
|
||||
CoreCount,
|
||||
DetailedGateway,
|
||||
DetailedMixnodes,
|
||||
InclusionProbabilities,
|
||||
InclusionProbability,
|
||||
NodeHistory,
|
||||
Report,
|
||||
@@ -20,7 +22,7 @@ export default class Status extends APIClient {
|
||||
|
||||
// GATEWAYS
|
||||
|
||||
public async getDetailedGateways(): Promise<DetailedGateway> {
|
||||
public async getDetailedGateways(): Promise<DetailedGateway[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/gateways/detailed`,
|
||||
});
|
||||
@@ -93,9 +95,20 @@ export default class Status extends APIClient {
|
||||
|
||||
public async sendMixnodeRewardEstimatedComputation(
|
||||
mix_id: number
|
||||
): Promise<ComputeRewardEstimation> {
|
||||
): Promise<RewardEstimation> {
|
||||
const response = await this.restClient.sendPost({
|
||||
route: `/mixnode/${mix_id}/compute-reward-estimation`,
|
||||
data: {
|
||||
// performance: "10",
|
||||
active_in_rewarded_set: true,
|
||||
// pledge_amount: 10,
|
||||
// total_delegation: 2000,
|
||||
// interval_operating_cost: {
|
||||
// denom: "unym",
|
||||
// amount: "250000000"
|
||||
// },
|
||||
// profit_margin_percent: 10
|
||||
}
|
||||
});
|
||||
|
||||
return response.data;
|
||||
@@ -136,4 +149,36 @@ export default class Status extends APIClient {
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getAllMixnodeInclusionProbability(): Promise<InclusionProbabilities> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/inclusion-probability`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedMixnodes(): Promise<DetailedMixnodes> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/detailed`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedRewardedMixnodes(): Promise<DetailedMixnodes> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/rewarded/detailed`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedActiveMixnodes(): Promise<DetailedMixnodes> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/active/detailed`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export type BondInformation = {
|
||||
mix_id: number;
|
||||
owner: string;
|
||||
original_pledge: OriginalPledge;
|
||||
layer: string;
|
||||
layer: number;
|
||||
mix_node: Mixnode;
|
||||
proxy: string;
|
||||
bonding_height: number;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export type CurrentEpoch = {
|
||||
export interface CurrentEpoch {
|
||||
epoch_reward_pool: string;
|
||||
rewarded_set_size: string;
|
||||
active_set_size: string;
|
||||
staking_supply: string;
|
||||
sybil_resistance_percent: number;
|
||||
active_set_work_factor: number;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export interface Epoch {
|
||||
@@ -22,11 +22,11 @@ export interface EpochLength {
|
||||
nanos: number;
|
||||
}
|
||||
|
||||
export type Node = {
|
||||
export interface Node {
|
||||
reward_blockstamp: number;
|
||||
uptime: string;
|
||||
in_active_set: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface RewardEstimation {
|
||||
estimation: Estimation;
|
||||
@@ -57,7 +57,7 @@ export interface ComputeRewardEstimation {
|
||||
profit_margin_percent: string
|
||||
}
|
||||
|
||||
export type IntervalOperatingCost = {
|
||||
export interface IntervalOperatingCost {
|
||||
denom: string,
|
||||
amount: string
|
||||
}
|
||||
@@ -73,27 +73,27 @@ export interface Interval {
|
||||
interval_pool_emission: string;
|
||||
}
|
||||
|
||||
export type StakeSaturation = {
|
||||
export interface StakeSaturation {
|
||||
saturation: string;
|
||||
uncapped_saturation: string;
|
||||
as_at: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type AvgUptime = {
|
||||
export interface AvgUptime {
|
||||
mix_id: number;
|
||||
avg_uptime: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SingleInclusionProbability {
|
||||
in_active: number;
|
||||
in_reserve: number;
|
||||
}
|
||||
|
||||
export type InclusionProbability = {
|
||||
export interface InclusionProbability {
|
||||
mix_id: number;
|
||||
in_active: string;
|
||||
in_reserve: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface InclusionProbabilities {
|
||||
inclusion_probabilities: InclusionProbability[];
|
||||
@@ -109,38 +109,123 @@ export interface Elapsed {
|
||||
nanos: number;
|
||||
}
|
||||
|
||||
export type Report = {
|
||||
export interface Report {
|
||||
mix_id: number;
|
||||
identity: string;
|
||||
owner: string;
|
||||
most_recent: number;
|
||||
last_hour: number;
|
||||
last_day: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type History = {
|
||||
export interface History {
|
||||
date: string;
|
||||
uptime: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type NodeHistory = {
|
||||
export interface NodeHistory {
|
||||
mix_id: number,
|
||||
identity: string;
|
||||
owner: string;
|
||||
history: History[];
|
||||
};
|
||||
}
|
||||
|
||||
export type CoreCount = {
|
||||
export interface CoreCount {
|
||||
mix_id: number,
|
||||
identity: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export type ActiveStatus = {
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type DetailedGateway = {
|
||||
owner: string;
|
||||
|
||||
}
|
||||
|
||||
export interface ActiveStatus {
|
||||
status: string;
|
||||
}
|
||||
|
||||
|
||||
export interface PledgeAmount {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface Gateway {
|
||||
host: string;
|
||||
mix_port: number;
|
||||
clients_port: number;
|
||||
location: string;
|
||||
sphinx_key: string;
|
||||
identity_key: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface GatewayBond {
|
||||
pledge_amount: PledgeAmount;
|
||||
owner: string;
|
||||
block_height: number;
|
||||
gateway: Gateway;
|
||||
proxy?: any;
|
||||
}
|
||||
|
||||
export interface DetailedGateway {
|
||||
gateway_bond: GatewayBond;
|
||||
performance: string;
|
||||
}
|
||||
|
||||
export interface OriginalPledge {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface MixNode {
|
||||
host: string;
|
||||
mix_port: number;
|
||||
verloc_port: number;
|
||||
http_api_port: number;
|
||||
sphinx_key: string;
|
||||
identity_key: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface BondInformation {
|
||||
mix_id: number;
|
||||
owner: string;
|
||||
original_pledge: OriginalPledge;
|
||||
layer: string;
|
||||
mix_node: MixNode;
|
||||
proxy: string;
|
||||
bonding_height: number;
|
||||
is_unbonding: boolean;
|
||||
}
|
||||
|
||||
export interface IntervalOperatingCost {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface CostParams {
|
||||
profit_margin_percent: string;
|
||||
interval_operating_cost: IntervalOperatingCost;
|
||||
}
|
||||
|
||||
export interface RewardingDetails {
|
||||
cost_params: CostParams;
|
||||
operator: string;
|
||||
delegates: string;
|
||||
total_unit_reward: string;
|
||||
unit_delegation: string;
|
||||
last_rewarded_epoch: number;
|
||||
unique_delegations: number;
|
||||
}
|
||||
|
||||
export interface MixnodeDetails {
|
||||
bond_information: BondInformation;
|
||||
rewarding_details: RewardingDetails;
|
||||
}
|
||||
|
||||
export interface DetailedMixnodes {
|
||||
mixnode_details: MixnodeDetails;
|
||||
stake_saturation: string;
|
||||
uncapped_stake_saturation: string;
|
||||
performance: string;
|
||||
estimated_operator_apy: string;
|
||||
estimated_delegators_apy: string;
|
||||
family: string;
|
||||
}
|
||||
Reference in New Issue
Block a user