Skip to content

Test: add RAM-billing and KV API coverage tests#331

Open
heifner wants to merge 2 commits into
masterfrom
feature/ram-billing-tests-v2
Open

Test: add RAM-billing and KV API coverage tests#331
heifner wants to merge 2 commits into
masterfrom
feature/ram-billing-tests-v2

Conversation

@heifner
Copy link
Copy Markdown
Contributor

@heifner heifner commented May 12, 2026

Adds 38 BOOST_FIXTURE_TEST_CASE entries in kv_api_tests and 2
BOOST_AUTO_TEST_CASE entries (kv_roa_limit_enforcement,
privileged_kv_payer_bypass) in protocol_feature_tests covering
payer-change billing, erase refund attribution, secondary-index
billing, cross-account billing, read-only rejection, payer
authorization edge cases, notification billing, mixed-payer
transactions, ROA quota enforcement, privileged-sysio bypass,
key/value size boundaries, iterator invalidation under mutation,
and cross-contract secondary reads.

Test coverage

Category Tests What it validates
Payer change billing 4 Correct refund/charge on payer change (same size, grow, shrink, back-to-self)
Erase refund 1 Refunds stored payer, not receiver
Secondary index billing 4 Correct amounts for idx store/remove/update
Cross-account idx billing 3 Idx bills payer (not contract), refunds correctly
Read-only rejection 4 erase, idx_store/remove/update blocked (table_operation_not_permitted)
Payer auth edge cases 3 Old payer unauth ok, missing auth fails, active-only (no sysio.payer) fails
Notification billing 2 Self-pay ok, third-party blocked in notify
Mixed-payer 2 Independent deltas, net zero
ROA limit 1 Quota exceeded -> ram_usage_exceeded
Privileged bypass 1 sysio.* bypasses payer auth, non-sysio.* does not
Key/value boundaries 6 Max and oversize on both create and update
Iterator invalidation 6 Primary + secondary mutation during iteration
Cross-contract reads 1 Secondary index read via kv_idx_primary_key + kv_get across contracts

Cherry-pick of 3579049 adapted to master's kv host API.

Adds 38 new kv_api_tests cases and 2 new protocol_feature_tests
cases covering payer-change billing, erase refund payer
attribution, secondary-index billing, cross-account billing,
read-only rejection, payer authorization edge cases, notification
billing, mixed-payer transactions, ROA quota enforcement,
privileged-sysio bypass, key/value size boundaries, iterator
invalidation under mutation, and cross-contract secondary reads.

Adaptations vs the abandoned feature/kv-secondary-primary-id base:
drop the index_id argument from kv_idx_* calls (master collapsed
table+index_id into uint32_t table_id), replace name-literal table
ids with uint32_t constants (300-305), rename contract-side
key_format -> test_table_id, restore the no-arg
kv_billing_tester::get_ram_usage() overload, qualify
read_only_rejects_kv_* tests with the kv_api_tester::t reference,
and bump the new protocol_feature_tests ROA budgets from 0.0941
to 0.0986 SYS to match master's other tests in this file.
The new RAM-billing actions added in 2612345 grew
test_kv_api.wasm enough that the kv_idx_payer_billing test's
1.1000 SYS contract-account budget (1145144 bytes) no longer
fits the contract on set_code (needs ~1170000 bytes after the
10x setcode multiplier).  Bump to 1.2000 SYS.
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