Skip to content

Conversation

@BowTiedRadone
Copy link
Contributor

@BowTiedRadone BowTiedRadone commented Sep 9, 2025

This PR adds the stx-defi contract to the examples, along with corresponding unit tests and newly added Rendezvous tests that can find a bug inside the contract.

Updates:

  • example folder package.json, tsconfig.json, vitest.config.js turning the folder into a Clarinet project; this allows running simnet unit tests
  • example folder exclusion from Rendezvous tsconfig.json
  • updated the example dialers file extension to .cjs for compatibility with the current format of the example and the supported Node versions and all the references to this file

Resolves #171 as a side effect.

@BowTiedRadone BowTiedRadone marked this pull request as ready for review September 10, 2025 15:13
@BowTiedRadone BowTiedRadone requested a review from a team as a code owner September 10, 2025 15:14
@BowTiedRadone BowTiedRadone changed the title [DRAFT] Add new contract and tests to examples Add stx-defi contract and tests to examples Sep 10, 2025
@BowTiedRadone
Copy link
Contributor Author

BowTiedRadone commented Sep 10, 2025

As this PR is already fairly-sized, a follow-up PR is needed. It should contain:

  • docs update to reference the new dialers file here
  • docs update to use the latest version of the SIP-010 dialer here
  • docs update to include stx-defi unit tests vs Rendezvous testing example + updated commands given the new format of the example directory
  • a README inside the example Clarinet project (eventually pointing to docs)

@BowTiedRadone
Copy link
Contributor Author

BowTiedRadone commented Sep 11, 2025

@moodmosaic Interesting finding implementing this PR: after the example folder became a Clarinet project (having its own package.json, tsconfig.json, etc.), the example sip010.js dialers file is no longer compatible with Rendezvous when using Node 18. For this reason, I turned it into a .cjs file so Node knows it is a CommonJS file.

This means a user working with a basic Clarinet project and using Node 18 will not be able to easily use Rendezvous along with a js dialers file in the current setup.

Copy link
Collaborator

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stx-defi contract addition is a solid move — it nicely surfaces how a PoX-2-style bug can be caught with rendezvous mechanics. That’s exactly the kind of thing these examples should be doing.

But: the TypeScript unit tests in example/ feel out of place. They're not in the same testing idiom we use for stx-defi (no fast-check, lots of boilerplate), and they pull in a bunch of TS scaffolding that doesn’t align with the purpose of this folder(?)

Two options:

  • Drop the TS tests, and just document the behavior they demonstrate alongside the Clarity code.
  • Or, move them into a dedicated folder (name of that would be?) and rewrite to match the Clarity-from-TypeScript testing pattern (leaner, property-based, more focused).

As-is, they dilute more than they add.

@moodmosaic
Copy link
Collaborator

It's better if we add the stx-defi.clar in the example folder in this PR and move the TS/JS part to another PR. There we can write idiomatic, example-based and/or property-based tests using fast-check.

.
|-- example
|   |-- Clarinet.toml
|   |-- contracts
|   |   |-- KEEPME
|   |   |-- cargo.clar
|   |   |-- cargo.tests.clar
|   |   |-- counter.clar
|   |   |-- counter.tests.clar
|   |   |-- stx-defi.clar
|   |   |-- stx-defi.tests.clar
|   |-- settings
|   |   `-- Devnet.toml
|   |-- sip010.js
|   |-- README.md
|   `-- ... (Clarity-focused examples and docs)
|
|-- example-ts/
|   `-- ... (Clarinet project with tests using the contracts from
|           ../example/contracts if possible.)
|
`-- ...

@BowTiedRadone
Copy link
Contributor Author

BowTiedRadone commented Sep 15, 2025

It's better if we add the stx-defi.clar in the example folder in this PR and move the TS/JS part to another PR. There we can write idiomatic, example-based and/or property-based tests using fast-check.

.
|-- example
|   |-- Clarinet.toml
|   |-- contracts
|   |   |-- KEEPME
|   |   |-- cargo.clar
|   |   |-- cargo.tests.clar
|   |   |-- counter.clar
|   |   |-- counter.tests.clar
|   |   |-- stx-defi.clar
|   |   |-- stx-defi.tests.clar
|   |-- settings
|   |   `-- Devnet.toml
|   |-- sip010.js
|   |-- README.md
|   `-- ... (Clarity-focused examples and docs)
|
|-- example-ts/
|   `-- ... (Clarinet project with tests using the contracts from
|           ../example/contracts if possible.)
|
`-- ...

@moodmosaic This could end up hiding configuration issues. Since Rendezvous is designed to work with a Clarinet project, I can’t imagine a real use case where someone would use it outside of one. That’s what happened in #174 as well. Our example folder should match a real Clarinet project as closely as possible. Otherwise, users learning Rendezvous might get confused by an unusual folder structure.

@moodmosaic
Copy link
Collaborator

Yes, indeed. Perhaps all we need is a good README.md in the example directory, along with some TypeScript tests written in an idiomatic, property-based testing style.

Copy link
Collaborator

@moodmosaic moodmosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@BowTiedRadone BowTiedRadone merged commit f131fd9 into master Sep 17, 2025
41 of 43 checks passed
@BowTiedRadone BowTiedRadone deleted the example branch September 17, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase Jest timeout to prevent CI flakiness

3 participants