Skip to content

test: add penalty transaction test - #172

Draft
ABallarini wants to merge 1 commit into
RGB-Tools:masterfrom
ABallarini:upstream-penalty-tx-tests
Draft

ABallarini wants to merge 1 commit into
RGB-Tools:masterfrom
ABallarini:upstream-penalty-tx-tests

Conversation

@ABallarini

@ABallarini ABallarini commented Sep 14, 2026

Copy link
Copy Markdown

Summary

Adds a deterministic integration test (src/test/penalty_transaction.rs) that verifies protocol penalty behavior when a node broadcasts a revoked commitment state (per BOLT 3 / BOLT 5).

High-Level Overview

  1. Setup & Channel Creation: Node A issues an RGB asset and opens a channel with Node B.
  2. State Transition: A sends a keysend payment to B (moving to State 2 and revoking State 1).
  3. Breach Simulation: Node A is rewound to a backup of State 1 and issues a forced channel closure on-chain.
  4. Justice & Consolidation: Node B detects the counterparty breach via ldk.log, constructs and mines a justice (penalty) transaction and processes the output consolidation sweep.
  5. Structural & Fee-Invariant Verification: Asserts exact spendable BTC balances (node2_btc_before + sweep_out) using structural transaction checks (1-in/1-out) and a bounded fee-sensitivity invariant (< 5_000 sats total fees).
  6. RGB Asset Verification & Known Issue: Asserts post-sweep spendable RGB asset balances on both nodes.

⚠️ ISSUE

  • RGB Asset Sweep Behavior (Assert RGB asset balances):
    There is currently an issue in the RGB asset assertion phase. While Node A correctly retains its uncommitted 400 RGB units (ISSUE_AMT - RGB_ON_NODE_A), the honest node (Node B) does not currently receive the 600 RGB units carried by the revoked to_local output upon sweeping but are burnt. The test framework currently flags this discrepancy during the asset balance assertion step.

📖 Specification & Step-by-Step Flow: View HackMD Specification

@ABallarini
ABallarini force-pushed the upstream-penalty-tx-tests branch from 8f6b8f0 to b3274eb Compare September 15, 2026 09:22
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