Skip to content

Commit

Permalink
fix(pox-4-tests): Replace pox values REWARD_CYCLE_LENGTH and `FIRST…
Browse files Browse the repository at this point in the history
…_BURNCHAIN_BLOCK_HEIGHT` consts
  • Loading branch information
BowTiedRadone authored and moodmosaic committed Apr 22, 2024
1 parent e33895f commit 5679afa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions contrib/core-contract-tests/tests/pox-4/pox_CommandModel.ts
Expand Up @@ -7,6 +7,10 @@ import {
StacksPrivateKey,
} from "@stacks/transactions";
import { StackingClient } from "@stacks/stacking";
import {
FIRST_BURNCHAIN_BLOCK_HEIGHT,
REWARD_CYCLE_LENGTH,
} from "./pox_Commands";

export type StxAddress = string;
export type BtcAddress = string;
Expand Down Expand Up @@ -53,7 +57,10 @@ export class Stub {
cvToValue(burnBlockHeightResult as ClarityValue),
);
const lastRefreshedCycle = this.lastRefreshedCycle;
const currentRewCycle = Math.floor((Number(burnBlockHeight) - 0) / 1050);
const currentRewCycle = Math.floor(
(Number(burnBlockHeight) - FIRST_BURNCHAIN_BLOCK_HEIGHT) /
REWARD_CYCLE_LENGTH,
);

// The `this.burnBlockHeight` instance member is used for logging purposes.
// However, it's not used in the actual implementation of the model and all
Expand Down Expand Up @@ -81,7 +88,7 @@ export class Stub {
stackerAddress,
) =>
this.stackers.get(stackerAddress)!.unlockHeight <=
burnBlockHeight + 1050
burnBlockHeight + REWARD_CYCLE_LENGTH
);

// Get the operator's ex-pool stackers by comparing their unlockHeight to
Expand Down Expand Up @@ -138,7 +145,8 @@ export class Stub {
// next empty reward slot)
else if (
wallet.unlockHeight > 0 &&
wallet.unlockHeight > burnBlockHeight + 1050 && wallet.isStackingSolo
wallet.unlockHeight > burnBlockHeight + REWARD_CYCLE_LENGTH &&
wallet.isStackingSolo
) {
this.nextRewardSetIndex++;
}
Expand Down
Expand Up @@ -74,7 +74,8 @@ export class DelegateStackExtendCommand implements PoxCommand {
const lastExtendCycle = firstExtendCycle + this.extendCount - 1;
const totalPeriod = lastExtendCycle - firstRewardCycle + 1;
const newUnlockHeight =
REWARD_CYCLE_LENGTH * (firstRewardCycle + totalPeriod - 1) + 0;
REWARD_CYCLE_LENGTH * (firstRewardCycle + totalPeriod - 1) +
FIRST_BURNCHAIN_BLOCK_HEIGHT;
const stackedAmount = stackerWallet.amountLocked;

return (
Expand Down

0 comments on commit 5679afa

Please sign in to comment.