Start a project and test it on a local chain¶
pyrxd new creates a small app with a working Glyph mint and a test that runs it on a
throwaway local Radiant chain. The test passes before you change anything, so you start
from green and keep it green.
Create the project¶
pyrxd new my-token-app
cd my-token-app
pip install -e ".[test]"
pyrxd regtest setup # once per machine: builds the node image (needs docker)
pytest
pyrxd new writes files and nothing else. It refuses a name that would shadow pyrxd, your
tests or a standard-library module, and it never writes into a directory that already has
files in it (--dir PATH picks another location).
What you get:
Path |
What it is |
|---|---|
|
Depends on the pyrxd series that generated it (for example |
|
|
|
One line that loads the |
|
Mints, then asks the node whether the reveal is mined and which output holds the new token. |
|
Runs the same three steps on every push. |
The test fixtures¶
pyrxd.testing.pytest_plugin is opt-in. Load it in any project’s conftest.py:
pytest_plugins = ["pyrxd.testing.pytest_plugin"]
Fixture |
Scope |
Gives you |
|---|---|---|
|
session |
A fresh |
|
test |
A client with |
|
test |
A new key funded with 10 RXD. It works anywhere |
|
test |
|
The session shares one chain, and every test gets its own wallet. The keys are generated by pyrxd, not by the node’s wallet, so funding one test can never spend another test’s coins.
The node runs at mainnet’s relay floor, and pyrxd.testing refuses to hand back a node that
enforces anything lower, so a transaction your test gets mined also clears mainnet’s fee
floor.
If docker or the node image is missing, the fixtures fail the test with the command that fixes it. They do not skip, because a skipped chain test reports green.
The helpers under the fixtures (start_test_node, RegtestClient, RegtestWallet) are in
pyrxd.testing and do not need pytest, so a script or notebook can use them too.
Make the template from code¶
pyrxd.starter.render_project(name) returns the project as {path: text} without touching
disk, and write_project(name, directory) writes it. Both take overrides={path: text} to
replace a file, such as src/<package>/mint.py, with your own code. Override text is written
as given.
Moving off regtest¶
Everything above runs on regtest, whose coins are worthless. For mainnet, pass mint_nft an
ElectrumXClient and an HdWallet instead of the regtest pair, and read
Troubleshoot common errors first. A test that passes on regtest
shows the transaction is valid and clears the fee floor. It says nothing about the security of
your keys or your app.