Description
Every existing test in crates/wallet-core/src/signer.rs for sign_payment uses asset: None (native XLM). The Some((code, issuer)) branch — which validates the issuer via is_valid_account and builds the asset via Asset::new_credit — has no direct coverage at all, including its two distinct error paths (invalid issuer, invalid asset code rejected by stellar-base).
Requirements and Context
- Cover the happy path: signing a payment with a valid 4-char and a valid 12-char asset code against a valid issuer produces a valid envelope with the correct
Asset XDR variant (CreditAlphanum4 vs CreditAlphanum12).
- Cover
WalletError::InvalidAddress when the issuer string fails is_valid_account.
- Cover the case where
Asset::new_credit itself rejects the code (e.g. empty string, code longer than 12 chars, non-ASCII) and confirm it maps to WalletError::InvalidAddress, matching the existing .map_err(|_| WalletError::InvalidAddress) in signer.rs.
Suggested Execution
Branch: test/wallet-core/sign-payment-credit-asset
Implement Changes
- Add test cases to the existing
#[cfg(test)] mod tests block in crates/wallet-core/src/signer.rs, reusing sealed_vector_seed and DEST already defined there.
- Use a valid vector-derived issuer address (e.g.
DEST) for the credit-asset tests.
Test and Commit
signs_credit_asset_payment_alphanum4 — 3-4 char code, asserts the envelope's operation carries a CreditAlphanum4 asset.
signs_credit_asset_payment_alphanum12 — 5-12 char code, asserts CreditAlphanum12.
rejects_credit_asset_with_invalid_issuer — malformed issuer string -> WalletError::InvalidAddress.
rejects_credit_asset_with_invalid_code — empty or oversized code -> WalletError::InvalidAddress.
- Run
cargo test -p octo-wallet-core locally before committing.
Example Commit Message
test(wallet-core): cover the credit-asset branch of sign_payment
sign_payment's non-native asset path (issuer validation, asset-code length
class, and error mapping) had zero direct test coverage; only native XLM was
exercised. Adds happy-path and error-path cases for both alphanum4 and
alphanum12 codes.
Guidelines
- Do not change
sign_payment's behavior — this issue is test-only.
- Assert on the XDR operation's asset variant, not just that signing succeeded, so a future regression in asset-kind selection is caught.
- Reference this issue with
Closes #<issue-number> in the PR description.
Description
Every existing test in
crates/wallet-core/src/signer.rsforsign_paymentusesasset: None(native XLM). TheSome((code, issuer))branch — which validates the issuer viais_valid_accountand builds the asset viaAsset::new_credit— has no direct coverage at all, including its two distinct error paths (invalid issuer, invalid asset code rejected bystellar-base).Requirements and Context
AssetXDR variant (CreditAlphanum4vsCreditAlphanum12).WalletError::InvalidAddresswhen the issuer string failsis_valid_account.Asset::new_credititself rejects the code (e.g. empty string, code longer than 12 chars, non-ASCII) and confirm it maps toWalletError::InvalidAddress, matching the existing.map_err(|_| WalletError::InvalidAddress)insigner.rs.Suggested Execution
Branch:
test/wallet-core/sign-payment-credit-assetImplement Changes
#[cfg(test)] mod testsblock incrates/wallet-core/src/signer.rs, reusingsealed_vector_seedandDESTalready defined there.DEST) for the credit-asset tests.Test and Commit
signs_credit_asset_payment_alphanum4— 3-4 char code, asserts the envelope's operation carries aCreditAlphanum4asset.signs_credit_asset_payment_alphanum12— 5-12 char code, assertsCreditAlphanum12.rejects_credit_asset_with_invalid_issuer— malformed issuer string ->WalletError::InvalidAddress.rejects_credit_asset_with_invalid_code— empty or oversized code ->WalletError::InvalidAddress.cargo test -p octo-wallet-corelocally before committing.Example Commit Message
Guidelines
sign_payment's behavior — this issue is test-only.Closes #<issue-number>in the PR description.