Skip to content

Commit

Permalink
refactor: use hc election add reward
Browse files Browse the repository at this point in the history
  • Loading branch information
thepiwo committed Dec 18, 2024
1 parent dcc14a8 commit 98b3188
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions test/stakingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe("StakingContract", () => {
const height = await aeSdk.getHeight();
const epochEnd = Number(epochInfo[1].start + epochInfo[1].length - 1n);
await utils.awaitKeyBlocks(aeSdk, Number(epochEnd - height));
await hcElection.step_eoe(aeSdk.address, 0, 0, 0, false);
await hcElection.step_eoe(validator.publicKey, 0, 0, 0, false);
await hcElection.add_reward(await aeSdk.getHeight(), validator.publicKey, {
amount: 1000n,
});
}

async function getMainStakingState() {
Expand Down Expand Up @@ -96,17 +99,6 @@ describe("StakingContract", () => {
assert.equal(getAfter.decodedResult, 2n);
});

it("MainStaking: add_rewards", async () => {
const epoch = await hcElection
.epoch()
.then(({ decodedResult }) => decodedResult);
await mainStaking.add_rewards(epoch, [[validator.publicKey, 1000]], {
amount: 1000,
});

console.log(await getMainStakingState());
});

it("DelegatedStaking: stake", async () => {
console.log("getDelegatedStakingState", await getDelegatedStakingState());
await delegatedStaking.delegate_stake({
Expand Down Expand Up @@ -141,12 +133,6 @@ describe("StakingContract", () => {
for (const i of [...Array(20)]) {
await nextEpoch();
}
const epoch = await hcElection
.epoch()
.then(({ decodedResult }) => decodedResult);
await mainStaking.add_rewards(epoch, [[validator.publicKey, 10000]], {
amount: 10000,
});
});

it("DelegatedStaking: request_unstake_delegated_stakes", async () => {
Expand All @@ -158,12 +144,11 @@ describe("StakingContract", () => {
});
console.log(
"getDelegatedStakingState",
util.inspect(
await getDelegatedStakingState(),
false,
null,
true /* enable colors */,
),
util.inspect(await getDelegatedStakingState(), false, null, true),
);
console.log(
"getMainStakingState",
util.inspect(await getMainStakingState(), false, null, true),
);
});

Expand All @@ -176,12 +161,7 @@ describe("StakingContract", () => {
});
console.log(
"getDelegatedStakingState",
util.inspect(
await getDelegatedStakingState(),
false,
null,
true /* enable colors */,
),
util.inspect(await getDelegatedStakingState(), false, null, true),
);
});

Expand All @@ -191,12 +171,7 @@ describe("StakingContract", () => {
});
console.log(
"getDelegatedStakingState",
util.inspect(
await getDelegatedStakingState(),
false,
null,
true /* enable colors */,
),
util.inspect(await getDelegatedStakingState(), false, null, true),
);
});
});

0 comments on commit 98b3188

Please sign in to comment.