adding onto the validator-api tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import ContractCache from "../../../tests/src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../src/config/configHandler";
|
||||
|
||||
let contract: ContractCache;
|
||||
let config: ConfigHandler;
|
||||
|
||||
describe("Get mixnode data", (): void => {
|
||||
beforeAll(async (): Promise<void> => {
|
||||
contract = new ContractCache();
|
||||
config = ConfigHandler.getInstance();
|
||||
});
|
||||
|
||||
it("Get all mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getMixnodes();
|
||||
|
||||
response.forEach((x) => {
|
||||
console.log(x.pledge_amount);
|
||||
console.log(x.total_delegation);
|
||||
console.log(x.owner);
|
||||
console.log(x.layer);
|
||||
console.log(x.block_height);
|
||||
console.log(x.mix_node);
|
||||
console.log(x.proxy);
|
||||
console.log(x.accumulated_rewards);
|
||||
});
|
||||
expect(typeof response.as_at).toBe("number");
|
||||
expect(typeof response.saturation).toBe("number");
|
||||
});
|
||||
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuites name="jest tests" tests="9" failures="0" errors="0" time="3.223">
|
||||
<testsuite name="Get mixnode data" errors="0" failures="0" skipped="0" timestamp="2022-08-12T08:12:05" time="3.021" tests="9">
|
||||
<testcase classname="Get mixnode data Get a mixnode stake saturation" name="Get mixnode data Get a mixnode stake saturation" time="0.216">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a mixnode average uptime" name="Get mixnode data Get a mixnode average uptime" time="0.196">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a mixnode history" name="Get mixnode data Get a mixnode history" time="0.386">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.211">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.321">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a gateway history" name="Get mixnode data Get a gateway history" time="0.269">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a mixnode status" name="Get mixnode data Get a mixnode status" time="0.244">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a mixnode reward estimation" name="Get mixnode data Get a mixnode reward estimation" time="0.185">
|
||||
</testcase>
|
||||
<testcase classname="Get mixnode data Get a mixnode inclusion probability" name="Get mixnode data Get a mixnode inclusion probability" time="0.179">
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
Generated
+8388
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,53 @@
|
||||
import { AxiosResponse } from "axios";
|
||||
import { MixnodesDetailed, AllGateways, AllMixnodes } from "../../src/interfaces/ContractInterfaces";
|
||||
import { APIClient } from "./abstracts/APIClient";
|
||||
|
||||
export default class ContractCache extends APIClient {
|
||||
|
||||
public async getMixnodes(): Promise<AllMixnodes> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes`,
|
||||
});
|
||||
|
||||
return <AllMixnodes>{
|
||||
pledge_amount: response.data.pledge_amount,
|
||||
total_delegation: response.data.total_delegation,
|
||||
owner: response.data.owner,
|
||||
layer: response.data.layer,
|
||||
block_height: response.data.block_height,
|
||||
mix_node: response.data.mix_node,
|
||||
proxy: response.data.proxy,
|
||||
accumulated_rewards: response.data.accumulated_rewards
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodesDetailed(): Promise<MixnodesDetailed> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/detailed`,
|
||||
});
|
||||
|
||||
return <MixnodesDetailed>{
|
||||
mixnode_bond: response.data.mixnode_bond,
|
||||
stake_saturation: response.data.stake_saturation,
|
||||
uptime: response.data.uptime,
|
||||
estimated_operator_apy: response.data.estimated_operator_apy,
|
||||
estimated_delegators_apy: response.data.estimated_delegators_apy
|
||||
};
|
||||
}
|
||||
|
||||
public async getGateways(): Promise<AllGateways> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/gateways`,
|
||||
});
|
||||
|
||||
return <AllGateways>{
|
||||
pledge_amount: response.data.pledge_amount,
|
||||
owner: response.data.owner,
|
||||
block_height: response.data.block_height,
|
||||
gateway: response.data.gateway,
|
||||
proxy: response.data.proxy
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -56,6 +56,18 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeHistory(identity_key: string): Promise<NodeHistory> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/history`,
|
||||
});
|
||||
|
||||
return <NodeHistory>{
|
||||
identity: response.data.identity,
|
||||
owner: response.data.owner,
|
||||
history: response.data.history,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeStakeSaturation(
|
||||
identity_key: string
|
||||
): Promise<StakeSaturation> {
|
||||
@@ -127,17 +139,7 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeHistory(identity_key: string): Promise<NodeHistory> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/history`,
|
||||
});
|
||||
|
||||
return <NodeHistory>{
|
||||
identity: response.data.identity,
|
||||
owner: response.data.owner,
|
||||
history: response.data.history,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public async getMixnodeAverageUptime(
|
||||
identity_key: string
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
export type AllMixnodes = {
|
||||
pledge_amount: PledgeAmount;
|
||||
total_delegation: TotalDelegation;
|
||||
owner: string;
|
||||
layer: string;
|
||||
block_height: number;
|
||||
mix_node: Mixnode;
|
||||
proxy: string;
|
||||
accumulated_rewards: string;
|
||||
}
|
||||
|
||||
export type PledgeAmount = {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export type TotalDelegation = {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export type Mixnode = {
|
||||
host: string;
|
||||
mix_port: number;
|
||||
verloc_port: number;
|
||||
http_api_port: number;
|
||||
sphinx_key: string;
|
||||
identity_key: string;
|
||||
version: string;
|
||||
profit_margin_percent: number;
|
||||
}
|
||||
|
||||
export type MixnodesDetailed = {
|
||||
mixnode_bond: AllMixnodes;
|
||||
stake_saturation: number;
|
||||
uptime: number;
|
||||
estimated_operator_apy: number;
|
||||
estimated_delegators_apy: number;
|
||||
}
|
||||
|
||||
export type AllGateways = {
|
||||
pledge_amount: PledgeAmount;
|
||||
owner: string;
|
||||
block_height: number;
|
||||
gateway: Gateway;
|
||||
proxy: string;
|
||||
}
|
||||
|
||||
export type Gateway = {
|
||||
host: string;
|
||||
mix_port: number;
|
||||
clients_port: number;
|
||||
location: string;
|
||||
sphinx_key: string;
|
||||
identity_key: string;
|
||||
version: string;
|
||||
}
|
||||
@@ -69,4 +69,4 @@ export type CoreCount = {
|
||||
|
||||
export type ActiveStatus = {
|
||||
status: string;
|
||||
};
|
||||
};
|
||||
+2038
-2020
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user