bolt5

On-chain transaction handling for Lightning (docs.ppad.tech/bolt5).
git clone git://git.ppad.tech/bolt5.git
Log | Files | Refs | README | LICENSE

Main.hs (2774B)


      1 module Main where
      2 
      3 import Criterion.Main
      4 import Fixtures
      5 import Lightning.Protocol.BOLT3
      6 import qualified Lightning.Protocol.BOLT5 as B5
      7 
      8 main :: IO ()
      9 main = do
     10   fx <- fixtures
     11   let keys = fx_keys fx
     12       revpk = ck_revocation_pubkey keys
     13       delayed = ck_local_delayed keys
     14   defaultMain [
     15       bgroup "detect" [
     16         bench "identify_close" $
     17           nf (B5.identify_close (fx_other fx) (fx_commit fx)) (fx_raw fx)
     18       , bench "classify_local_commit_outputs" $
     19           nf (\c -> B5.classify_local_commit_outputs c keys (fx_delay fx)
     20                 StaticRemotekey)
     21              (fx_commit fx)
     22       , bench "classify_remote_commit_outputs" $
     23           nf (\c -> B5.classify_remote_commit_outputs c keys) (fx_commit fx)
     24       , bench "classify_revoked_commit_outputs" $
     25           nf (\c -> B5.classify_revoked_commit_outputs c revpk)
     26              (fx_commit fx)
     27       , bench "extract_preimage_offered" $
     28           nf (B5.extract_preimage_offered (fx_hash fx)) (fx_claim fx)
     29       , bench "extract_preimage_htlc_success" $
     30           nf (B5.extract_preimage_htlc_success (fx_hash fx)) (fx_success fx)
     31       , bench "htlc_timed_out" $
     32           nf (B5.htlc_timed_out 500001) (fx_offered fx)
     33       ]
     34     , bgroup "spend" [
     35         bench "spend_to_local" $
     36           nf (\v -> B5.spend_to_local (fx_outpoint fx) v revpk (fx_delay fx)
     37                 delayed (fx_dest fx) (fx_feerate fx))
     38              (fx_value fx)
     39       , bench "spend_htlc_tx" $
     40           nf (B5.spend_htlc_tx (fx_htlc_ctx fx)) keys
     41       , bench "spend_remote_htlc_timeout" $
     42           nf (\v -> B5.spend_remote_htlc_timeout (fx_outpoint fx) v
     43                 (fx_received fx) keys StaticRemotekey (fx_dest fx)
     44                 (fx_feerate fx))
     45              (fx_value fx)
     46       , bench "spend_remote_htlc_preimage" $
     47           nf (\v -> B5.spend_remote_htlc_preimage (fx_outpoint fx) v
     48                 (fx_offered fx) keys StaticRemotekey (fx_dest fx)
     49                 (fx_feerate fx))
     50              (fx_value fx)
     51       , bench "spend_revoked_to_local" $
     52           nf (\v -> B5.spend_revoked_to_local (fx_outpoint fx) v revpk
     53                 (fx_delay fx) delayed (fx_dest fx) (fx_feerate fx))
     54              (fx_value fx)
     55       , bench "spend_revoked_htlc" $
     56           nf (\v -> B5.spend_revoked_htlc (fx_outpoint fx) v
     57                 (B5.HTLCReceivedOutput (CltvExpiry 501)) revpk keys
     58                 StaticRemotekey (fx_hash fx) (fx_dest fx) (fx_feerate fx))
     59              (fx_value fx)
     60       , bench "spend_anchor_owner" $
     61           nf (\v -> B5.spend_anchor_owner (fx_outpoint fx) v
     62                 (ck_local_funding keys) (fx_dest fx))
     63              (fx_anchor fx)
     64       ]
     65     , bgroup "fees" [
     66         bench "spending_fee" $
     67           nf (B5.spending_fee (fx_feerate fx)) 538
     68       ]
     69     ]