Fixtures.hs (1860B)
1 module Fixtures ( 2 -- * ByteString fixtures 3 typicalBytes 4 , emptyBytes 5 , largeBytes 6 7 -- * FeatureVector fixtures 8 , typicalFV 9 , emptyFV 10 , validFV 11 , unknownBitsFV 12 ) where 13 14 import Data.ByteString (ByteString) 15 import qualified Data.ByteString as BS 16 import qualified Lightning.Protocol.BOLT9 as B9 17 18 -- ByteString fixtures -------------------------------------------------------- 19 20 -- | A typical 8-byte feature vector with several common features set: 21 -- basic_mpp (bit 17), option_anchors (bit 23), option_route_blinding (bit 25) 22 typicalBytes :: ByteString 23 typicalBytes = BS.pack [0x02, 0x82, 0x00, 0x00] 24 25 -- | Empty ByteString for parsing. 26 emptyBytes :: ByteString 27 emptyBytes = BS.empty 28 29 -- | Large 64-byte feature vector for stress testing. 30 largeBytes :: ByteString 31 largeBytes = BS.pack $ replicate 64 0xAA 32 33 -- FeatureVector fixtures ----------------------------------------------------- 34 35 -- | A typical feature vector with common features set (optional bits): 36 -- basic_mpp (17), option_anchors (23), option_route_blinding (25) 37 typicalFV :: B9.FeatureVector 38 typicalFV = B9.parse typicalBytes 39 40 -- | Empty feature vector. 41 emptyFV :: B9.FeatureVector 42 emptyFV = B9.empty 43 44 -- | A valid feature vector for validation benchmarks. 45 -- Sets payment_secret (required for basic_mpp dependency) and basic_mpp. 46 validFV :: B9.FeatureVector 47 validFV = B9.setBit 15 -- payment_secret (optional) 48 $ B9.setBit 17 -- basic_mpp (optional) 49 $ B9.setBit 23 -- option_anchors (optional) 50 $ B9.empty 51 52 -- | A feature vector with unknown bits for remote validation. 53 -- Contains a known feature plus an unknown odd bit (safe to ignore). 54 unknownBitsFV :: B9.FeatureVector 55 unknownBitsFV = B9.setBit 15 -- payment_secret (optional, known) 56 $ B9.setBit 99 -- unknown odd bit (should be ignored) 57 $ B9.empty