Skip to content

Currency — InternalTruth Tests

These tests live under:

Assets/RevFramework/Tests/EditMode/Currency/InternalTruth/

They are Editor-only (EditMode) tests that intentionally verify the current implementation truth of the Currency system.

These tests do not define public guarantees. They exist to document, lock down, and make visible behaviour that is real, but not promised.


Purpose

InternalTruth tests answer a different question from Hostile tests:

“What does the Currency system actually do today, even if that behaviour is not public API?”

They exist to: - Prevent accidental semantic drift during refactors - Make hidden or implicit behaviour explicit - Support confident internal change without guessing

If an InternalTruth test breaks, it does not automatically mean a bug was introduced. It may simply mean the implementation changed — and the test (or documentation) must be updated accordingly.


Rules (explicitly different from Hostile)

InternalTruth tests may:

  • ✅ Use System.Reflection
  • ✅ Access private fields and internal methods
  • ✅ Walk decorator chains
  • ✅ Depend on internal helper utilities

InternalTruth tests must not:

  • ❌ Be referenced by Hostile tests
  • ❌ Be treated as public guarantees
  • ❌ Be used to justify behaviour in user-facing documentation without promotion

If a behaviour here becomes something you want to guarantee, it should be: 1. Promoted to Hostile 2. Documented as a contract


What these tests cover

Policy preview vs commit semantics

CurrencyPolicyPreviewTests

These tests reflect the internal method:

CurrencyTxn.TryPreview(...)

They prove:

  • Preview matches commit when only caps apply
  • Preview intentionally ignores:
  • Authority gating
  • RequireEscrow enforcement
  • Idempotency replay semantics

These tests explicitly document that preview ≠ commit in many real stacks.

This prevents preview from being accidentally treated as a guarantee or simulation of reality.


Audit visibility through decorator chains

CurrencyAuditDecoratorChainTests

These tests: - Walk the decorator chain via private fields - Prove that audit exists even when not forwarded publicly - Show where audit is intentionally hidden (eg. behind Escrow)

This behaviour is real, but not guaranteed — so it lives here.


Internal policy authoring helpers

CurrencyPolicyTestBuilder

A reflection-based helper used only by InternalTruth tests to:

  • Write to private serialized fields on CurrencyPolicy
  • Force internal cache rebuilds
  • Construct deterministic policy scenarios

This helper exists only to support InternalTruth tests. It must never be referenced from Hostile tests.


Relationship to Hostile tests

The separation is intentional:

Hostile InternalTruth
Public guarantees Implementation truth
No reflection Reflection allowed
Stable across refactors Expected to break during refactors
User-facing contract Developer-facing safety net

If you find yourself wanting to rely on an InternalTruth assertion in downstream code, that is a signal that:

  • The behaviour should be promoted to Hostile or
  • The downstream code is depending on something it shouldn’t

If an InternalTruth test fails

Before changing anything, ask:

  1. Did the implementation intentionally change?
  2. Is the observed behaviour still desirable?
  3. Should this behaviour remain undocumented, or be promoted to a contract?

Then:

  • Update the test to reflect the new truth or
  • Refactor the implementation to restore the old truth or
  • Promote the behaviour to Hostile and document it properly

InternalTruth tests exist to make these decisions explicit, not accidental.