test(core): rust_decimal checked against exact rationals
The engine trusts Decimal for every money path, and docs/verification.md said so without checking it: Kani cannot explore Decimal arithmetic, and the bridge tests only tie the Decimal kernel to the i64 one. This adds a property test that compares the operations the books use against num-rational/num-bigint, an independent exact reference: checked_add and checked_sub over signed line amounts (1e15 at up to ten places), 1,000-line sums, checked_mul while the true product fits 28 digits (including the top of the line range and FX-style rates), round_dp_with_strategy for every strategy the workspace uses at every scale 0..=28, rescale's half-away rounding, normalize, comparison and equality across scales (1.0 = 1.00), and from_str/to_string round trips at every scale. It also pins the one inexact edge: when a product's scale does not fit, checked_mul rounds to 28 decimal places, ties to even, rather than failing; None comes only when the integer part cannot fit. That case is reachable through Ledger::add_line_fx, whose foreign amount and rate are unbounded positive Decimals (the base amount is then rounded to the currency's minor unit). No property failed: 256 cases by default, PROPTEST_CASES=5000 passed, plus hand cases at 28-digit mantissas, scale 28 and negative ties. The two dev-dependencies are test-only and already in the lockfile (through proptest and the PDF stack); they are the exact reference the whole check rests on. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
a2ad2ed35e
commit
b10804fb07
4 files changed
+511
-6
No files matched your search
Generated
+2
@@ -3977,6 +3977,8 @@ dependencies = [
|
||||
"ledger-import",
|
||||
"ledger-package",
|
||||
"ledger-store",
|
||||
"num-bigint",
|
||||
"num-rational",
|
||||
"proptest",
|
||||
"rust_decimal",
|
||||
"serde",
|
||||
|
||||
Reference in new issue
Block a user