test(python/tvm): add unit tests for codecs/jetton.py#2349
Closed
0xAxiom wants to merge 1 commit into
Closed
Conversation
Add 27 unit tests for python/x402/x402/mechanisms/tvm/codecs/jetton.py — the only TVM codec source file without a dedicated test module. TestBuildJettonTransferBodyFields (11 tests): opcode stored as first 32 bits, amount stored as coins, destination address round-trip, no responseDestination stores None address, responseDestination stored, custom-payload bit is always 0, forwardTonAmount stored, zero accepted, negative raises ValueError, no forwardPayload stores two zero bits, forwardPayload stored as ref. TestBuildJettonTransferBody (3 tests): delegates amount+pay_to from requirements, amount coerced from string, returns Cell instance. TestParseJettonTransfer (13 tests): round-trip destination, amount, and forward_ton_amount extraction, source_wallet set to jetton_wallet arg, body_hash equals cell.hash, attached_ton_amount always 0, response destination None vs normalized, wrong opcode raises, custom_payload bit raises, null destination raises, forward_payload from ref vs slice. Full unit suite: 27 passed, 0 failed. ruff check + format clean. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
@0xAxiom is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python/x402/mechanisms/tvm/codecs/jetton.pyis the only TVM codec source file without a dedicated unit test module. This PR adds 27 unit tests covering all three public functions.Tests added
TestBuildJettonTransferBodyFields(11 tests)JETTON_TRANSFER_OPCODE = 0x0F8A7EA5)responseDestinationinextrastores None address slotresponseDestinationinextrastores and reads back normalizedforwardTonAmountstored as coinsforwardTonAmountacceptedforwardTonAmountraisesValueErrorforwardPayloadinextrastores two zero bits (Either Cell path)forwardPayload(base64 BoC) stored as a refTestBuildJettonTransferBody(3 tests)amountandpay_tofromPaymentRequirementsintCellinstanceTestParseJettonTransfer(13 tests)source_walletset tojetton_walletargumentbody_hashequalsbody.hashattached_ton_amountis always0(hardcoded)Nonewhen absentValueError(ERR_EXACT_TVM_INVALID_JETTON_TRANSFER)ValueErrorValueErrorTest plan
uv run pytest tests/unit/mechanisms/tvm/test_jetton.py— 27 passed, 0 failed, 0.08suv run ruff check tests/unit/mechanisms/tvm/test_jetton.py— cleanuv run ruff format --check tests/unit/mechanisms/tvm/test_jetton.py— already formatted🤖 Generated with Claude Code