Skip to content

Commit 63f180e

Browse files
authored
Merge pull request #6321 from moodmosaic/sip31-prop-tests
SIP-031 stateful property tests
2 parents 4850f72 + 225d25b commit 63f180e

File tree

16 files changed

+926
-10
lines changed

16 files changed

+926
-10
lines changed

contrib/core-contract-tests/deployments/default.simnet-plan.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ genesis:
1212
address: ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5
1313
balance: "100000000000000"
1414
sbtc-balance: "1000000000"
15+
- name: wallet_10
16+
address: ST3FFKYTTB975A3JC3F99MM7TXZJ406R3GKE6JV56
17+
balance: "200000000000000"
18+
sbtc-balance: "1000000000"
1519
- name: wallet_2
1620
address: ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG
1721
balance: "100000000000000"

contrib/core-contract-tests/package-lock.json

Lines changed: 211 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/core-contract-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@clarigen/test": "2.1.3",
1717
"@hirosystems/clarinet-sdk": "2.16.0",
1818
"@stacks/clarunit": "0.0.1",
19+
"@stacks/rendezvous": "^0.7.4",
1920
"@stacks/stacking": "^6.13.2",
2021
"@stacks/transactions": "^6.13.0",
2122
"chokidar-cli": "^3.0.0",

contrib/core-contract-tests/settings/Devnet.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@ balance = 100_000_000_000_000
7171
# stx_address: STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6
7272
# btc_address: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d
7373

74+
[accounts.wallet_10]
75+
mnemonic = "kiss denial decade slide spawn medal twist lamp evidence economy torch alter witness paper rule snack cushion hill sugar fury public innocent almost divide"
76+
balance = 200_000_000_000_000
77+
# secret_key: 5b897659452b9f3642be69aee75dc3cc84b2386d55ece1312affdbb80a3b2a7d01
78+
# stx_address: ST3FFKYTTB975A3JC3F99MM7TXZJ406R3GKE6JV56
79+
# btc_address: n1qwmgbzf1YeHDW6cTxxEwuqnjbqauvKJ1

contrib/core-contract-tests/tests/pox-4/pox-4.prop.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { assert, describe, expect, it } from "vitest";
1313
import { createHash } from "crypto";
1414

1515
// Contract Consts
16-
const INITIAL_TOTAL_LIQ_SUPPLY = 1_000_000_000_000_000;
17-
const MIN_AMOUNT_USTX = 125_000_000_000n;
16+
const INITIAL_TOTAL_LIQ_SUPPLY = 1_200_000_000_000_000;
17+
const MIN_AMOUNT_USTX = 150_000_000_000n;
1818
const TESTNET_PREPARE_CYCLE_LENGTH = 50;
1919
const TESTNET_REWARD_CYCLE_LENGTH = 1050;
2020
const TESTNET_STACKING_THRESHOLD_25 = 8000;
@@ -53,6 +53,8 @@ const privateKeyMapping: {
5353
"6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01",
5454
STNHKEPYEPJ8ET55ZZ0M5A34J0R3N5FM2CMMMAZ6:
5555
"de433bdfa14ec43aa1098d5be594c8ffb20a31485ff9de2923b2689471c401b801",
56+
ST3FFKYTTB975A3JC3F99MM7TXZJ406R3GKE6JV56:
57+
'5b897659452b9f3642be69aee75dc3cc84b2386d55ece1312affdbb80a3b2a7d01',
5658
};
5759

5860
const sha256 = (data: Buffer): Buffer =>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import fc from "fast-check";
2+
import type { Model, Real } from "./types";
3+
import {
4+
calculateClaimable,
5+
getWalletNameByAddress,
6+
logCommand,
7+
trackCommandRun,
8+
} from "./utils";
9+
import { expect } from "vitest";
10+
import { txOk } from "@clarigen/test";
11+
12+
export const Claim = (accounts: Real["accounts"]) =>
13+
fc.record({
14+
sender: fc.constantFrom(
15+
...Object.values(accounts).map((x) => x.address),
16+
),
17+
}).map((r) => ({
18+
check: (model: Readonly<Model>) => {
19+
const claimable = calculateClaimable(model);
20+
return model.initialized === true && model.recipient === r.sender &&
21+
claimable > 0n;
22+
},
23+
run: (model: Model, real: Real) => {
24+
trackCommandRun(model, "claim");
25+
26+
const expectedClaim = calculateClaimable(model);
27+
const receipt = txOk(real.contracts.sip031.claim(), r.sender);
28+
expect(receipt.value).toBe(expectedClaim);
29+
30+
model.balance -= expectedClaim;
31+
model.totalClaimed += expectedClaim;
32+
33+
logCommand({
34+
sender: getWalletNameByAddress(r.sender),
35+
status: "ok",
36+
action: "claim",
37+
value: `amount ${expectedClaim}`,
38+
});
39+
},
40+
toString: () => `claim`,
41+
}));

0 commit comments

Comments
 (0)