Skip to content

test: Trace NFT fields in host_functions_test - #290

Open
sappenin wants to merge 4 commits into
mainfrom
feat/58-trace-nft-fields
Open

sappenin wants to merge 4 commits into
mainfrom
feat/58-trace-nft-fields

Conversation

@sappenin

Copy link
Copy Markdown
Collaborator

High Level Overview of Change

Extend e2e-tests/host_functions_test so it mints a real NFToken and traces every typed NFToken getter (flags, transfer_fee, issuer, taxon, token_sequence, uri) instead of probing nft_uri with a dummy all-zero ID.

Fixes #58.

Context of Change

#58 asked for e2e coverage that proves the stdlib NFT field accessors work against a real host. A dedicated trace_* crate would have duplicated host_functions_test; this PR folds that coverage into the existing probe and has runTest.js mint a token with known flags, taxon, transfer fee, and URI, then pass the ID in an EscrowFinish memo (StandardBlob).

Value assertions run only on wasm, because native coverage still uses empty host stubs.

Type of Change

  • Tests (added tests for existing code, or tests for the new feature in this PR)

Test Plan

  • cargo clippy --manifest-path e2e-tests/Cargo.toml -p host_functions_test --target wasm32v1-none -- -Dclippy::all
  • cargo test --manifest-path e2e-tests/Cargo.toml -p host_functions_test --lib
  • cargo build --manifest-path e2e-tests/Cargo.toml -p host_functions_test --target wasm32v1-none --release
  • ./scripts/run-tests.sh e2e-tests/host_functions_test (needs a rippled node; local ws://127.0.0.1:6006 was not running when this was written)

Mint a real NFToken and exercise the typed getters instead of probing nft_uri with a dummy ID.

Fixes #58.
@sappenin sappenin self-assigned this Aug 27, 2026
@sappenin
sappenin requested review from mvadari and pwang200 and removed request for mvadari August 27, 2026 22:35
@sappenin sappenin added this to the v1.0.0 milestone Aug 27, 2026
@sappenin
sappenin marked this pull request as ready for review August 27, 2026 22:35
@mvadari

mvadari commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

/ai-reviewer --adopt

@ripple-code-reviewer

Copy link
Copy Markdown

Repository ripple/xrpl-wasm-stdlib has been adopted for auto-reviews by @mvadari.

Three examples (nft_owner, atomic_swap1, freelancer_escrow) each
hand-rolled the same unsafe Locator/tx_inner call to read
Memos[0].MemoData. Add a first_memo_data() convenience on
TransactionCommonFields that returns the TxPathBuilder pre-positioned
at that path, and switch the examples to it. Update the
xrpl-smart-escrows skill reference docs to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@ripple-code-reviewer ripple-code-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid refactor that replaces the dummy-NFT nft_uri probe with real typed NFToken field coverage minted by runTest.js, and cleans up several examples/docs to use the new first_memo_data() helper consistently. One correctness concern: the wasm-only URI value assertion slices uri.data with a fixed-length index that could panic (trap) if the underlying URI buffer is shorter than the expected 38-byte URI, rather than failing gracefully with the existing -632 error code.

sappenin and others added 2 commits November 2, 2026 13:14
Resolve e2e-tests/host_functions_test/runTest.js by keeping main's
finishEscrow/expectResult harness helpers and passing the PR's NFT-id
Memo through the options bag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Compare the trailing-zero-trimmed slice against the full expected URI
instead of indexing with a fixed 38-byte range, so a shorter buffer
returns the -632 error code rather than trapping.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@ripple-code-reviewer ripple-code-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found.

This branch has not been deployed

No deployments
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.

Add e2e-test contract that traces all NFT fields

3 participants