diff --git a/contrib/core-contract-tests/tests/pox-4/pox_CheckBalanceCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_CheckBalanceCommand.ts deleted file mode 100644 index d28613a22..000000000 --- a/contrib/core-contract-tests/tests/pox-4/pox_CheckBalanceCommand.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { - logCommand, - PoxCommand, - Real, - Stub, - Wallet, -} from "./pox_CommandModel.ts"; -import { expect } from "vitest"; -import { ClarityValue, cvToValue } from "@stacks/transactions"; - -/** - * Implements the `PoxCommand` interface to check a wallet's balance. - */ -export class CheckBalanceCommand implements PoxCommand { - readonly wallet: Wallet; - - /** - * Constructs a new `CheckBalanceCommand`. - * - * @param wallet The wallet information, including the STX address used to - * query the `stx-account`. - */ - constructor(wallet: Wallet) { - this.wallet = wallet; - } - - check(_model: Readonly): boolean { - // Can always check user's balance. - return true; - } - - run(model: Stub, real: Real): void { - const actual = model.wallets.get(this.wallet.stxAddress)!; - - // Get the real balance - const stxAccount = cvToValue( - real.network.runSnippet( - `(stx-account '${actual.stxAddress})`, - ) as ClarityValue, - ); - const lockedBalance = parseInt(stxAccount.locked.value); - const unlockedBalance = parseInt(stxAccount.unlocked.value); - const realBalance = lockedBalance + unlockedBalance; - - // Check the real balance to equal wallet's ustxBalance - expect(realBalance).toBe(this.wallet.ustxBalance); - - // Log to console for debugging purposes. This is not necessary for the - // test to pass but it is useful for debugging and eyeballing the test. - logCommand( - `✓ ${this.wallet.label}`, - "check-balance", - "real-balance", - realBalance.toString(), - "wallet-balance", - this.wallet.ustxBalance.toString(), - ); - } - - toString() { - // fast-check will call toString() in case of errors, e.g. property failed. - // It will then make a minimal counterexample, a process called 'shrinking' - // https://github.com/dubzzz/fast-check/issues/2864#issuecomment-1098002642 - return `${this.wallet.label} check-balance`; - } -} diff --git a/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts b/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts index 838b4d2a2..62db94efa 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts @@ -9,7 +9,6 @@ import { Simnet } from "@hirosystems/clarinet-sdk"; import { Cl, cvToValue, OptionalCV, UIntCV } from "@stacks/transactions"; import { RevokeDelegateStxCommand } from "./pox_RevokeDelegateStxCommand"; import { AllowContractCallerCommand } from "./pox_AllowContractCallerCommand"; -import { CheckBalanceCommand } from "./pox_CheckBalanceCommand"; export function PoxCommands( wallets: Map, @@ -168,18 +167,6 @@ export function PoxCommands( r.wallet, ) ), - // CheckBalanceCommand - fc.record({ - wallet: fc.constantFrom(...wallets.values()), - }).map(( - r: { - wallet: Wallet; - }, - ) => - new CheckBalanceCommand( - r.wallet, - ) - ), ]; // More on size: https://github.com/dubzzz/fast-check/discussions/2978 diff --git a/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts index ac5a482b8..7f6ddf6ca 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts @@ -39,6 +39,8 @@ export class GetStxAccountCommand implements PoxCommand { "unlock-height": Cl.uint(actual.unlockHeight), }); + expect(actual.amountLocked + actual.amountUnlocked).toBe(actual.ustxBalance); + // Log to console for debugging purposes. This is not necessary for the // test to pass but it is useful for debugging and eyeballing the test. logCommand(