commit 2113539a278a3b1ab8484a5b205d9388b758ddb6
parent 5f01f791da2b78c55a183deed2a5d71cc5a19bbe
Author: Jared Tobin <jared@jtobin.io>
Date: Sun, 19 Apr 2026 12:16:40 +0800
test/bench: update for shared bolt1 types
Rename smart constructor calls to camelCase and remove orphan
NFData instances for types that now derive NFData via bolt1.
Diffstat:
3 files changed, 16 insertions(+), 45 deletions(-)
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -10,20 +10,12 @@ import qualified Data.ByteString as BS
import Lightning.Protocol.BOLT3
-- NFData instances for benchmarking
-
--- Existing instances
-instance NFData Satoshi where
- rnf (Satoshi x) = rnf x
-
-instance NFData MilliSatoshi where
- rnf (MilliSatoshi x) = rnf x
+-- (Satoshi, MilliSatoshi, Point, PaymentHash, PerCommitmentSecret
+-- derive NFData via ppad-bolt1)
instance NFData Pubkey where
rnf (Pubkey x) = rnf x
-instance NFData Point where
- rnf (Point x) = rnf x
-
instance NFData PerCommitmentPoint where
rnf (PerCommitmentPoint x) = rnf x
@@ -42,9 +34,6 @@ instance NFData FeeratePerKw where
instance NFData DustLimit where
rnf (DustLimit x) = rnf x
-instance NFData PaymentHash where
- rnf (PaymentHash x) = rnf x
-
instance NFData CltvExpiry where
rnf (CltvExpiry x) = rnf x
@@ -150,9 +139,6 @@ instance NFData HtlcBasepoint where
instance NFData FundingPubkey where
rnf (FundingPubkey p) = rnf p
-instance NFData PerCommitmentSecret where
- rnf (PerCommitmentSecret bs) = rnf bs
-
-- Secret storage (SecretStore is a newtype over list)
instance NFData SecretStore where
rnf store = rnf (derive_old_secret 0 store)
diff --git a/bench/Weight.hs b/bench/Weight.hs
@@ -10,21 +10,12 @@ import Lightning.Protocol.BOLT3
import Weigh
-- NFData instances for weigh
+-- (Satoshi, MilliSatoshi, Point, PaymentHash, PerCommitmentSecret
+-- derive NFData via ppad-bolt1)
--- Monetary types
-instance NFData Satoshi where
- rnf (Satoshi x) = rnf x
-
-instance NFData MilliSatoshi where
- rnf (MilliSatoshi x) = rnf x
-
--- Key types
instance NFData Pubkey where
rnf (Pubkey x) = rnf x
-instance NFData Point where
- rnf (Point x) = rnf x
-
instance NFData PerCommitmentPoint where
rnf (PerCommitmentPoint x) = rnf x
@@ -64,9 +55,6 @@ instance NFData HtlcBasepoint where
instance NFData FundingPubkey where
rnf (FundingPubkey p) = rnf p
-instance NFData PerCommitmentSecret where
- rnf (PerCommitmentSecret bs) = rnf bs
-
-- Channel features
instance NFData ChannelFeatures where
rnf (ChannelFeatures x) = rnf x
@@ -78,9 +66,6 @@ instance NFData DustLimit where
rnf (DustLimit x) = rnf x
-- Hash types
-instance NFData PaymentHash where
- rnf (PaymentHash x) = rnf x
-
instance NFData CltvExpiry where
rnf (CltvExpiry x) = rnf x
diff --git a/test/Main.hs b/test/Main.hs
@@ -306,24 +306,24 @@ smartConstructorTests = testGroup "validation" [
, testCase "mkTxId rejects 31 bytes" $ do
let bs = BS.replicate 31 0x00
isNothing (mkTxId bs) @?= True
- , testCase "payment_hash accepts 32 bytes" $ do
+ , testCase "paymentHash accepts 32 bytes" $ do
let bs = BS.replicate 32 0xab
- isJust (payment_hash bs) @?= True
- , testCase "payment_hash rejects 33 bytes" $ do
+ isJust (paymentHash bs) @?= True
+ , testCase "paymentHash rejects 33 bytes" $ do
let bs = BS.replicate 33 0xab
- isNothing (payment_hash bs) @?= True
- , testCase "payment_preimage accepts 32 bytes" $ do
+ isNothing (paymentHash bs) @?= True
+ , testCase "paymentPreimage accepts 32 bytes" $ do
let bs = BS.replicate 32 0xcd
- isJust (payment_preimage bs) @?= True
- , testCase "payment_preimage rejects 31 bytes" $ do
+ isJust (paymentPreimage bs) @?= True
+ , testCase "paymentPreimage rejects 31 bytes" $ do
let bs = BS.replicate 31 0xcd
- isNothing (payment_preimage bs) @?= True
- , testCase "per_commitment_secret accepts 32 bytes" $ do
+ isNothing (paymentPreimage bs) @?= True
+ , testCase "perCommitmentSecret accepts 32 bytes" $ do
let bs = BS.replicate 32 0xef
- isJust (per_commitment_secret bs) @?= True
- , testCase "per_commitment_secret rejects 33 bytes" $ do
+ isJust (perCommitmentSecret bs) @?= True
+ , testCase "perCommitmentSecret rejects 33 bytes" $ do
let bs = BS.replicate 33 0xef
- isNothing (per_commitment_secret bs) @?= True
+ isNothing (perCommitmentSecret bs) @?= True
-- 48-bit commitment number
, testCase "commitment_number accepts 0" $ do