mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
chore: move boot contracts unit tests in their own directory
This commit is contained in:
13
contrib/boot-contracts-unit-tests/.gitignore
vendored
Normal file
13
contrib/boot-contracts-unit-tests/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
**/settings/Mainnet.toml
|
||||
**/settings/Testnet.toml
|
||||
.cache/**
|
||||
history.txt
|
||||
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
coverage
|
||||
*.info
|
||||
costs-reports.json
|
||||
node_modules
|
||||
4
contrib/boot-contracts-unit-tests/.vscode/settings.json
vendored
Normal file
4
contrib/boot-contracts-unit-tests/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
{
|
||||
"files.eol": "\n"
|
||||
}
|
||||
19
contrib/boot-contracts-unit-tests/.vscode/tasks.json
vendored
Normal file
19
contrib/boot-contracts-unit-tests/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "check contracts",
|
||||
"group": "test",
|
||||
"type": "shell",
|
||||
"command": "clarinet check"
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "test",
|
||||
"group": "test",
|
||||
"problemMatcher": [],
|
||||
"label": "npm test"
|
||||
}
|
||||
]
|
||||
}
|
||||
25
contrib/boot-contracts-unit-tests/Clarinet.toml
Normal file
25
contrib/boot-contracts-unit-tests/Clarinet.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[project]
|
||||
name = 'boot-contracts-unit-tests'
|
||||
description = ''
|
||||
authors = []
|
||||
telemetry = false
|
||||
cache_dir = './.cache'
|
||||
requirements = []
|
||||
|
||||
[contracts.indirect]
|
||||
path = 'contracts/indirect.clar'
|
||||
clarity_version = 2
|
||||
epoch = 2.4
|
||||
|
||||
[repl]
|
||||
clarity_wasm_mode = false
|
||||
show_timings = false
|
||||
|
||||
[repl.analysis]
|
||||
passes = ['check_checker']
|
||||
|
||||
[repl.analysis.check_checker]
|
||||
strict = false
|
||||
trusted_sender = false
|
||||
trusted_caller = false
|
||||
callee_filter = false
|
||||
24
contrib/boot-contracts-unit-tests/README.md
Normal file
24
contrib/boot-contracts-unit-tests/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Boot contracts unit tests
|
||||
|
||||
Run unit tests with clarinet on boot contracts.
|
||||
|
||||
Contracts tests:
|
||||
|
||||
- [x] pox-4.clar
|
||||
|
||||
|
||||
## About boot contract unit testing with Clarinet
|
||||
|
||||
- To really test contracts such as the pox contracts, we need to test the boot contracts embedded
|
||||
into Clarinet. For example `ST000000000000000000002AMW42H.pox-4.clar`
|
||||
- This mean that calling this contract will interact
|
||||
- Since the boot contracts are embedded into Clarinet, we only test the version of the contract
|
||||
that is in Clarinet, and not the ones that actually live in the stacks-core repository.
|
||||
|
||||
We are able to get the boot contracts coverage thanks to this settings in `vitest.config.js`:
|
||||
```js
|
||||
includeBootContracts: true,
|
||||
bootContractsPath: `${process.cwd()}/boot_contracts`,
|
||||
```
|
||||
A copy of the tested boot contracts is includedin this directory as well so that we are able to
|
||||
compute and render the code coverage.
|
||||
@@ -562,7 +562,7 @@
|
||||
;; * The Stacker will receive rewards in the reward cycle following `start-burn-ht`.
|
||||
;; Importantly, `start-burn-ht` may not be further into the future than the next reward cycle,
|
||||
;; and in most cases should be set to the current burn block height.
|
||||
;;
|
||||
;;
|
||||
;; To ensure that the Stacker is authorized to use the provided `signer-key`, the stacker
|
||||
;; must provide either a signature have an authorization already saved. Refer to
|
||||
;; `verify-signer-key-sig` for more information.
|
||||
@@ -716,7 +716,7 @@
|
||||
;; the lock period are inflexible, which means that the stacker must confirm their transaction
|
||||
;; during the exact reward cycle and with the exact period that the signature or authorization was
|
||||
;; generated for.
|
||||
;;
|
||||
;;
|
||||
;; The `amount` field is checked to ensure it is not larger than `max-amount`, which is
|
||||
;; a field in the authorization. `auth-id` is a random uint to prevent authorization
|
||||
;; replays.
|
||||
@@ -728,7 +728,7 @@
|
||||
;; When `signer-sig` is present, the public key is recovered from the signature
|
||||
;; and compared to `signer-key`. If `signer-sig` is `none`, the function verifies that an authorization was previously
|
||||
;; added for this key.
|
||||
;;
|
||||
;;
|
||||
;; This function checks to ensure that the authorization hasn't been used yet, but it
|
||||
;; does _not_ store the authorization as used. The function `consume-signer-key-authorization`
|
||||
;; handles that, and this read-only function is exposed for client-side verification.
|
||||
@@ -1082,10 +1082,10 @@
|
||||
;; *New in Stacks 2.1*
|
||||
;; This method locks up an additional amount of STX from `tx-sender`'s, indicated
|
||||
;; by `increase-by`. The `tx-sender` must already be Stacking & must not be
|
||||
;; straddling more than one signer-key for the cycles effected.
|
||||
;; straddling more than one signer-key for the cycles effected.
|
||||
;; Refer to `verify-signer-key-sig` for more information on the authorization parameters
|
||||
;; included here.
|
||||
(define-public (stack-increase
|
||||
(define-public (stack-increase
|
||||
(increase-by uint)
|
||||
(signer-sig (optional (buff 65)))
|
||||
(signer-key (buff 33))
|
||||
@@ -1144,7 +1144,7 @@
|
||||
;; This method extends the `tx-sender`'s current lockup for an additional `extend-count`
|
||||
;; and associates `pox-addr` with the rewards, The `signer-key` will be the key
|
||||
;; used for signing. The `tx-sender` can thus decide to change the key when extending.
|
||||
;;
|
||||
;;
|
||||
;; Because no additional STX are locked in this function, the `amount` field used
|
||||
;; to verify the signer key authorization is zero. Refer to `verify-signer-key-sig` for more information.
|
||||
(define-public (stack-extend (extend-count uint)
|
||||
@@ -0,0 +1,57 @@
|
||||
---
|
||||
id: 0
|
||||
name: "Simulated deployment, used as a default for `clarinet console`, `clarinet test` and `clarinet check`"
|
||||
network: simnet
|
||||
genesis:
|
||||
wallets:
|
||||
- name: deployer
|
||||
address: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
|
||||
balance: "100000000000000"
|
||||
- name: faucet
|
||||
address: STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6
|
||||
balance: "100000000000000"
|
||||
- name: wallet_1
|
||||
address: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
|
||||
balance: "100000000000000"
|
||||
- name: wallet_2
|
||||
address: ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
|
||||
balance: "100000000000000"
|
||||
- name: wallet_3
|
||||
address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC
|
||||
balance: "100000000000000"
|
||||
- name: wallet_4
|
||||
address: ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND
|
||||
balance: "100000000000000"
|
||||
- name: wallet_5
|
||||
address: ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB
|
||||
balance: "100000000000000"
|
||||
- name: wallet_6
|
||||
address: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0
|
||||
balance: "100000000000000"
|
||||
- name: wallet_7
|
||||
address: ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ
|
||||
balance: "100000000000000"
|
||||
- name: wallet_8
|
||||
address: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP
|
||||
balance: "100000000000000"
|
||||
contracts:
|
||||
- costs
|
||||
- pox
|
||||
- pox-2
|
||||
- pox-3
|
||||
- pox-4
|
||||
- lockup
|
||||
- costs-2
|
||||
- costs-3
|
||||
- cost-voting
|
||||
- bns
|
||||
plan:
|
||||
batches:
|
||||
- id: 0
|
||||
transactions:
|
||||
- emulated-contract-publish:
|
||||
contract-name: indirect
|
||||
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
|
||||
path: contracts/indirect.clar
|
||||
clarity-version: 2
|
||||
epoch: "2.4"
|
||||
2356
contrib/boot-contracts-unit-tests/package-lock.json
generated
Normal file
2356
contrib/boot-contracts-unit-tests/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
contrib/boot-contracts-unit-tests/package.json
Normal file
23
contrib/boot-contracts-unit-tests/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "boot-contracts-unit-tests-tests",
|
||||
"version": "1.0.0",
|
||||
"description": "Run unit tests on this project.",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"test:report": "vitest run -- --coverage --costs",
|
||||
"test:watch": "chokidar \"tests/**/*.ts\" \"contracts/**/*.clar\" -c \"npm run test:report\""
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@hirosystems/clarinet-sdk": "^2.5.0",
|
||||
"@stacks/transactions": "^6.13.0",
|
||||
"chokidar-cli": "^3.0.0",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.1.4",
|
||||
"vitest": "^1.3.1",
|
||||
"vitest-environment-clarinet": "^2.0.0"
|
||||
}
|
||||
}
|
||||
151
contrib/boot-contracts-unit-tests/settings/Devnet.toml
Normal file
151
contrib/boot-contracts-unit-tests/settings/Devnet.toml
Normal file
@@ -0,0 +1,151 @@
|
||||
[network]
|
||||
name = "devnet"
|
||||
deployment_fee_rate = 10
|
||||
|
||||
[accounts.deployer]
|
||||
mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 753b7cc01a1a2e86221266a154af739463fce51219d97e4f856cd7200c3bd2a601
|
||||
# stx_address: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
|
||||
# btc_address: mqVnk6NPRdhntvfm4hh9vvjiRkFDUuSYsH
|
||||
|
||||
[accounts.wallet_1]
|
||||
mnemonic = "sell invite acquire kitten bamboo drastic jelly vivid peace spawn twice guilt pave pen trash pretty park cube fragile unaware remain midnight betray rebuild"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 7287ba251d44a4d3fd9276c88ce34c5c52a038955511cccaf77e61068649c17801
|
||||
# stx_address: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
|
||||
# btc_address: mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC
|
||||
|
||||
[accounts.wallet_2]
|
||||
mnemonic = "hold excess usual excess ring elephant install account glad dry fragile donkey gaze humble truck breeze nation gasp vacuum limb head keep delay hospital"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 530d9f61984c888536871c6573073bdfc0058896dc1adfe9a6a10dfacadc209101
|
||||
# stx_address: ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
|
||||
# btc_address: muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG
|
||||
|
||||
[accounts.wallet_3]
|
||||
mnemonic = "cycle puppy glare enroll cost improve round trend wrist mushroom scorpion tower claim oppose clever elephant dinosaur eight problem before frozen dune wagon high"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: d655b2523bcd65e34889725c73064feb17ceb796831c0e111ba1a552b0f31b3901
|
||||
# stx_address: ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC
|
||||
# btc_address: mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7
|
||||
|
||||
[accounts.wallet_4]
|
||||
mnemonic = "board list obtain sugar hour worth raven scout denial thunder horse logic fury scorpion fold genuine phrase wealth news aim below celery when cabin"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: f9d7206a47f14d2870c163ebab4bf3e70d18f5d14ce1031f3902fbbc894fe4c701
|
||||
# stx_address: ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND
|
||||
# btc_address: mg1C76bNTutiCDV3t9nWhZs3Dc8LzUufj8
|
||||
|
||||
[accounts.wallet_5]
|
||||
mnemonic = "hurry aunt blame peanut heavy update captain human rice crime juice adult scale device promote vast project quiz unit note reform update climb purchase"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 3eccc5dac8056590432db6a35d52b9896876a3d5cbdea53b72400bc9c2099fe801
|
||||
# stx_address: ST2REHHS5J3CERCRBEPMGH7921Q6PYKAADT7JP2VB
|
||||
# btc_address: mweN5WVqadScHdA81aATSdcVr4B6dNokqx
|
||||
|
||||
[accounts.wallet_6]
|
||||
mnemonic = "area desk dutch sign gold cricket dawn toward giggle vibrant indoor bench warfare wagon number tiny universe sand talk dilemma pottery bone trap buddy"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01
|
||||
# stx_address: ST3AM1A56AK2C1XAFJ4115ZSV26EB49BVQ10MGCS0
|
||||
# btc_address: mzxXgV6e4BZSsz8zVHm3TmqbECt7mbuErt
|
||||
|
||||
[accounts.wallet_7]
|
||||
mnemonic = "prevent gallery kind limb income control noise together echo rival record wedding sense uncover school version force bleak nuclear include danger skirt enact arrow"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401
|
||||
# stx_address: ST3PF13W7Z0RRM42A8VZRVFQ75SV1K26RXEP8YGKJ
|
||||
# btc_address: n37mwmru2oaVosgfuvzBwgV2ysCQRrLko7
|
||||
|
||||
[accounts.wallet_8]
|
||||
mnemonic = "female adjust gallery certain visit token during great side clown fitness like hurt clip knife warm bench start reunion globe detail dream depend fortune"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: 6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01
|
||||
# stx_address: ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCP
|
||||
# btc_address: n2v875jbJ4RjBnTjgbfikDfnwsDV5iUByw
|
||||
|
||||
[accounts.faucet]
|
||||
mnemonic = "shadow private easily thought say logic fault paddle word top book during ignore notable orange flight clock image wealth health outside kitten belt reform"
|
||||
balance = 100_000_000_000_000
|
||||
# secret_key: de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801
|
||||
# stx_address: STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6
|
||||
# btc_address: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d
|
||||
|
||||
[devnet]
|
||||
disable_stacks_explorer = false
|
||||
disable_stacks_api = false
|
||||
# disable_subnet_api = false
|
||||
# disable_bitcoin_explorer = true
|
||||
# working_dir = "tmp/devnet"
|
||||
# stacks_node_events_observers = ["host.docker.internal:8002"]
|
||||
# miner_mnemonic = "fragile loan twenty basic net assault jazz absorb diet talk art shock innocent float punch travel gadget embrace caught blossom hockey surround initial reduce"
|
||||
# miner_derivation_path = "m/44'/5757'/0'/0/0"
|
||||
# faucet_mnemonic = "shadow private easily thought say logic fault paddle word top book during ignore notable orange flight clock image wealth health outside kitten belt reform"
|
||||
# faucet_derivation_path = "m/44'/5757'/0'/0/0"
|
||||
# orchestrator_port = 20445
|
||||
# bitcoin_node_p2p_port = 18444
|
||||
# bitcoin_node_rpc_port = 18443
|
||||
# bitcoin_node_username = "devnet"
|
||||
# bitcoin_node_password = "devnet"
|
||||
# bitcoin_controller_block_time = 30_000
|
||||
# stacks_node_rpc_port = 20443
|
||||
# stacks_node_p2p_port = 20444
|
||||
# stacks_api_port = 3999
|
||||
# stacks_api_events_port = 3700
|
||||
# bitcoin_explorer_port = 8001
|
||||
# stacks_explorer_port = 8000
|
||||
# postgres_port = 5432
|
||||
# postgres_username = "postgres"
|
||||
# postgres_password = "postgres"
|
||||
# postgres_database = "postgres"
|
||||
# bitcoin_node_image_url = "quay.io/hirosystems/bitcoind:26.0"
|
||||
# stacks_node_image_url = "quay.io/hirosystems/stacks-node:devnet-2.5"
|
||||
# stacks_signer_image_url = "quay.io/hirosystems/stacks-node:devnet-2.5"
|
||||
# stacks_api_image_url = "hirosystems/stacks-blockchain-api:master"
|
||||
# stacks_explorer_image_url = "hirosystems/explorer:latest"
|
||||
# bitcoin_explorer_image_url = "quay.io/hirosystems/bitcoin-explorer:devnet"
|
||||
# postgres_image_url = "postgres:alpine"
|
||||
# enable_subnet_node = true
|
||||
# subnet_node_image_url = "hirosystems/stacks-subnets:0.8.1"
|
||||
# subnet_leader_mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw"
|
||||
# subnet_leader_derivation_path = "m/44'/5757'/0'/0/0"
|
||||
# subnet_contract_id = "ST173JK7NZBA4BS05ZRATQH1K89YJMTGEH1Z5J52E.subnet-v3-0-1"
|
||||
# subnet_node_rpc_port = 30443
|
||||
# subnet_node_p2p_port = 30444
|
||||
# subnet_events_ingestion_port = 30445
|
||||
# subnet_node_events_observers = ["host.docker.internal:8002"]
|
||||
# subnet_api_image_url = "hirosystems/stacks-blockchain-api:master"
|
||||
# subnet_api_postgres_database = "subnet_api"
|
||||
|
||||
# For testing in epoch 2.1 / using Clarity2
|
||||
# epoch_2_0 = 100
|
||||
# epoch_2_05 = 100
|
||||
# epoch_2_1 = 101
|
||||
# epoch_2_2 = 102
|
||||
# epoch_2_3 = 103
|
||||
# epoch_2_4 = 104
|
||||
# epoch_2_5 = 108
|
||||
|
||||
|
||||
# Send some stacking orders
|
||||
[[devnet.pox_stacking_orders]]
|
||||
start_at_cycle = 1
|
||||
duration = 12
|
||||
wallet = "wallet_1"
|
||||
slots = 2
|
||||
btc_address = "mr1iPkD9N3RJZZxXRk7xF9d36gffa6exNC"
|
||||
|
||||
[[devnet.pox_stacking_orders]]
|
||||
start_at_cycle = 1
|
||||
duration = 12
|
||||
wallet = "wallet_2"
|
||||
slots = 1
|
||||
btc_address = "muYdXKmX9bByAueDe6KFfHd5Ff1gdN9ErG"
|
||||
|
||||
[[devnet.pox_stacking_orders]]
|
||||
start_at_cycle = 1
|
||||
duration = 12
|
||||
wallet = "wallet_3"
|
||||
slots = 1
|
||||
btc_address = "mvZtbibDAAA3WLpY7zXXFqRa3T4XSknBX7"
|
||||
@@ -159,10 +159,10 @@ export const stackStx = (
|
||||
) => {
|
||||
const rewardCycle = burnHeightToRewardCycle(startBurnHeight);
|
||||
const sigArgs = {
|
||||
authId,
|
||||
maxAmount,
|
||||
authId: authId,
|
||||
maxAmount: maxAmount,
|
||||
rewardCycle,
|
||||
period: lockPeriod,
|
||||
period: Number(lockPeriod),
|
||||
topic: Pox4SignatureTopic.StackStx,
|
||||
poxAddress: stacker.btcAddr,
|
||||
signerPrivateKey: stacker.signerPrivKey,
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
stackStx,
|
||||
stackers,
|
||||
} from "./helpers";
|
||||
import { bufferFromHex } from "@stacks/transactions/dist/cl";
|
||||
|
||||
const accounts = simnet.getAccounts();
|
||||
const deployer = accounts.get("deployer")!;
|
||||
@@ -255,7 +254,7 @@ describe("test `get-stacker-info`", () => {
|
||||
|
||||
it("returns info before stacked", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
let stackResponse = stackStx(
|
||||
stacker,
|
||||
amount,
|
||||
@@ -292,7 +291,7 @@ describe("test `get-stacker-info`", () => {
|
||||
|
||||
it("returns info while stacked", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
let stackResponse = stackStx(
|
||||
stacker,
|
||||
amount,
|
||||
@@ -330,7 +329,7 @@ describe("test `get-stacker-info`", () => {
|
||||
|
||||
it("returns none after stacking expired", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
let stackResponse = stackStx(
|
||||
stacker,
|
||||
amount,
|
||||
@@ -424,7 +423,7 @@ describe("test `get-reward-set-size`", () => {
|
||||
});
|
||||
|
||||
it("returns number of stackers", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
stackers.forEach((stacker) => {
|
||||
const { result } = stackStx(
|
||||
@@ -457,7 +456,7 @@ describe("test `get-reward-set-size`", () => {
|
||||
});
|
||||
|
||||
it("returns number of uniq pox address", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
stackers.forEach((_stacker) => {
|
||||
const stacker: StackerInfo = {
|
||||
@@ -498,7 +497,7 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
});
|
||||
|
||||
it("returns total amount stacked", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
stackers.forEach((stacker) => {
|
||||
const { result } = stackStx(
|
||||
@@ -519,11 +518,11 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
[Cl.uint(1)],
|
||||
address1
|
||||
);
|
||||
expect(responseCycle1.result).toBeUint(amount * 3);
|
||||
expect(responseCycle1.result).toBeUint(amount * 3n);
|
||||
});
|
||||
|
||||
it("returns 0 in the cycle before stacking starts", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
// stacking txs sent in cycle 0, so stackers will be start in cycle 1
|
||||
stackers.forEach((stacker) => {
|
||||
@@ -548,7 +547,7 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
});
|
||||
|
||||
it("returns total amount stacked", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
stackers.forEach((stacker) => {
|
||||
stackStx(
|
||||
@@ -568,11 +567,11 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
[Cl.uint(1)],
|
||||
address1
|
||||
);
|
||||
expect(response.result).toBeUint(amount * 3);
|
||||
expect(response.result).toBeUint(amount * 3n);
|
||||
});
|
||||
|
||||
it("expires stacking after the stacking duration has finsihed", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
stackers.forEach((stacker, i) => {
|
||||
const { result } = stackStx(
|
||||
@@ -594,7 +593,7 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
[Cl.uint(3)],
|
||||
address1
|
||||
);
|
||||
expect(responseCycle3.result).toBeUint(amount * 2);
|
||||
expect(responseCycle3.result).toBeUint(amount * 2n);
|
||||
|
||||
const responseCycle5 = simnet.callReadOnlyFn(
|
||||
POX_CONTRACT,
|
||||
@@ -602,7 +601,7 @@ describe("test `get-total-ustx-stacked`", () => {
|
||||
[Cl.uint(5)],
|
||||
address1
|
||||
);
|
||||
expect(responseCycle5.result).toBeUint(amount * 1);
|
||||
expect(responseCycle5.result).toBeUint(amount * 1n);
|
||||
|
||||
const responseCycle7 = simnet.callReadOnlyFn(
|
||||
POX_CONTRACT,
|
||||
@@ -626,7 +625,7 @@ describe("test `get-reward-set-pox-address`", () => {
|
||||
});
|
||||
|
||||
it("returns pox address for a stacker", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
stackers.forEach((stacker) => {
|
||||
stackStx(
|
||||
stacker,
|
||||
@@ -769,7 +768,7 @@ describe("test `check-pox-lock-period`", () => {
|
||||
describe("test `can-stack-stx` and `minimal-can-stack-stx`", () => {
|
||||
it("returns true for a valid stacker", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const canStackArgs = [
|
||||
poxAddressToTuple(stacker.btcAddr),
|
||||
Cl.uint(amount),
|
||||
@@ -788,7 +787,7 @@ describe("test `can-stack-stx` and `minimal-can-stack-stx`", () => {
|
||||
|
||||
it("returns error if amount is too low", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() / 2;
|
||||
const amount = getStackingMinimum() / 2n;
|
||||
const canStackArgs = [
|
||||
poxAddressToTuple(stacker.btcAddr),
|
||||
Cl.uint(amount),
|
||||
@@ -807,7 +806,7 @@ describe("test `can-stack-stx` and `minimal-can-stack-stx`", () => {
|
||||
|
||||
it("returns error if period is too low or to high", () => {
|
||||
const stacker = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const canStackArgsTooLow = [
|
||||
poxAddressToTuple(stacker.btcAddr),
|
||||
Cl.uint(amount),
|
||||
@@ -850,7 +849,7 @@ describe("test `can-stack-stx` and `minimal-can-stack-stx`", () => {
|
||||
),
|
||||
version: Cl.buffer(Buffer.from([7])),
|
||||
});
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const canStackArgs = [
|
||||
addressTupleWrongVersion,
|
||||
Cl.uint(amount),
|
||||
@@ -1036,8 +1035,8 @@ describe("test `minimal-can-stack-stx`", () => {
|
||||
describe("test `verify-signer-key-sig`", () => {
|
||||
it("returns `(ok true)` for a valid signature", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1075,8 +1074,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
|
||||
it("returns `(ok true)` for a valid prior authorization", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1121,7 +1120,7 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
it("returns an error if the amount is too high", () => {
|
||||
const account = stackers[0];
|
||||
const maxAmount = getStackingMinimum();
|
||||
const amount = maxAmount * 1.2;
|
||||
const amount = maxAmount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1161,8 +1160,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
|
||||
it("returns an error for a used authorization", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1217,8 +1216,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
|
||||
it("returns an error for an invalid signature", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1260,8 +1259,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
it("returns an error for a signature that does not match", () => {
|
||||
const account = stackers[0];
|
||||
const account2 = stackers[1];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1301,8 +1300,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
|
||||
it("returns an error if not signature is passed and there is no prior authorization", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1332,8 +1331,8 @@ describe("test `verify-signer-key-sig`", () => {
|
||||
describe("test `consume-signer-key-authorization`", () => {
|
||||
it("returns `(ok true)` for a valid signature", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1371,8 +1370,8 @@ describe("test `consume-signer-key-authorization`", () => {
|
||||
|
||||
it("returns an error for a used authorization", () => {
|
||||
const account = stackers[0];
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const maxAmount = amount * 2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
const maxAmount = amount * 2n;
|
||||
const poxAddr = poxAddressToTuple(account.btcAddr);
|
||||
const rewardCycle = 1;
|
||||
const period = 1;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assert, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { Cl, ResponseCV, UIntCV, cvToString } from "@stacks/transactions";
|
||||
import { Cl } from "@stacks/transactions";
|
||||
import { Pox4SignatureTopic, poxAddressToTuple } from "@stacks/stacking";
|
||||
import {
|
||||
ERRORS,
|
||||
@@ -9,9 +9,6 @@ import {
|
||||
delegateStackStx,
|
||||
delegateStx,
|
||||
getStackingMinimum,
|
||||
stackAggregationCommitIndexed,
|
||||
stackAggregationIncrease,
|
||||
stackStx,
|
||||
stackers,
|
||||
} from "./helpers";
|
||||
|
||||
@@ -24,7 +24,7 @@ beforeEach(() => {
|
||||
|
||||
describe("switching delegates`", () => {
|
||||
it("is allowed while stacked", () => {
|
||||
const amount = getStackingMinimum() * 1.2;
|
||||
const amount = getStackingMinimum() * 2n;
|
||||
|
||||
// Delegate to address2
|
||||
let delegateResponse = delegateStx(
|
||||
@@ -79,7 +79,7 @@ describe("switching delegates`", () => {
|
||||
|
||||
it("revoked delegate cannot extend or increase", () => {
|
||||
const stackingMinimum = getStackingMinimum();
|
||||
const amount = stackingMinimum * 1.2;
|
||||
const amount = stackingMinimum * 2n;
|
||||
|
||||
// Delegate to address2
|
||||
let delegateResponse = delegateStx(
|
||||
@@ -156,7 +156,7 @@ describe("switching delegates`", () => {
|
||||
|
||||
it("new delegate cannot lock before previous delegation unlocks", () => {
|
||||
const stackingMinimum = getStackingMinimum();
|
||||
const amount = stackingMinimum * 1.2;
|
||||
const amount = stackingMinimum * 2n;
|
||||
const poxInfo = getPoxInfo();
|
||||
let unlockHeight = poxInfo.rewardCycleLength * 3n;
|
||||
|
||||
@@ -229,7 +229,7 @@ describe("switching delegates`", () => {
|
||||
|
||||
delegateStackStxResponse = delegateStackStx(
|
||||
address1,
|
||||
stackingMinimum + 2,
|
||||
stackingMinimum + 2n,
|
||||
stackers[1].btcAddr,
|
||||
simnet.blockHeight,
|
||||
2,
|
||||
@@ -237,7 +237,7 @@ describe("switching delegates`", () => {
|
||||
);
|
||||
expect(delegateStackStxResponse.result).toBeOk(
|
||||
Cl.tuple({
|
||||
"lock-amount": Cl.uint(stackingMinimum + 2),
|
||||
"lock-amount": Cl.uint(stackingMinimum + 2n),
|
||||
stacker: Cl.principal(address1),
|
||||
"unlock-burn-height": Cl.uint(unlockHeight),
|
||||
})
|
||||
@@ -246,7 +246,7 @@ describe("switching delegates`", () => {
|
||||
|
||||
it("New delegate cannot extend or increase", () => {
|
||||
const stackingMinimum = getStackingMinimum();
|
||||
const amount = stackingMinimum * 1.2;
|
||||
const amount = stackingMinimum * 2n;
|
||||
|
||||
// Delegate to address2
|
||||
let delegateResponse = delegateStx(
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
stackStx,
|
||||
stackers,
|
||||
} from "./helpers";
|
||||
import { address } from "@stacks/transactions/dist/cl";
|
||||
|
||||
const accounts = simnet.getAccounts();
|
||||
const deployer = accounts.get("deployer")!;
|
||||
26
contrib/boot-contracts-unit-tests/tsconfig.json
Normal file
26
contrib/boot-contracts-unit-tests/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ESNext"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
|
||||
"strict": true,
|
||||
"noImplicitAny": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": [
|
||||
"node_modules/@hirosystems/clarinet-sdk/vitest-helpers/src",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
44
contrib/boot-contracts-unit-tests/vitest.config.js
Normal file
44
contrib/boot-contracts-unit-tests/vitest.config.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/// <reference types="vitest" />
|
||||
|
||||
import { defineConfig } from "vite";
|
||||
import {
|
||||
vitestSetupFilePath,
|
||||
getClarinetVitestsArgv,
|
||||
} from "@hirosystems/clarinet-sdk/vitest";
|
||||
|
||||
/*
|
||||
In this file, Vitest is configured so that it works seamlessly with Clarinet and the Simnet.
|
||||
|
||||
The `vitest-environment-clarinet` will initialise the clarinet-sdk
|
||||
and make the `simnet` object available globally in the test files.
|
||||
|
||||
`vitestSetupFilePath` points to a file in the `@hirosystems/clarinet-sdk` package that does two things:
|
||||
- run `before` hooks to initialize the simnet and `after` hooks to collect costs and coverage reports.
|
||||
- load custom vitest matchers to work with Clarity values (such as `expect(...).toBeUint()`)
|
||||
|
||||
The `getClarinetVitestsArgv()` will parse options passed to the command `vitest run --`
|
||||
- vitest run -- --manifest ./Clarinet.toml # pass a custom path
|
||||
- vitest run -- --coverage --costs # collect coverage and cost reports
|
||||
*/
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: "clarinet", // use vitest-environment-clarinet
|
||||
pool: "forks",
|
||||
poolOptions: {
|
||||
forks: { singleFork: true },
|
||||
},
|
||||
setupFiles: [
|
||||
vitestSetupFilePath,
|
||||
// custom setup files can be added here
|
||||
],
|
||||
environmentOptions: {
|
||||
clarinet: {
|
||||
...getClarinetVitestsArgv(),
|
||||
includeBootContracts: true,
|
||||
bootContractsPath: `${process.cwd()}/boot_contracts`,
|
||||
// add or override options
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -4,46 +4,41 @@ name = "core-contracts"
|
||||
[repl]
|
||||
costs_version = 1
|
||||
|
||||
# [contracts.bns]
|
||||
# path = "../../stackslib/src/chainstate/stacks/boot/bns.clar"
|
||||
# depends_on = []
|
||||
# epoch = 2.4
|
||||
[contracts.bns]
|
||||
path = "../../stackslib/src/chainstate/stacks/boot/bns.clar"
|
||||
depends_on = []
|
||||
epoch = 2.4
|
||||
|
||||
# [contracts.signers]
|
||||
# path = "../../stackslib/src/chainstate/stacks/boot/signers.clar"
|
||||
# depends_on = []
|
||||
# clarity = 2
|
||||
# epoch = 2.4
|
||||
[contracts.signers]
|
||||
path = "../../stackslib/src/chainstate/stacks/boot/signers.clar"
|
||||
depends_on = []
|
||||
clarity = 2
|
||||
epoch = 2.4
|
||||
|
||||
# [contracts.signers-voting]
|
||||
# path = "../../stackslib/src/chainstate/stacks/boot/signers-voting.clar"
|
||||
# depends_on = []
|
||||
# clarity = 2
|
||||
# epoch = 2.4
|
||||
[contracts.signers-voting]
|
||||
path = "../../stackslib/src/chainstate/stacks/boot/signers-voting.clar"
|
||||
depends_on = []
|
||||
clarity = 2
|
||||
epoch = 2.4
|
||||
|
||||
# [contracts.pox-4]
|
||||
# path = "../../stackslib/src/chainstate/stacks/boot/pox-4.clar"
|
||||
# clarity_version = 2
|
||||
# epoch = 2.4
|
||||
# depends_on = ["pox-mainnet"]
|
||||
|
||||
# [contracts.pox-mainnet]
|
||||
# path = "../../stackslib/src/chainstate/stacks/boot/pox-mainnet.clar"
|
||||
# clarity_version = 2
|
||||
# epoch = 2.4
|
||||
# depends_on = []
|
||||
|
||||
# [contracts.bns_test]
|
||||
# path = "./tests/bns_test.clar"
|
||||
# clarity_version = 2
|
||||
# epoch = 2.4
|
||||
|
||||
# [contracts.pox_4_test]
|
||||
# path = "./tests/pox_4_test.clar"
|
||||
# clarity_version = 2
|
||||
# epoch = 2.4
|
||||
|
||||
[contracts.indirect]
|
||||
path = './tests/pox-4-unit-tests/indirect.clar'
|
||||
[contracts.pox-4]
|
||||
path = "../../stackslib/src/chainstate/stacks/boot/pox-4.clar"
|
||||
clarity_version = 2
|
||||
epoch = 2.4
|
||||
depends_on = ["pox-mainnet"]
|
||||
|
||||
[contracts.pox-mainnet]
|
||||
path = "../../stackslib/src/chainstate/stacks/boot/pox-mainnet.clar"
|
||||
clarity_version = 2
|
||||
epoch = 2.4
|
||||
depends_on = []
|
||||
|
||||
[contracts.bns_test]
|
||||
path = "./tests/bns_test.clar"
|
||||
clarity_version = 2
|
||||
epoch = 2.4
|
||||
|
||||
[contracts.pox_4_test]
|
||||
path = "./tests/pox_4_test.clar"
|
||||
clarity_version = 2
|
||||
epoch = 2.4
|
||||
|
||||
@@ -36,8 +36,6 @@ export default defineConfig({
|
||||
environmentOptions: {
|
||||
clarinet: {
|
||||
...getClarinetVitestsArgv(),
|
||||
includeBootContracts: true,
|
||||
bootContractsPath: `${process.cwd()}/boot_contracts`,
|
||||
// add or override options
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user