Files
consensus/engine/chain/ERROR_TESTS_SUMMARY.md
zeekay 1040a196dd docs: snowball → Quasar/Wave terminology (no code changes)
Follow-up docs cleanup from the snow-removal audit — these two files
still referenced 'snowball configuration' and 'Snowball' engine names
even though the consensus code itself is 100% Quasar family. Aligns
docs with the code.
2026-03-01 23:00:51 -08:00

3.1 KiB

Error Propagation Tests for Lux Consensus

Overview

Successfully ported error propagation tests from upstream chain consensus to Lux consensus engine.

Tests Implemented

Core Error Tests

  1. TestErrorOnAccept - Tests that errors during block acceptance are properly propagated
  2. TestErrorOnRejectSibling - Tests that errors during sibling rejection are properly propagated
  3. TestMetricsProcessingError - Tests that metric registration errors are handled properly
  4. TestErrorOnAddDecidedBlock - Tests that adding an already decided block results in error
  5. TestTransitiveRejectionError - Tests error propagation during transitive block rejection

Metrics Error Tests

  1. TestMetricsAcceptedError - Tests that accepted counter metric conflicts are handled
  2. TestMetricsRejectedError - Tests that rejected counter metric conflicts are handled

Graceful Failure Tests

  1. TestGracefulFailureHandling - Tests that the consensus engine handles failures gracefully
  2. TestMetricsAccuracyDuringErrors - Tests that metrics remain accurate even when errors occur

Implementation Details

Key Components

  • ErrorBlock - Test block implementation that can inject errors on Accept/Reject/Verify
  • Consensus - Simplified consensus engine for testing with proper error propagation
  • ConsensusContext - Context with Prometheus registerer for metrics testing
  • Parameters - Consensus parameters matching Quasar/Wave configuration

Adaptations from upstream

  1. Used Lux's bag.Bag from node/utils/bag instead of upstream's bag implementation
  2. Adapted to Lux's block interfaces in engine/chain/block
  3. Used Lux's test utilities from engine/chain/chaintest
  4. Fixed bag initialization issues (requires SetThreshold to avoid nil set bug)
  5. Used separate Prometheus registries per test to avoid metric conflicts

Test Results

All 9 error propagation tests pass successfully:

=== RUN   TestErrorOnAccept
--- PASS: TestErrorOnAccept (0.00s)
=== RUN   TestErrorOnRejectSibling
--- PASS: TestErrorOnRejectSibling (0.00s)
=== RUN   TestMetricsProcessingError
--- PASS: TestMetricsProcessingError (0.00s)
=== RUN   TestErrorOnAddDecidedBlock
--- PASS: TestErrorOnAddDecidedBlock (0.00s)
=== RUN   TestTransitiveRejectionError
--- PASS: TestTransitiveRejectionError (0.00s)
=== RUN   TestMetricsAcceptedError
--- PASS: TestMetricsAcceptedError (0.00s)
=== RUN   TestMetricsRejectedError
--- PASS: TestMetricsRejectedError (0.00s)
=== RUN   TestGracefulFailureHandling
--- PASS: TestGracefulFailureHandling (0.00s)
=== RUN   TestMetricsAccuracyDuringErrors
--- PASS: TestMetricsAccuracyDuringErrors (0.00s)

File Location

/Users/z/work/lux/consensus/engine/chain/error_propagation_test.go

Known Issues

  • The bag.Bag implementation has a bug where metThreshold set is not properly initialized when threshold is 0
  • Worked around by setting threshold to 2 before adding elements
  • This should be fixed in the bag implementation itself

Future Work

  • Consider fixing the bag initialization bug in /Users/z/work/lux/node/utils/bag/bag.go
  • Add more comprehensive error scenarios
  • Add benchmarks for error handling performance