Comprehensive test suite detalization synchronized with /simulator/tests.js
- Total Tests: 56
- Purpose: Formal verification of TMCTOL mathematical guarantees, component behavior, and emergent properties
- Methodology: Mathematical Foundations → Core Components → Integration Flows → System Properties → Economic Security
- Architecture Symmetry: Tests mirror TMCTOL system architecture for progressive comprehension
Core mathematical formulas and computational correctness.
- Nature: Direct formula validation against specification
- Necessity: Confirms
price = initial_price + slope × supply / PRECISIONholds exactly - Validates: Linear price progression, zero-supply initial price, correct dimensional scaling
- Failure Criteria: Price calculation deviates from formula by >1 wei
- Nature: Calculus-based mint amount verification
- Necessity: Proves integral-based token calculation matches theoretical quadratic formula
- Validates:
mint = payment / avg_pricewhereavg_price = (price_before + price_after) / 2 - Failure Criteria: Mint amount error >0.01% from theoretical integral
- Nature: Tests perfect linear scaling property for specific parameter configurations
- Necessity: Validates that when
price_initial = PRECISION/Nandslope = PRECISION/N, the system exhibits ideal linear behavior where doubling supply approximately doubles price - Validates: Price ratio equals supply ratio within 1% tolerance for linear function
P(S) = (PRECISION + S) / N; system maintains linear scaling across multiple supply points; linear approximation holds whenS >> PRECISION - Failure Criteria: Price doubling ratio deviates >1% from supply doubling ratio; non-linear behavior in linear parameter configuration
- Key Insight: Perfect linearity emerges when initial price and slope share identical scaling factors, enabling predictable price progression
- Nature: Degenerate case where
slope = 0 - Necessity: Confirms system degrades gracefully to fixed-price model
- Validates: Price independence from supply when slope disabled
Parameter boundaries, scaling rules, and precision validation.
- Nature: Tests
price_initialfrom 1 wei to millions - Necessity: Ensures system stability across entire economic range
- Validates: Minimum (1 wei), fractional (0.000001), standard (1.0), extreme (1M+)
- Nature: Tests
slopefrom 0 to extreme values with PRECISION scaling - Necessity: Confirms pricing model works for flat, gentle, and aggressive slopes
- Validates: Zero (constant), minimal (0.000001), standard (0.001), high (0.1), extreme (1.0+)
- Nature: Tests behavior from zero to billions of tokens
- Necessity: Proves formula stability under hyperscale token economies
- Validates: Empty state, small (1K), medium (1M), large (1B+)
- Nature: Tests near uint256 maximum values
- Necessity: Prevents overflow vulnerabilities in production
- Validates: 128-bit operations, maximum safe minting amounts
- Nature: Tests extreme parameter pairings
- Necessity: Reveals edge cases invisible in isolated testing
- Validates: Low price + high slope, high price + zero slope, etc.
- Nature: Smoke test for production configuration
- Necessity: Ensures DEFAULT_CONFIG represents sane, tested values
- Validates: All defaults produce mathematically valid system state
Precision model verification and scaling rule consistency.
- Nature: Structural test for scaling convention adherence
- Necessity: Enforces self-documenting code pattern
- Validates: Fractional values (fees, shares) use
_ppbsuffix; slope uses PRECISION scaling without suffix
- Nature: Confirms inputs arrive scaled to correct units
- Necessity: Prevents double-scaling bugs
- Validates: Price and slope use PRECISION; amounts use PRECISION; percentages (fees, shares) use PPB
- Nature: Validates price and slope dimensional consistency
- Necessity: Ensures all price-related calculations maintain [Foreign/Native] × PRECISION scaling
- Validates: Price formula P(s) = P₀ + slope·s/PRECISION produces consistent units
- Nature: Validates PPB values sum to 1,000,000,000 (100%)
- Necessity: Prevents distribution math errors
- Validates: Share allocation totals exactly 100%
- Nature: Tests precision loss through calculation chains
- Necessity: Quantifies rounding error accumulation
- Validates: Errors remain within acceptable tolerance (<0.01%)
- Nature: Property-based validation of price/slope scaling
- Necessity: Ensures exact adherence to dimensional scaling across randomized inputs
- Validates:
P(S) = P₀ + m·S/PRECISIONholds exactly; price remains non-negative; inputs conform to PRECISION/PPB domains - Failure Criteria: Any deviation from the formula; negative price; unit-inconsistent results
Isolated validation of individual system components in architectural order.
- Nature: Tests system factory and component wiring
- Necessity: Confirms dependency injection creates valid state
- Validates: All components initialized, cross-references correct
- Nature: Tests token creation and share allocation
- Necessity: Proves distribution percentages match configuration
- Validates: User/TOL shares exact (33.3%/66.7%), supply increases correctly, TOL manages 4 internal buckets
- Nature: Tests automatic liquidity provision via Zap
- Necessity: Confirms TOL accumulation mechanism functions
- Validates: LP tokens minted, reserves increased, ratios preserved
- Nature: Tests constant-product AMM formula
- Necessity: Validates
x × y = kinvariant preservation - Validates: Swap calculations, fee collection, reserve updates
- Nature: Validates constant-product
x × y = kunder multiple sequential swaps - Necessity: Ensures invariant stability under repeated activity; guards against pathological drift
- Validates:
kis non-decreasing within fee/rounding tolerance on each step; reserves remain strictly positive
- Nature: Tests fee calculation and tracking for native-to-foreign swaps
- Necessity: Validates that foreign_xyk_fee is correctly computed and returned
- Validates: Fee field returned in swap result, fee is non-negative, fee equals zero when fee_ppb is 0
- Key Insight: Separate fee fields (foreign_xyk_fee vs native_xyk_fee) preserve currency information for monitoring and analytics
- Nature: Tests TMC vs XYK price comparison logic
- Necessity: Ensures users always receive optimal price
- Validates: Cheaper path chosen, tie-breaking to TMC
- Nature: Tests token destruction and supply reduction
- Necessity: Confirms deflationary mechanics work correctly
- Validates: Supply decreases, price calculated before burn
Multi-component workflows and system-level behavior validation.
- Nature: Tests degenerate inputs and empty states
- Necessity: Prevents division-by-zero and null-pointer equivalents
- Validates: Zero amounts, empty pools, first mint handled gracefully
- Nature: Complete user journey: mint → swap → burn
- Necessity: Reveals interaction bugs invisible in unit tests
- Validates: End-to-end flow produces consistent state
- Failure Criteria: State inconsistency, balance mismatch, or operation failure
- Nature: Tests near-maximum uint256 operations
- Necessity: Critical for preventing financial exploits
- Validates: Safe multiplication, no silent overflows
- Failure Criteria: Overflow occurs or result wraps around
- Nature: Identifies practical parameter boundaries
- Necessity: Establishes production deployment guidelines
- Validates: Conservative/moderate/aggressive configs all safe
- Nature: Benchmarks quadratic formula execution time
- Necessity: Ensures on-chain feasibility (gas costs)
- Validates: Sub-millisecond performance at scale
Validation of system invariants and participant class integration with core tokenomics. Actual distribution is User + TOL (with 4 internal buckets).
- Nature: Economic correctness verification across multiple minting operations
- Necessity: Validates exact distribution percentages (33.3% user, 66.7% TOL) hold over time
- Validates: TOL receives precise allocation through
receive_mint_allocation()and distributes to 4 internal buckets (50%, 16.67%, 16.67%, 16.67%); distribution ratios remain constant regardless of mint count; rounding errors remain within tolerance (<1%) - Failure Criteria: Distribution ratio deviates >1% from configured shares; accumulation mechanism fails; TOL bucket balances incorrect
- Nature: Fundamental conservation law for token supply
- Necessity: Proves tokens cannot be created or destroyed outside designed mechanisms (minting, TOL lock)
- Validates: Total supply exactly equals user balances + TOL reserves (across all 4 buckets); no tokens lost to rounding; supply tracking remains consistent across all operations
- Failure Criteria: Supply mismatch >1 wei; tokens disappear or appear unexpectedly; balance sum ≠ total supply
- Nature: Security property ensuring TOL permanence
- Necessity: Confirms TOL liquidity remains locked regardless of participant trading activity
- Validates: User sales only affect XYK reserves, not TOL LP tokens; TOL balance strictly non-decreasing (only increases on new mints); each of 4 TOL buckets maintains independent LP balances
- Failure Criteria: TOL LP balance decreases; user sales affect TOL allocation; TOL buckets become accessible to users
Complex economic behaviors and advanced component interactions.
- Nature: Tests round-trip swap profitability
- Necessity: Proves system resistant to risk-free arbitrage
- Validates: Fees prevent circular profit, price convergence observed
- Additional Check: Anti-Arbitrage Cycle — repeated deterministic foreign→native→foreign cycles (e.g., 10 iterations) must be non-profitable; starting capital is non-increasing across cycles.
- Nature: Tests trade size restrictions
- Necessity: Prevents dust attacks and spam
- Validates: Sub-minimum trades rejected, error messages clear
- Nature: Tests
min_outputparameter enforcement - Necessity: Protects users from front-running attacks
- Validates: Insufficient output reverts transaction
- Nature: Tests TOL accumulation when pool doesn't exist
- Necessity: Ensures smooth cold-start without liquidity
- Validates: Buffer holds tokens, flushes on pool creation
- Nature: Tests fee accumulation and threshold-based burning
- Necessity: Confirms deflationary mechanism activates correctly
- Validates: Fees buffered, burned when threshold reached
- Nature: Tests rounding remainder allocation to TOL
- Necessity: Prevents dust loss from fractional PPB in 2-way split (user 33.3% + TOL 66.7%)
- Validates: Total distributed matches minted exactly
Mathematical guarantees and system-level properties that must never break.
- Nature: Tests conservation laws after 1000+ operations
- Necessity: Proves system stability under production load
- Validates:
- Total supply = sum of all balances
- XYK invariant
konly increases (fees) - TOL never decreases (locked forever)
- Price boundaries hold (floor ≤ market ≤ ceiling)
- Nature: Proves users receive more tokens via TMC than XYK
- Necessity: Validates "protocol arbitrage, not user taxation" claim
- Validates: TMC allocation > hypothetical XYK allocation for same payment
- Nature: Validates the physical derivation of the floor price
- Necessity: Proves the
$P_{floor} = k/(R+S)^2$ law holds in simulation - Validates:
- Calculated spot price matches theoretical floor after simulated dump
- Floor/Ceiling ratio aligns with
$1/(1+s/a)^2$ approximation
Emergent behavior from concurrent interactions and chaos testing.
- Nature: Simulates 100 random users, 500+ operations
- Necessity: Reveals emergent properties invisible in isolated tests
- Validates:
- Conservation laws under chaos
- Price ratchet acceleration (floor rises)
- Deflation acceleration (burning compounds)
- System stability (no deadlocks/livelocks)
- Failure Criteria: Conservation error >0.01%, TOL balance reduction, XYK constant k decreases, system deadlock
- Key Insight: Multi-user flows expose state interactions that unit tests cannot predict.
- Nature: Tests system stability under extreme operational load (500+ rapid operations)
- Necessity: Validates system resilience and invariant preservation during high-frequency trading
- Validates:
- Supply remains positive under extreme load
- Pool maintains liquidity during rapid operations
- K invariant remains positive and only increases (fees accumulate)
- Fee system processes transactions under load
- Total supply equals sum of all mints plus TOL allocation (mass conservation)
- Failure Criteria: System deadlock, invariant violation, liquidity depletion, fee processing failure
- Key Insight: Extreme load testing reveals performance bottlenecks and state management issues invisible under normal conditions.
Tests for system behaviors that emerge from component interactions and intelligent system responses.
- Nature: Critical TOL accumulation threshold validation
- Necessity: Identifies the point where system transitions from fragile to stable
- Validates: System achieves stability when TOL value exceeds ~15% of market capitalization
- Failure Criteria: System remains unstable despite significant TOL accumulation
- Nature: Tests the counterintuitive property where increasing supply raises minimum price
- Necessity: Validates TMCTOL's unique economic behavior that inverts traditional supply-demand dynamics
- Validates: After critical supply level, floor price increases despite supply expansion
- Failure Criteria: Traditional supply-demand relationship persists (more supply → lower price)
- Nature: Tests mathematical lock-in of large holder tokens during convergence
- Necessity: Confirms price impact creates natural exit difficulty
- Validates: Large holder tokens (e.g., 10%+ of supply) become mathematically difficult to exit when floor approaches ceiling
- Failure Criteria: Large holders can exit significant positions without severe price impact during convergence
- Nature: Tests self-reinforcing cycle where TMC mints degrade XYK prices
- Necessity: Validates router fee effectiveness in preventing infinite mint avalanches
- Validates: Router fees (0.5%) create sufficient friction to limit consecutive TMC routes
- Failure Criteria: Unlimited consecutive TMC routes create price manipulation vulnerability
- Nature: Tests that equilibrium price scales as √slope, not linearly
- Necessity: Validates diminishing returns from slope parameter increases
- Validates: 10x slope increase gives ~3.16x equilibrium price (√10), 100x slope gives ~10x price (√100)
- Failure Criteria: Linear scaling observed (10x slope gives 10x price)
Validation of system security against economic attack vectors with realistic scenarios and economic resilience.
- Nature: Tests that router fees make sandwich attacks economically inefficient through fee extraction
- Necessity: Validates that 0.5% router fee per swap creates sufficient friction to deter profitable MEV extraction
- Validates: Total fees exceed 0.8% of attack capital for round-trip; attacker profit margin minimal (<0.1%); TOL accumulation continues during attack scenarios
- Failure Criteria: Fees insufficient to deter attacks; attacker achieves significant profit; TOL accumulation disrupted
- Nature: Tests realistic governance attack where malicious proposal changes distribution shares to extract value
- Necessity: Confirms that mathematical floor guarantee persists even under extreme governance manipulation
- Validates: Floor guarantee maintains despite extreme governance scenarios; TOL continues accumulating across all 4 buckets; large holder extraction faces severe price impact (>100% of TOL reserves); XYK invariant maintains liquidity guarantee
- Failure Criteria: Floor guarantee compromised; large holders can extract value without severe price impact; TOL accumulation stops
- Nature: Tests that each chain maintains floor guarantee during bridge failure with realistic price divergence
- Necessity: Validates independent economic security of each chain when cross-chain communication is disrupted
- Validates: Each chain maintains positive floor price; TOL distribution prevents single-chain dominance (>70% threshold); no arbitrage opportunities without bridge functionality; sustainable TOL-to-supply ratio (>5%) per chain
- Failure Criteria: Single chain dominates TOL; arbitrage possible without bridge; chain loses floor guarantee
- Nature: Tests TMCTOL's capital efficiency advantage over traditional treasury models through continuous liquidity deployment cycles
- Necessity: Validates that ~100% capital utilization (with temporary buffers recycled into subsequent mints) provides price floor protection, value accrual, and resilience vs 0% traditional treasury
- Validates: ~100% capital utilization through deployment cycles (vs 0% traditional idle treasury) with temporary buffers for Zap operations; mathematical price floor protection (11-25% range); value accrual through XYK participation (quadratic growth capture); 50%+ resilience to strategic spending while maintaining protection
- Failure Criteria: Capital utilization significantly below 100%; floor protection fails; value accrual mechanism broken; spending eliminates protection
Validation of adaptive system behaviors, intelligent routing decisions, and economic incentive alignment.
- Nature: Tests the simultaneous compression of price range from both directions
- Necessity: Validates that burning reduces ceiling while TOL accumulation raises floor, creating convergence
- Validates: Price range narrows after token burning; ceiling decreases while floor increases or remains stable; compression accelerates with continued burning
- Failure Criteria: Price range expands after burning; ceiling increases; floor decreases
- Nature: Tests router's ability to select optimal TMC route when XYK lacks liquidity
- Necessity: Ensures users receive best available price by defaulting to TMC when XYK is unavailable
- Validates: Router chooses TMC route when XYK pool has no liquidity; TMC route provides positive output; system handles initial mint correctly
- Failure Criteria: Router fails to select TMC when XYK unavailable; zero output from TMC route
- Nature: Tests router's ability to select optimal XYK route when established liquidity exists
- Necessity: Ensures users benefit from established liquidity pools when available
- Validates: Router chooses XYK route when pool has sufficient liquidity; XYK provides better price than TMC in established state; router correctly compares TMC vs XYK prices
- Failure Criteria: Router selects TMC when XYK provides better price; incorrect price comparison
- Nature: Tests that system rewards beneficial behaviors and penalizes harmful ones
- Necessity: Validates economic incentives align with system stability and long-term holding
- Validates: Arbitrage unprofitable due to router fees; long-term holding more profitable than active trading; system penalizes manipulation attempts; TOL accumulation continues during all activities
- Failure Criteria: Arbitrage profitable; trading more profitable than holding; manipulation rewarded
node ./simulator/tests.js- Expected Output: Minimal statistics, error codes only for failures
- Tolerance: ~0.01% for emergent behaviors (multi-step calculations)
- Coverage: 56 tests validating 12 system layers across 1973 lines
- Documentation Standard: Each test includes Nature/Necessity/Validates/Failure Criteria
- Add Test: Update both
tests.jsimplementation and thistests.mddocumentation with all four fields (Nature/Necessity/Validates/Failure Criteria) - Modify Test: Sync all four fields to match new behavior
- Remove Test: Delete from both files, update test count in overview
- Refactor: Maintain test ID stability for historical comparison
- Mathematical Foundations: 4 tests for core formulas
- System Parameters: 6 tests for boundaries and extremes
- Scaling Rules: 6 tests for precision and consistency
- Core Components: 8 tests for isolated component behavior
- Integration Flows: 5 tests for multi-component workflows
- System Invariants: 3 tests for conservation laws
- Advanced Scenarios: 6 tests for complex behaviors
- System Properties: 3 tests for mathematical guarantees
- Multi-User Testing: 2 tests for chaos and concurrency
- Emergent Properties: 5 tests for system behavior analysis
- Economic Security: 4 tests for attack resistance and capital efficiency (continuous deployment vs idle vaults)
- Adaptive System Behaviors: 4 tests for intelligent system responses
- Philosophy: Tests prove specifications; specifications guide implementation; implementation validates mathematics.
- Each test has a hierarchical code based on its section and position, mapping to TMCTOL architecture:
1.1-1.4: Mathematical Foundations (Core Formulas)2.1-2.6: System Parameters & Boundaries3.1-3.6: Scaling Rules & Precision4.1-4.8: Core Component Tests (TMC, XYK, Router, TOL)5.1-5.5: Integration & System Flows6.1-6.3: System Invariants & Multi-Actor7.1-7.6: Advanced Integration Scenarios8.1-8.3: System Properties & Invariants9.1-9.2: Multi-User & Chaos Testing10.1-10.5: Emergent Properties & System Intelligence11.1-11.4: Economic Security & Attack Resistance12.1-12.4: Adaptive System Behaviors
- Use these codes in error messages for quick reference to this documentation.