From e21db006493e001aac865236a692a0f3cc768f90 Mon Sep 17 00:00:00 2001 From: Nikos Baxevanis Date: Wed, 27 Mar 2024 01:03:09 +0100 Subject: [PATCH] style(pox-4): Run formatter on tests/pox-4/*.ts --- .../tests/pox-4/pox-4.stateful-prop.test.ts | 49 ++++++++++++++----- .../pox-4/pox_AllowContractCallerCommand.ts | 27 ++++++++-- .../tests/pox-4/pox_Commands.ts | 9 ++-- .../pox-4/pox_DelegateStackStxCommand.ts | 19 +++++-- .../tests/pox-4/pox_DelegateStxCommand.ts | 25 +++++++--- .../pox-4/pox_GetStackingMinimumCommand.ts | 15 +++++- .../tests/pox-4/pox_GetStxAccountCommand.ts | 19 ++++++- .../pox-4/pox_RevokeDelegateStxCommand.ts | 8 ++- .../tests/pox-4/pox_StackStxCommand.ts | 15 +++++- 9 files changed, 150 insertions(+), 36 deletions(-) diff --git a/contrib/core-contract-tests/tests/pox-4/pox-4.stateful-prop.test.ts b/contrib/core-contract-tests/tests/pox-4/pox-4.stateful-prop.test.ts index 4331f434a2..6c3df5fa0b 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox-4.stateful-prop.test.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox-4.stateful-prop.test.ts @@ -31,15 +31,42 @@ describe("PoX-4 invariant tests", () => { }; const wallets = [ - ["wallet_1", "7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801"], - ["wallet_2", "530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101"], - ["wallet_3", "d655b2523bcd65e34889725c73064feb17ceb796831c0e111ba1a552b0f31b3901"], - ["wallet_4", "f9d7206a47f14d2870c163ebab4bf3e70d18f5d14ce1031f3902fbbc894fe4c701"], - ["wallet_5", "3eccc5dac8056590432db6a35d52b9896876a3d5cbdea53b72400bc9c2099fe801"], - ["wallet_6", "7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01"], - ["wallet_7", "b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401"], - ["wallet_8", "6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01"], - ["wallet_9", "de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801"], + [ + "wallet_1", + "7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801", + ], + [ + "wallet_2", + "530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101", + ], + [ + "wallet_3", + "d655b2523bcd65e34889725c73064feb17ceb796831c0e111ba1a552b0f31b3901", + ], + [ + "wallet_4", + "f9d7206a47f14d2870c163ebab4bf3e70d18f5d14ce1031f3902fbbc894fe4c701", + ], + [ + "wallet_5", + "3eccc5dac8056590432db6a35d52b9896876a3d5cbdea53b72400bc9c2099fe801", + ], + [ + "wallet_6", + "7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01", + ], + [ + "wallet_7", + "b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401", + ], + [ + "wallet_8", + "6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01", + ], + [ + "wallet_9", + "de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801", + ], ].map((wallet) => { const label = wallet[0]; const prvKey = wallet[1]; @@ -71,8 +98,8 @@ describe("PoX-4 invariant tests", () => { amountLocked: 0, amountUnlocked: initialUstxBalance, unlockHeight: 0, - allowedContractCaller: '', - callerAllowedBy: [] + allowedContractCaller: "", + callerAllowedBy: [], }; }); diff --git a/contrib/core-contract-tests/tests/pox-4/pox_AllowContractCallerCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_AllowContractCallerCommand.ts index 64f4a32142..591568a17c 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_AllowContractCallerCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_AllowContractCallerCommand.ts @@ -1,6 +1,18 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { expect } from "vitest"; -import { boolCV, Cl, ClarityType, OptionalCV, UIntCV } from "@stacks/transactions"; +import { + boolCV, + Cl, + ClarityType, + OptionalCV, + UIntCV, +} from "@stacks/transactions"; /** * The `AllowContractCallerComand` gives a `contract-caller` authorization to call stacking methods. @@ -23,7 +35,6 @@ export class AllowContractCallerCommand implements PoxCommand { * @param allowanceTo - Represents the authorized `contract-caller` (i.e. a stacking pool) * @param alllowUntilBurnHt - The burn block height until the authorization is valid. */ - constructor( wallet: Wallet, allowanceTo: Wallet, @@ -59,14 +70,20 @@ export class AllowContractCallerCommand implements PoxCommand { // Get the wallets involved from the model and update it with the new state. const wallet = model.wallets.get(this.wallet.stxAddress)!; const callerToAllow = model.wallets.get(this.allowanceTo.stxAddress)!; - // Update model so that we know this wallet has authorized a contract-caller. + // Update model so that we know this wallet has authorized a contract-caller. wallet.allowedContractCaller = this.allowanceTo.stxAddress; callerToAllow.callerAllowedBy.push(wallet.stxAddress); // 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}`, "allow-contract-caller", this.allowanceTo.label, "until", optionalCVToString(this.allowUntilBurnHt)); + logCommand( + `✓ ${this.wallet.label}`, + "allow-contract-caller", + this.allowanceTo.label, + "until", + optionalCVToString(this.allowUntilBurnHt), + ); } toString() { 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 859316451c..e0024ffbeb 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_Commands.ts @@ -11,7 +11,8 @@ import { RevokeDelegateStxCommand } from "./pox_RevokeDelegateStxCommand"; import { AllowContractCallerCommand } from "./pox_AllowContractCallerCommand"; export function PoxCommands( - wallets: Map, network: Simnet, + wallets: Map, + network: Simnet, ): fc.Arbitrary>> { const cmds = [ // GetStackingMinimumCommand @@ -52,7 +53,7 @@ export function PoxCommands( wallet: fc.constantFrom(...wallets.values()), delegateTo: fc.constantFrom(...wallets.values()), untilBurnHt: fc.integer({ min: 1 }), - amount: fc.bigInt({ min:0n, max: 100_000_000_000_000n }), + amount: fc.bigInt({ min: 0n, max: 100_000_000_000_000n }), }).map(( r: { wallet: Wallet; @@ -77,7 +78,7 @@ export function PoxCommands( }, ) => new RevokeDelegateStxCommand( - r.wallet + r.wallet, ) ), // DelegateStackStxCommand @@ -89,7 +90,7 @@ export function PoxCommands( max: nextCycleFirstBlock(network), }), period: fc.integer({ min: 1, max: 12 }), - amount: fc.bigInt({ min:0n, max: 100_000_000_000_000n }), + amount: fc.bigInt({ min: 0n, max: 100_000_000_000_000n }), }).chain((r) => fc.record({ unlockBurnHt: fc.constant( diff --git a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackStxCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackStxCommand.ts index ae4d61cc7b..23e1892a39 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackStxCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStackStxCommand.ts @@ -1,4 +1,10 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { poxAddressToTuple } from "@stacks/stacking"; import { assert, expect } from "vitest"; import { Cl, ClarityType, isClarityType } from "@stacks/transactions"; @@ -104,7 +110,7 @@ export class DelegateStackStxCommand implements PoxCommand { // (start-burn-ht uint) Cl.uint(this.startBurnHt), // (lock-period uint) - Cl.uint(this.period) + Cl.uint(this.period), ], this.operator.stxAddress, ); @@ -146,7 +152,14 @@ export class DelegateStackStxCommand implements PoxCommand { // 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.operator.label} Ӿ ${this.stacker.label}`, "delegate-stack-stx", "lock-amount", this.amountUstx.toString(), "until", this.stacker.unlockHeight.toString()); + logCommand( + `✓ ${this.operator.label} Ӿ ${this.stacker.label}`, + "delegate-stack-stx", + "lock-amount", + this.amountUstx.toString(), + "until", + this.stacker.unlockHeight.toString(), + ); } toString() { diff --git a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStxCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStxCommand.ts index bc638719fd..3fbf131a62 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_DelegateStxCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_DelegateStxCommand.ts @@ -1,11 +1,17 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { poxAddressToTuple } from "@stacks/stacking"; import { expect } from "vitest"; import { boolCV, Cl } from "@stacks/transactions"; /** - * The `DelegateStxCommand` delegates STX for stacking within PoX-4. This operation - * allows the `tx-sender` (the `wallet` in this case) to delegate stacking participation + * The `DelegateStxCommand` delegates STX for stacking within PoX-4. This operation + * allows the `tx-sender` (the `wallet` in this case) to delegate stacking participation * to a `delegatee`. * * Constraints for running this command include: @@ -50,7 +56,7 @@ export class DelegateStxCommand implements PoxCommand { run(model: Stub, real: Real): void { // The amount of uSTX delegated by the Stacker to the Delegatee. - // Even if there are no constraints about the delegated amount, + // Even if there are no constraints about the delegated amount, // it will be checked in the future, when calling delegate-stack-stx. const amountUstx = Number(this.amount); @@ -83,12 +89,19 @@ export class DelegateStxCommand implements PoxCommand { wallet.hasDelegated = true; wallet.delegatedTo = this.delegateTo.stxAddress; wallet.delegatedMaxAmount = amountUstx; - wallet.delegatedUntilBurnHt = this.untilBurnHt + wallet.delegatedUntilBurnHt = this.untilBurnHt; delegatedWallet.hasPoolMembers.push(wallet.stxAddress); // 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}`, "delegate-stx", "amount", amountUstx.toString(), "delegated to", this.delegateTo.label); + logCommand( + `✓ ${this.wallet.label}`, + "delegate-stx", + "amount", + amountUstx.toString(), + "delegated to", + this.delegateTo.label, + ); } toString() { diff --git a/contrib/core-contract-tests/tests/pox-4/pox_GetStackingMinimumCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_GetStackingMinimumCommand.ts index 78b084f910..6e3ca20b43 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_GetStackingMinimumCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_GetStackingMinimumCommand.ts @@ -1,4 +1,10 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { assert } from "vitest"; import { ClarityType, isClarityType } from "@stacks/transactions"; @@ -42,7 +48,12 @@ export class GetStackingMinimumCommand implements PoxCommand { // 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}`, "get-stacking-minimum", "pox-4", stackingMinimum.value.toString()); + logCommand( + `✓ ${this.wallet.label}`, + "get-stacking-minimum", + "pox-4", + stackingMinimum.value.toString(), + ); } toString() { 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 b67079f404..ac5a482b85 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_GetStxAccountCommand.ts @@ -1,4 +1,10 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { expect } from "vitest"; import { Cl } from "@stacks/transactions"; @@ -35,7 +41,16 @@ export class GetStxAccountCommand implements PoxCommand { // 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}`, "stx-account", "lock-amount", actual.amountLocked.toString(), "unlocked-amount", actual.amountUnlocked.toString(), "unlocked-height", actual.unlockHeight.toString()); + logCommand( + `✓ ${this.wallet.label}`, + "stx-account", + "lock-amount", + actual.amountLocked.toString(), + "unlocked-amount", + actual.amountUnlocked.toString(), + "unlocked-height", + actual.unlockHeight.toString(), + ); } toString() { diff --git a/contrib/core-contract-tests/tests/pox-4/pox_RevokeDelegateStxCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_RevokeDelegateStxCommand.ts index c121146130..ecd9ddfec6 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_RevokeDelegateStxCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_RevokeDelegateStxCommand.ts @@ -1,4 +1,10 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { poxAddressToTuple } from "@stacks/stacking"; import { expect } from "vitest"; import { Cl, someCV, tupleCV } from "@stacks/transactions"; diff --git a/contrib/core-contract-tests/tests/pox-4/pox_StackStxCommand.ts b/contrib/core-contract-tests/tests/pox-4/pox_StackStxCommand.ts index 765441a68f..66557bd473 100644 --- a/contrib/core-contract-tests/tests/pox-4/pox_StackStxCommand.ts +++ b/contrib/core-contract-tests/tests/pox-4/pox_StackStxCommand.ts @@ -1,4 +1,10 @@ -import { PoxCommand, Real, Stub, Wallet, logCommand } from "./pox_CommandModel.ts"; +import { + logCommand, + PoxCommand, + Real, + Stub, + Wallet, +} from "./pox_CommandModel.ts"; import { Pox4SignatureTopic, poxAddressToTuple } from "@stacks/stacking"; import { assert, expect } from "vitest"; import { Cl, ClarityType, isClarityType } from "@stacks/transactions"; @@ -155,7 +161,12 @@ export class StackStxCommand implements PoxCommand { // 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}`, "stack-stx", "lock-amount", amountUstx.toString()); + logCommand( + `✓ ${this.wallet.label}`, + "stack-stx", + "lock-amount", + amountUstx.toString(), + ); } toString() {