Skip to content

fix(example): check the register_with manifest against the compiled macro keys #13

Description

@0dillon

Summary

register_with_presents_the_escrows_own_address asserts call.keys_xdr == keys, where keys is
the value the test itself passed in from its manifest() helper. The assertion compares
manifest() to manifest() and holds no matter what the contract's impl_maintainable! extends.

scripts/init_testnet.sh states in a comment that its manifest constants are "kept in step with the
contract by manifest() in examples/long_escrow/src/test.rs, which asserts against the same three
values." That safety net does not exist. If someone adds a key to the macro, every test still
passes and the published manifest silently goes stale — the exact drift the registry's
documentation warns about, manufactured by our own example.

Also worth fixing while here: register_with takes threshold and extend_to from the caller,
while extend_all uses the values compiled into the macro. The buyer can publish numbers that do
not match what the contract does.

Acceptance Criteria

  • A test derives the expected keys from the contract's actual maintenance behaviour rather than
    from the same constant it passes in — for example by extending TTLs through extend_all and
    checking which entries moved.
  • Adding or removing a key in the escrow's impl_maintainable! without updating the manifest
    fails the suite. Verify by making the change locally before submitting.
  • The comment in scripts/init_testnet.sh is either made true or corrected.
  • A decision is recorded on threshold and extend_to: either register_with stops taking
    them and uses the compiled values, or the rustdoc states plainly that the caller can publish
    values the contract does not honour.

Tech Stack

Rust (edition 2021, toolchain 1.93.0 pinned in rust-toolchain.toml), soroban-sdk 27.0.4,
target wasm32v1-none. Build with stellar contract build, never cargo build. Tests are
#[cfg(test)] modules on Env::default(); run them with cargo test --all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: exampleexamples/long_escrowcomplexity: mediumHalf a day, some design judgement neededtype: bugExisting behaviour is wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions