Skip to content

test(claims_settlement): add 82 unit tests for batch settlement [T12]#6327

Open
waefrebeorn wants to merge 46 commits into
Scottcjn:mainfrom
waefrebeorn:test-claims-settlement
Open

test(claims_settlement): add 82 unit tests for batch settlement [T12]#6327
waefrebeorn wants to merge 46 commits into
Scottcjn:mainfrom
waefrebeorn:test-claims-settlement

Conversation

@waefrebeorn
Copy link
Copy Markdown

Summary

Adds 82 unit tests for node/claims_settlement.py (961 lines, HIGH criticality), completing test coverage for all 22 public functions and classes.

Coverage

Category Functions Tested Test Count
Exceptions SettlementError, InsufficientFundsError, TransactionFailedError 3
Helpers _normalize_claim_limit 7
Queries get_pending_claims, get_verifying_claims 8
Pool operations check_rewards_pool_balance, reserve_rewards_pool_funds, release_rewards_pool_funds 13
Transaction construct_settlement_transaction, calculate_settlement_fee 8
Signing sign_and_broadcast_transaction 4
Status updates update_claims_settled, update_claims_failed 7
Batch ID generate_batch_id 6
Stats get_settlement_stats 6
Conditions settlement_batch_conditions_met 6
Orchestration process_claims_batch 12
End-to-end full_batch_cycle, multiple_batches 2

All 82 tests pass. Existing 12 reservation tests also pass (94 total).

RTC Wallet for bounty: RTC17c0d21f04f6f65c1a85c0aeb5d4a305d57531096

BCOS-L2: test_coverage

Adds max_length parameter to _clean_string_field and caps all user input
fields in POST route handlers:

- /lock: sender_wallet(128), target_wallet(128), tx_hash(128), receipt_signature(256)
- /confirm: proof_ref(256), notes(1024)
- /release: release_tx(128), notes(1024)

Prevents storage of arbitrarily large strings in bridge_ledger DB.
…s + Row M error handling + Row T test gaps + Row E infrastructure
…debase scan

- Vaulted: A1-A14, B1-B5, C1-C16, D1, A15-A41, S1-S19, M1-M9 (47 PRs)
- Added Row F (Form-not-function): 85 stub/form gaps from codebase scan
- Added Row T (Test coverage): 85 untested files mapped
- Added Rows M, S, D, E, H for remaining 72 cells
- README: added bounty badge + Bounty Bug Hunt section
- Total target: 400 cells (103 vaulted + 297 active)
F6: bare 'except Exception: pass' in inline query miners handler
F7: bare 'except Exception: pass' in inline query epoch handler

Both now log a warning with exc_info=True so silent failures
are observable without changing the fallthrough behaviour.

Also:
- Mark F3-F5 as FALSE POSITIVES (explorer-api pass is intentional,
  WalletCheckError exception class is standard Python)
- Update board: 107/400 cells vaulted, 49 PRs, 290 fresh gaps
…approvals (113/400 cells, 55 PRs, 19 jaxint-approved)
…t [T12]

Covers all untested functions in node/claims_settlement.py (961 lines):
- Exception classes: SettlementError, InsufficientFundsError, TransactionFailedError
- _normalize_claim_limit: type coercion, negatives, defaults
- get_pending_claims: ordering, limits, empty, DB errors
- get_verifying_claims: stuck claims, filtering, DB errors
- check_rewards_pool_balance: sufficient/insufficient, no-table fallback, DB errors
- reserve_rewards_pool_funds: reservation, insufficient, exact, no-table, zero
- release_rewards_pool_funds: add back, zero/negative amounts, no-table, DB errors
- construct_settlement_transaction: single/multi claims, fees, timestamp
- calculate_settlement_fee: base, per-output, large batch
- sign_and_broadcast_transaction: deterministic hash, different inputs
- update_claims_settled: single/multi/nonexistent, DB errors
- update_claims_failed: status update, DB errors
- generate_batch_id: format, sequence increment, multi-day, auto-create table
- get_settlement_stats: empty DB, settled counts, mixed status, periods, success rates
- settlement_batch_conditions_met: empty, size, timeout, boundaries
- process_claims_batch: dry-run, no claims, batch-not-met, broadcast fail/exception,
  successful processing, stale verifying flags, dedup, negative max, batch ID
- End-to-end: full batch cycle, multiple batches over time
- Import fallback: check stubs exist

Existing test files (test_claims_settlement_batch_id.py + reservation.py)
cover concurrency safety and atomic reservation — this completes coverage
for all 22 public functions/classes in claims_settlement.py

82 tests, all passing alongside existing 12 reservation/batch-id tests
Total: 94 tests for claims_settlement.py
@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related api API endpoint related tests Test suite changes size/XL PR: 500+ lines labels May 25, 2026
waefrebeorn added a commit to waefrebeorn/Rustchain that referenced this pull request May 25, 2026
Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great work on this PR! The code looks clean and well-structured. Thanks for contributing to RustChain! 🦀

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

LGTM! Great work on this PR. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api API endpoint related BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation node Node server related size/XL PR: 500+ lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants