From 5679afaca25ad3de9ef34e086812483830298580 Mon Sep 17 00:00:00 2001 From: BowTiedRadone Date: Mon, 22 Apr 2024 16:41:45 +0300 Subject: [PATCH] fix(pox-4-tests): Replace pox values `REWARD_CYCLE_LENGTH` and `FIRST_BURNCHAIN_BLOCK_HEIGHT` consts --- .../tests/pox-4/pox_CommandModel.ts | 14 +++++++++++--- .../tests/pox-4/pox_DelegateStackExtendCommand.ts | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/contrib/core-contract-tests/tests/pox-4/pox_CommandModel.ts b/contrib/core-contract-tests/tests/pox-4/pox_CommandModel.ts index 243b89a36e..6d4d582b58 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_CommandModel.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_CommandModel.ts @@ -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; @@ -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 @@ -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 @@ -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++; } diff --git a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackExtendCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackExtendCommand.ts index a699cd2006..cfd385cf5a 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackExtendCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackExtendCommand.ts @@ -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 (