Expose property-based testing helpers as public API#249
Conversation
|
@moodmosaic @hugo-stacks @wileyj If you have bandwidth, this is a pretty small PR that should have a high effect in sustaining Clarity property-based testing efforts. |
friedger
left a comment
There was a problem hiding this comment.
Looks good, nice addition!
moodmosaic
left a comment
There was a problem hiding this comment.
@BowTiedRadone shouldn't the CLI consume lib.ts as well?
|
@moodmosaic Thought about it initially, but the CLI and Two blockers:
Making the CLI use |
|
Can you either:
Option 1 is strongly preferred: it guarantees the library API stays honest by construction, and it's the clearest signal that the maintainers trust their own public surface.
I'd actually read this as an argument for the CLI consuming lib.ts. Batch orchestration is a natural layer above a single-function primitive, and the re-read-per-call cost is a caching concern inside getContractFunction rather than a reason for two parallel code paths.
I don't think it has to be that binary. The shape I'd reach for is: lib.ts exposes pure primitives → CLI imports those and layers logging, batching, and discard semantics on top. Nothing CLI-specific needs to migrate into lib.ts.
That's a presentation concern, not an architectural one: the raw form can be surfaced via an optional return shape or debug hook, and different logging shouldn't justify a forked generation pipeline. To be clear: I don't want to hold or block this PR — these are just my thoughts since I was pinged in as a reviewer, and you all are closer to the day-to-day tradeoffs than I am now. |
6c8ce7d to
86a9110
Compare
`strategyFor` now accepts optional `allAddresses` and `projectTraitImplementations` parameters. When omitted it still derives both from the simnet, preserving the default API. Callers that already hold a filtered account list or a precomputed trait map can pass them through to avoid redundant work and, more importantly, to honor user-supplied account filtering.
86a9110 to
e693249
Compare
|
@moodmosaic Checked again and your suggestion proved to be the most friendly in the eventuality we decide to support additional features such as customizable generators, etc. Now CLI uses |
Clarity smart contracts benefit from property-based testing, but setting up
fast-checkarbitraries that produce valid Clarity values for every parameter type (uint, principal, buffers, lists, tuples, optionals, responses, trait references) is tedious and error-prone. Rendezvous already solves this internally; this PR exposes that capability as a library API so the community can use it off-the-shelf.Two new exports:
getContractFunction(simnet, contract, fn, deployer?): extracts a function interface from a deployed contract, enriched with trait datagenerateArgs(simnet, fn): returnsfc.Arbitrary<ClarityValue[]>, handling all Clarity types including recursive structures (list of tuples, optional of response, etc.) and trait reference resolutionThe package now works as both a CLI (
npx rv) and a library (import { generateArgs } from "@stacks/rendezvous"). TypeScript declarations are included.Fixes #168.