Skip to content

feat: add register_import! for testing import_contract! callers - #77

Open
pselle wants to merge 3 commits into
mainfrom
feat/register-import
Open

pselle wants to merge 3 commits into
mainfrom
feat/register-import

Conversation

@pselle

@pselle pselle commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Part of #65

Adds register_import! (behind a new testutils feature on stellar-registry), a test helper for contracts that use import_contract!.

import_contract! bakes the imported contract's on-chain address in at build time, so a unit test's Env has 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.

use stellar_registry::testutils::register_import;

register_import!(&env, our_dao);                           // the imported Wasm
register_import!(&env, our_dao, args = (&admin, 7u32));    // with constructor args
register_import!(&env, our_dao, contract = MockDao);       // a native mock instead

SAC names are a compile error for now; support follows in #82. The hello_caller fixture is excluded from the workspace because it can't compile without seeded cache files; just test-register-import seeds them and runs it in CI.

`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 <noreply@anthropic.com>
@pselle pselle self-assigned this Oct 13, 2026
pselle and others added 2 commits October 13, 2026 14:10
Co-Authored-By: Claude <noreply@anthropic.com>
The fixture sits outside the workspace, so it does not pick up the
workspace's soroban-sdk bump.

Co-Authored-By: Claude <noreply@anthropic.com>
@pselle
pselle marked this pull request as ready for review October 14, 2026 01:18
@pselle
pselle requested a review from chadoh October 14, 2026 01:21
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.

1 participant