commit 3b0e43744c280e8d0948c59c542b109fde465165
parent b466c9ba5dde63ebce973c11a47b96836bb7a9a6
Author: Jared Tobin <jared@jtobin.io>
Date: Mon, 20 Apr 2026 15:16:26 +0800
test: add next_commitment_number tests
Test increment of 0, 2^48-2, and overflow at 2^48-1. Use total
pattern matches throughout (no partial let-bindings).
Diffstat:
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/test/Main.hs b/test/Main.hs
@@ -338,4 +338,24 @@ smartConstructorTests = testGroup "validation" [
isNothing (commitment_number 281474976710656) @?= True
, testCase "commitment_number rejects maxBound Word64" $ do
isNothing (commitment_number maxBound) @?= True
+
+ -- next_commitment_number
+ , testCase "next_commitment_number 0 -> 1" $
+ case commitment_number 0 of
+ Nothing -> assertFailure "commitment_number 0"
+ Just cn0 -> case next_commitment_number cn0 of
+ Nothing -> assertFailure "next failed"
+ Just cn1 -> unCommitmentNumber cn1 @?= 1
+ , testCase "next_commitment_number (2^48-2) -> (2^48-1)" $
+ case commitment_number 281474976710654 of
+ Nothing -> assertFailure "commitment_number"
+ Just cn -> case next_commitment_number cn of
+ Nothing -> assertFailure "next failed"
+ Just cn' ->
+ unCommitmentNumber cn' @?= 281474976710655
+ , testCase "next_commitment_number (2^48-1) -> Nothing" $
+ case commitment_number 281474976710655 of
+ Nothing -> assertFailure "commitment_number"
+ Just cn ->
+ isNothing (next_commitment_number cn) @?= True
]