editing tests
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
import ContractCache from "../../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../../src/config/configHandler";
|
||||
import ContractCache from "../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../src/config/configHandler";
|
||||
|
||||
let contract: ContractCache;
|
||||
let config: ConfigHandler;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import ContractCache from "../../../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../../../src/config/configHandler";
|
||||
import ContractCache from "../../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../../src/config/configHandler";
|
||||
|
||||
let contract: ContractCache;
|
||||
let config: ConfigHandler;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import ContractCache from "../../../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../../../src/config/configHandler";
|
||||
import ContractCache from "../../../src/endpoints/ContractCache";
|
||||
import ConfigHandler from "../../../src/config/configHandler";
|
||||
|
||||
let contract: ContractCache;
|
||||
let config: ConfigHandler;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import Status from "../../../src/endpoints/Status";
|
||||
import ConfigHandler from "../../../src/config/configHandler";
|
||||
import Status from "../../src/endpoints/Status";
|
||||
import ConfigHandler from "../../src/config/configHandler";
|
||||
|
||||
let status: Status;
|
||||
let config: ConfigHandler;
|
||||
+17
-16
@@ -1,5 +1,5 @@
|
||||
import Status from "../../../src/endpoints/Status";
|
||||
import ConfigHandler from "../../../src/config/configHandler";
|
||||
import Status from "../../src/endpoints/Status";
|
||||
import ConfigHandler from "../../src/config/configHandler";
|
||||
|
||||
let status: Status;
|
||||
let config: ConfigHandler;
|
||||
@@ -11,39 +11,40 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode stake saturation", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
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("number");
|
||||
expect(typeof response.saturation).toBe("string");
|
||||
expect(typeof response.uncapped_saturation).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a mixnode average uptime", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeAverageUptime(identity_key);
|
||||
|
||||
console.log(response.avg_uptime);
|
||||
console.log(response.identity);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.avg_uptime).toBe("number");
|
||||
});
|
||||
|
||||
it("Get a mixnode history", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeHistory(identity_key);
|
||||
|
||||
response.history.forEach((x) => {
|
||||
console.log(x.date);
|
||||
console.log(x.uptime);
|
||||
});
|
||||
console.log(response.identity);
|
||||
console.log(response.mix_id);
|
||||
console.log(response.owner);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
});
|
||||
|
||||
@@ -74,18 +75,18 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a gateway history", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeCoreCount(identity_key);
|
||||
|
||||
console.log(response.count);
|
||||
console.log(response.identity);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
|
||||
it("Get a mixnode status", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStatus(identity_key);
|
||||
|
||||
console.log(response.status);
|
||||
@@ -94,7 +95,7 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode reward estimation", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeRewardComputation(identity_key);
|
||||
|
||||
console.log(response.estimated_delegators_reward);
|
||||
@@ -111,7 +112,7 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode inclusion probability", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.mixnode_identity;
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeInclusionProbability(identity_key);
|
||||
|
||||
console.log(response.in_active);
|
||||
@@ -15,20 +15,8 @@ export default class Status extends APIClient {
|
||||
constructor() {
|
||||
super("/status");
|
||||
}
|
||||
|
||||
public async getMixnodeStatusReport(identity_key: string): Promise<Report> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/report`,
|
||||
});
|
||||
|
||||
return <Report>{
|
||||
identity: response.data.identity,
|
||||
owner: response.data.owner,
|
||||
most_recent: response.data.most_recent,
|
||||
last_hour: response.data.last_hour,
|
||||
last_day: response.data.last_day,
|
||||
};
|
||||
}
|
||||
|
||||
// GATEWAYS
|
||||
|
||||
public async getGatewayStatusReport(identity_key: string): Promise<Report> {
|
||||
const response = await this.restClient.sendGet({
|
||||
@@ -56,30 +44,6 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeStakeSaturation(
|
||||
identity_key: string
|
||||
): Promise<StakeSaturation> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/stake-saturation`,
|
||||
});
|
||||
|
||||
return <StakeSaturation>{
|
||||
as_at: response.data.as_at,
|
||||
saturation: response.data.saturation,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeCoreCount(identity_key: string): Promise<CoreCount> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/core-status-count`,
|
||||
});
|
||||
|
||||
return <CoreCount>{
|
||||
identity: response.data.identity,
|
||||
count: response.data.count,
|
||||
};
|
||||
}
|
||||
|
||||
public async getGatewayCoreCount(identity_key: string): Promise<CoreCount> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/gateway/${identity_key}/core-status-count`,
|
||||
@@ -91,11 +55,55 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// MIXNODES
|
||||
|
||||
public async getMixnodeStatusReport(mix_id: number): Promise<Report> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${mix_id}/report`,
|
||||
});
|
||||
|
||||
return <Report>{
|
||||
mix_id: response.data.mix_id,
|
||||
identity: response.data.identity,
|
||||
owner: response.data.owner,
|
||||
most_recent: response.data.most_recent,
|
||||
last_hour: response.data.last_hour,
|
||||
last_day: response.data.last_day,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeStakeSaturation(
|
||||
mix_id: number
|
||||
): Promise<StakeSaturation> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${mix_id}/stake-saturation`,
|
||||
});
|
||||
|
||||
return <StakeSaturation>{
|
||||
as_at: response.data.as_at,
|
||||
saturation: response.data.saturation,
|
||||
uncapped_saturation: response.uncapped_saturation,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeCoreCount(mix_id: number): Promise<CoreCount> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${mix_id}/core-status-count`,
|
||||
});
|
||||
|
||||
return <CoreCount>{
|
||||
mix_id: response.data.mix_id,
|
||||
identity: response.data.identity,
|
||||
count: response.data.count,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeRewardComputation(
|
||||
identity_key: string
|
||||
mix_id: number
|
||||
): Promise<EstimatedReward> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/reward-estimation`,
|
||||
route: `/mixnode/${mix_id}/reward-estimation`,
|
||||
});
|
||||
|
||||
return <EstimatedReward>{
|
||||
@@ -110,10 +118,10 @@ export default class Status extends APIClient {
|
||||
}
|
||||
|
||||
public async getMixnodeRewardEstimatedComputation(
|
||||
identity_key: string
|
||||
mix_id: number
|
||||
): Promise<EstimatedReward> {
|
||||
const response = await this.restClient.sendPost({
|
||||
route: `/mixnode/${identity_key}/compute-reward-estimation`,
|
||||
route: `/mixnode/${mix_id}/compute-reward-estimation`,
|
||||
});
|
||||
|
||||
return <EstimatedReward>{
|
||||
@@ -127,12 +135,13 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeHistory(identity_key: string): Promise<NodeHistory> {
|
||||
public async getMixnodeHistory(mix_id: number): Promise<NodeHistory> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/history`,
|
||||
route: `/mixnode/${mix_id}/history`,
|
||||
});
|
||||
|
||||
return <NodeHistory>{
|
||||
mix_id: response.data.mix_id,
|
||||
identity: response.data.identity,
|
||||
owner: response.data.owner,
|
||||
history: response.data.history,
|
||||
@@ -140,23 +149,23 @@ export default class Status extends APIClient {
|
||||
}
|
||||
|
||||
public async getMixnodeAverageUptime(
|
||||
identity_key: string
|
||||
mix_id: number
|
||||
): Promise<AvgUptime> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/avg_uptime`,
|
||||
route: `/mixnode/${mix_id}/avg_uptime`,
|
||||
});
|
||||
|
||||
return <AvgUptime>{
|
||||
identity: response.data.identity,
|
||||
mix_id: response.data.mix_id,
|
||||
avg_uptime: response.data.avg_uptime,
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeInclusionProbability(
|
||||
identity_key: string
|
||||
mix_id: number
|
||||
): Promise<InclusionProbability> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/inclusion-probability`,
|
||||
route: `/mixnode/${mix_id}/inclusion-probability`,
|
||||
});
|
||||
|
||||
return <InclusionProbability>{
|
||||
@@ -165,9 +174,9 @@ export default class Status extends APIClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMixnodeStatus(identity_key: string): Promise<ActiveStatus> {
|
||||
public async getMixnodeStatus(mix_id: number): Promise<ActiveStatus> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${identity_key}/status`,
|
||||
route: `/mixnode/${mix_id}/status`,
|
||||
});
|
||||
|
||||
return <ActiveStatus>{
|
||||
|
||||
@@ -29,12 +29,13 @@ export type EstimatedReward = {
|
||||
};
|
||||
|
||||
export type StakeSaturation = {
|
||||
saturation: number;
|
||||
saturation: string;
|
||||
uncapped_saturation: string;
|
||||
as_at: number;
|
||||
};
|
||||
|
||||
export type AvgUptime = {
|
||||
identity: string;
|
||||
mix_id: number;
|
||||
avg_uptime: number;
|
||||
};
|
||||
|
||||
@@ -57,12 +58,14 @@ export type History = {
|
||||
};
|
||||
|
||||
export type NodeHistory = {
|
||||
mix_id: number,
|
||||
identity: string;
|
||||
owner: string;
|
||||
history: History[];
|
||||
};
|
||||
|
||||
export type CoreCount = {
|
||||
mix_id: number,
|
||||
identity: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"typeRoots": ["node_modules/@types"],
|
||||
"alwaysStrict": true
|
||||
},
|
||||
"include": ["src/**/*", "functional_test/**/*"],
|
||||
"include": ["src/**/*", "functional_test/*/*"],
|
||||
"exclude": ["unit_test/**/*"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user