Repository navigation
Conversation
`import_contract!` bakes a real on-chain address into a contract, and nothing lives at that address in a sandboxed test `Env`. Add `stellar_registry::testutils::register_import!` (behind a new `testutils` feature), which resolves a name through the same code as `import_contract!` and registers the imported Wasm, or a native mock, at that address with `Env::register_at`. Stellar Asset Contracts are a compile error for now. The new `hello_caller` fixture imports `hello_v1` and tests itself with `register_import!`. It is excluded from the workspace, since it needs seeded cache files to compile; `just test-register-import` seeds them and runs it offline, and CI runs that recipe. Part of #65 Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
The fixture sits outside the workspace, so it does not pick up the workspace's soroban-sdk bump. Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
I have been thinking about this for hours and I still haven't finished reading it all but it's time to give you my first wall of thoughts!!! 😂 😖 🙇🏼 🙇🏼 🙇🏼
(Take this as a good thing! You came up with an interesting solution to a problem I hadn't yet really thought through and it spurred some ideas!!)
Also, as always, I'm open to pushback on any of this! We don't have to do it the ways I'm contemplating, or we do not need to do them right now. Maybe it's fine to do an initial fast release with a cleanup update later.
Co-authored-by: Chad Ostrowski <[email protected]>
Co-Authored-By: Claude <[email protected]>
`args = { admin, quorum: 7u32 }` passes constructor arguments by name.
The macro reads the constructor's parameters from the imported Wasm's
spec, orders the values to match, and calls the typed
`Args::__constructor` that `contractimport!` generates, so names and
types are checked at compile time. Leaving out `args` when the
constructor takes parameters is a compile error listing them. The tuple
form still works and is type-checked too.
Co-Authored-By: Claude <[email protected]>
Resolve the Cargo.lock conflict from main's dependency bumps. main moved stellar-xdr to 30 while soroban-spec 28 uses stellar-xdr 28, so read only the raw spec section with soroban-spec and parse it with this crate's stellar-xdr. Co-Authored-By: Claude <[email protected]>
The new `unverified_caller` fixture imports `unverified`, the root registry's subregistry on testnet, and tests itself with `register_import!` and named constructor args. `just test-register-import-testnet` runs it with `STELLAR_NETWORK=testnet`, so the id and Wasm are really fetched. It needs network access, so CI doesn't run it. Co-Authored-By: Claude <[email protected]>
Drop its committed Cargo.lock (it only runs manually, online) and trim its comments. Co-Authored-By: Claude <[email protected]>
`unverified` is the subregistry itself; `unverified/my-token` is an ordinary registered contract, and its five-argument constructor exercises named args more fully. Co-Authored-By: Claude <[email protected]>
|
Ok, I've resolved all the comments. I added typed args, but the I also added a recipe for testing through a contract build on testnet, alas that adds another fixture so that I can import that specific contract (alternatively, we could deploy hello_v1 or a different fixture to testnet ... but unverified/token is from the oz-wasms and I thought it fit well). The perk of adding the fixture is that it shows the full example within the repo of how you'd use import_contract and then use register_contract, which I think was what you were aiming for. I like the token one too because it does have a handful of args, so it showcases the typed args well. |
Main now derives asset-syntax SAC addresses at runtime, so resolve() returns a new Resolved::Asset carrying the asset XDR instead of a build-time address. register_import! rejects it like any other SAC, and its expansion now tracks the network env so it re-expands alongside import_contract! when the network changes. Co-Authored-By: Claude <[email protected]>
Part of #65
Adds
register_import!(behind a newtestutilsfeature onstellar-registry), a test helper for contracts that useimport_contract!.import_contract!bakes the imported contract's on-chain address in at build time, so a unit test'sEnvhas nothing at that address.register_import!resolves the name the same way and registers the contract there, so contract code needs no#[cfg(test)]switch around the import.SAC names are a compile error for now; support follows in #82. The
hello_callerfixture is excluded from the workspace because it can't compile without seeded cache files;just test-register-importseeds them and runs it in CI.