{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Cardano.Ledger.Shelley.Serialisation.Golden.Encoding (tests) where
import qualified Cardano.Crypto.Hash as Monomorphic
import Cardano.Crypto.KES (SignedKES)
import Cardano.Crypto.VRF (CertifiedVRF)
import Cardano.Ledger.Address (Addr (..), RewardAccount (..))
import Cardano.Ledger.BaseTypes (
BoundedRational (..),
EpochInterval (..),
Network (..),
Nonce (..),
ProtVer (..),
StrictMaybe (..),
UnitInterval,
mkNonceFromNumber,
mkTxIxPartial,
textToDns,
textToUrl,
)
import Cardano.Ledger.Binary (
Annotator,
DecCBOR (..),
DecCBORGroup (..),
Decoder,
DecoderError,
EncCBOR (..),
EncCBORGroup (..),
Tokens (..),
byronProtVer,
decodeFullAnnotator,
decodeFullDecoder,
decodeMapTraverse,
encCBOR,
fromPlainEncoding,
hashWithEncoder,
ipv4ToBytes,
shelleyProtVer,
toCBOR,
toPlainEncoding,
)
import Cardano.Ledger.Binary.Crypto (
encodeSignedDSIGN,
encodeVerKeyDSIGN,
)
import qualified Cardano.Ledger.Binary.Plain as Plain
import Cardano.Ledger.Block (Block (..))
import Cardano.Ledger.Coin (Coin (..), DeltaCoin (..))
import Cardano.Ledger.Credential (Credential (..), StakeReference (..))
import Cardano.Ledger.Crypto
import Cardano.Ledger.Keys (
Hash,
KeyHash (..),
KeyRole (..),
KeyRoleVRF (..),
SignedDSIGN,
VKey (..),
VRFVerKeyHash,
WitVKey (..),
asWitness,
encodeSignedKES,
hashKey,
hashVerKeyVRF,
signedDSIGN,
signedKES,
)
import Cardano.Ledger.PoolParams (
PoolMetadata (..),
PoolParams (..),
StakePoolRelay (..),
)
import Cardano.Ledger.SafeHash (SafeHash, extractHash, hashAnnotated)
import Cardano.Ledger.Shelley (Shelley, ShelleyEra)
import Cardano.Ledger.Shelley.API (MultiSig)
import Cardano.Ledger.Shelley.BlockChain (ShelleyTxSeq (..), bbHash)
import Cardano.Ledger.Shelley.Core
import Cardano.Ledger.Shelley.PParams (
ProposedPPUpdates (..),
pattern ProposedPPUpdates,
pattern Update,
)
import Cardano.Ledger.Shelley.Rewards ()
import Cardano.Ledger.Shelley.Scripts (pattern RequireSignature)
import Cardano.Ledger.Shelley.Tx (ShelleyTx (..))
import qualified Cardano.Ledger.Shelley.TxAuxData as TxAuxData
import Cardano.Ledger.Shelley.TxBody (ShelleyTxBody (..))
import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..))
import Cardano.Ledger.Shelley.TxWits (ShelleyTxWits, addrWits)
import Cardano.Ledger.Slot (BlockNo (..), EpochNo (..), SlotNo (..))
import Cardano.Ledger.TxIn (TxId, TxIn (..))
import Cardano.Protocol.TPraos.BHeader (
BHBody (..),
BHeader (..),
HashHeader (..),
PrevHash (..),
bhash,
bheaderBlockNo,
bheaderEta,
bheaderL,
bheaderOCert,
bheaderPrev,
bheaderSlotNo,
bheaderVk,
bheaderVrfVk,
bprotver,
bsize,
mkSeed,
seedEta,
seedL,
)
import Cardano.Protocol.TPraos.OCert (
KESPeriod (..),
OCert,
OCertSignable (..),
pattern OCert,
)
import qualified Codec.CBOR.Encoding as CBOR (Encoding (..))
import Control.Monad
import Data.ByteString (ByteString)
import qualified Data.ByteString.Base16 as B16
import qualified Data.ByteString.Char8 as BS (pack)
import qualified Data.ByteString.Lazy as BSL (ByteString)
import Data.Coerce (coerce)
import Data.IP (toIPv4)
import qualified Data.Map.Strict as Map
import qualified Data.Maybe as Maybe (fromJust)
import Data.Ratio ((%))
import qualified Data.Sequence.Strict as StrictSeq
import qualified Data.Set as Set
import Data.String (fromString)
import Data.Word (Word64)
import Lens.Micro ((&), (.~))
import Numeric.Natural (Natural)
import qualified Prettyprinter as Pretty
import Test.Cardano.Ledger.Binary.TreeDiff (CBORBytes (CBORBytes), ansiDocToString, diffExpr)
import Test.Cardano.Ledger.Core.KeyPair (KeyPair (..), mkWitnessVKey, sKey, vKey)
import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes (C, C_Crypto, ExMock, Mock)
import Test.Cardano.Ledger.Shelley.Examples.Consensus as Ex (
ledgerExamplesShelley,
sleNewEpochState,
)
import Test.Cardano.Ledger.Shelley.Generator.Core (KESKeyPair (..), PreAlonzo, VRFKeyPair (..))
import Test.Cardano.Ledger.Shelley.Generator.EraGen (genesisId)
import Test.Cardano.Ledger.Shelley.Serialisation.GoldenUtils (
ToTokens (..),
checkEncoding,
checkEncodingCBOR,
checkEncodingCBORAnnotated,
)
import Test.Cardano.Ledger.Shelley.Utils
import Test.Cardano.Protocol.Crypto.VRF.Fake (WithResult (..))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (assertFailure, testCase)
type MultiSigMap = Map.Map (ScriptHash C_Crypto) (MultiSig (ShelleyEra C_Crypto))
decodeMultiSigMap :: Decoder s (Annotator MultiSigMap)
decodeMultiSigMap :: forall s. Decoder s (Annotator MultiSigMap)
decodeMultiSigMap = forall a (t :: * -> *) s b.
(Ord a, Applicative t) =>
Decoder s (t a) -> Decoder s (t b) -> Decoder s (t (Map a b))
decodeMapTraverse (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a s. DecCBOR a => Decoder s a
decCBOR) forall a s. DecCBOR a => Decoder s a
decCBOR
deserializeMultiSigMap :: BSL.ByteString -> Either DecoderError MultiSigMap
deserializeMultiSigMap :: ByteString -> Either DecoderError MultiSigMap
deserializeMultiSigMap =
forall a.
Version
-> Text
-> (forall s. Decoder s (Annotator a))
-> ByteString
-> Either DecoderError a
decodeFullAnnotator Version
shelleyProtVer Text
"Map ScriptHash MultiSig" forall s. Decoder s (Annotator MultiSigMap)
decodeMultiSigMap
checkEncodingCBORCBORGroup ::
(DecCBORGroup a, EncCBORGroup a, Show a, Eq a) =>
String ->
a ->
ToTokens ->
TestTree
checkEncodingCBORCBORGroup :: forall a.
(DecCBORGroup a, EncCBORGroup a, Show a, Eq a) =>
String -> a -> ToTokens -> TestTree
checkEncodingCBORCBORGroup String
name a
x ToTokens
t =
let d :: ByteString -> Either DecoderError a
d = forall a.
Version
-> Text
-> (forall s. Decoder s a)
-> ByteString
-> Either DecoderError a
decodeFullDecoder Version
shelleyProtVer (forall a. IsString a => String -> a
fromString String
name) forall a s. DecCBORGroup a => Decoder s a
decCBORGroup
in forall a.
(HasCallStack, Show a, Eq a) =>
Version
-> (a -> Encoding)
-> (ByteString -> Either DecoderError a)
-> String
-> a
-> ToTokens
-> TestTree
checkEncoding Version
shelleyProtVer forall a. EncCBORGroup a => a -> Encoding
encCBORGroup ByteString -> Either DecoderError a
d String
name a
x ToTokens
t
getRawKeyHash :: KeyHash 'Payment h -> ByteString
getRawKeyHash :: forall h. KeyHash 'Payment h -> ByteString
getRawKeyHash (KeyHash Hash (ADDRHASH h) (VerKeyDSIGN (DSIGN h))
hsh) = forall h a. Hash h a -> ByteString
Monomorphic.hashToBytes Hash (ADDRHASH h) (VerKeyDSIGN (DSIGN h))
hsh
getRawNonce :: Nonce -> ByteString
getRawNonce :: Nonce -> ByteString
getRawNonce (Nonce Hash Blake2b_256 Nonce
hsh) = forall h a. Hash h a -> ByteString
Monomorphic.hashToBytes Hash Blake2b_256 Nonce
hsh
getRawNonce Nonce
NeutralNonce = forall a. HasCallStack => String -> a
error String
"The neutral nonce has no bytes"
testGKey :: Crypto c => GenesisKeyPair c
testGKey :: forall c. Crypto c => GenesisKeyPair c
testGKey = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkGenKey (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
0)
testGKeyHash :: Crypto c => KeyHash 'Genesis c
testGKeyHash :: forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash = (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey) forall c. Crypto c => GenesisKeyPair c
testGKey
testVRF :: Crypto c => VRFKeyPair c
testVRF :: forall c. Crypto c => VRFKeyPair c
testVRF = forall c. Crypto c => RawSeed -> VRFKeyPair c
mkVRFKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
5)
testVRFKH :: forall c r. Crypto c => VRFVerKeyHash r c
testVRFKH :: forall c (r :: KeyRoleVRF). Crypto c => VRFVerKeyHash r c
testVRFKH = forall c (r :: KeyRoleVRF).
Crypto c =>
VerKeyVRF c -> VRFVerKeyHash r c
hashVerKeyVRF forall a b. (a -> b) -> a -> b
$ forall c. VRFKeyPair c -> VerKeyVRF c
vrfVerKey (forall c. Crypto c => VRFKeyPair c
testVRF @c)
testTxb :: (EraTxOut era, EraTxCert era) => ShelleyTxBody era
testTxb :: forall era. (EraTxOut era, EraTxCert era) => ShelleyTxBody era
testTxb =
forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody
forall a. Set a
Set.empty
forall a. StrictSeq a
StrictSeq.empty
forall a. StrictSeq a
StrictSeq.empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
0)
(Word64 -> SlotNo
SlotNo Word64
0)
forall a. StrictMaybe a
SNothing
forall a. StrictMaybe a
SNothing
testTxbHash ::
forall era.
(EraTxOut era, EraTxCert era) =>
SafeHash (EraCrypto era) EraIndependentTxBody
testTxbHash :: forall era.
(EraTxOut era, EraTxCert era) =>
SafeHash (EraCrypto era) EraIndependentTxBody
testTxbHash = forall x index c.
(HashAnnotated x index c, HashAlgorithm (HASH c)) =>
x -> SafeHash c index
hashAnnotated forall a b. (a -> b) -> a -> b
$ forall era. (EraTxOut era, EraTxCert era) => ShelleyTxBody era
testTxb @era
testKey1 :: Crypto c => KeyPair 'Payment c
testKey1 :: forall c. Crypto c => KeyPair 'Payment c
testKey1 = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
1)
testKey2 :: Crypto c => KeyPair kr c
testKey2 :: forall c (kr :: KeyRole). Crypto c => KeyPair kr c
testKey2 = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
2)
testBlockIssuerKey :: Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey :: forall c. Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
4)
testStakePoolKey :: Crypto c => KeyPair 'StakePool c
testStakePoolKey :: forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
5)
testGenesisDelegateKey ::
Crypto c =>
KeyPair 'GenesisDelegate c
testGenesisDelegateKey :: forall c. Crypto c => KeyPair 'GenesisDelegate c
testGenesisDelegateKey = forall (kd :: KeyRole) c.
VKey kd c -> SignKeyDSIGN (DSIGN c) -> KeyPair kd c
KeyPair forall {kd :: KeyRole}. VKey kd c
vk SignKeyDSIGN (DSIGN c)
sk
where
(SignKeyDSIGN (DSIGN c)
sk, VKey kd c
vk) = forall c (kd :: KeyRole).
DSIGNAlgorithm (DSIGN c) =>
RawSeed -> (SignKeyDSIGN (DSIGN c), VKey kd c)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
6)
testBlockIssuerKeyTokens :: Tokens -> Tokens
testBlockIssuerKeyTokens :: Tokens -> Tokens
testBlockIssuerKeyTokens = Tokens -> Tokens
e
where
VKey VerKeyDSIGN (DSIGN C_Crypto)
vk = forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey (forall c. Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey @C_Crypto)
CBOR.Encoding Tokens -> Tokens
e = Version -> Encoding -> Encoding
toPlainEncoding Version
shelleyProtVer (forall v. DSIGNAlgorithm v => VerKeyDSIGN v -> Encoding
encodeVerKeyDSIGN VerKeyDSIGN MockDSIGN
vk)
testKey1SigToken ::
forall era.
(EraTxOut era, Mock (EraCrypto era), EraTxCert era) =>
Tokens ->
Tokens
testKey1SigToken :: forall era.
(EraTxOut era, Mock (EraCrypto era), EraTxCert era) =>
Tokens -> Tokens
testKey1SigToken = Tokens -> Tokens
e
where
s :: SignedDSIGN
(EraCrypto era) (Hash (HASH (EraCrypto era)) EraIndependentTxBody)
s =
forall c a.
(Crypto c, Signable (DSIGN c) a) =>
SignKeyDSIGN (DSIGN c) -> a -> SignedDSIGN c a
signedDSIGN @(EraCrypto era)
(forall (kd :: KeyRole) c. KeyPair kd c -> SignKeyDSIGN (DSIGN c)
sKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'Payment c
testKey1 @(EraCrypto era))
(forall c i. SafeHash c i -> Hash (HASH c) i
extractHash (forall era.
(EraTxOut era, EraTxCert era) =>
SafeHash (EraCrypto era) EraIndependentTxBody
testTxbHash @era)) ::
SignedDSIGN (EraCrypto era) (Hash (EraCrypto era) EraIndependentTxBody)
CBOR.Encoding Tokens -> Tokens
e = Version -> Encoding -> Encoding
toPlainEncoding Version
shelleyProtVer (forall v a. DSIGNAlgorithm v => SignedDSIGN v a -> Encoding
encodeSignedDSIGN SignedDSIGN
(EraCrypto era) (Hash (HASH (EraCrypto era)) EraIndependentTxBody)
s)
testOpCertSigTokens ::
forall c.
Mock c =>
Tokens ->
Tokens
testOpCertSigTokens :: forall c. Mock c => Tokens -> Tokens
testOpCertSigTokens = Tokens -> Tokens
e
where
s :: SignedDSIGN c (OCertSignable c)
s =
forall c a.
(Crypto c, Signable (DSIGN c) a) =>
SignKeyDSIGN (DSIGN c) -> a -> SignedDSIGN c a
signedDSIGN @c
(forall (kd :: KeyRole) c. KeyPair kd c -> SignKeyDSIGN (DSIGN c)
sKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'Payment c
testKey1 @c)
(forall c. VerKeyKES c -> Word64 -> KESPeriod -> OCertSignable c
OCertSignable @c (forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @c) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
CBOR.Encoding Tokens -> Tokens
e = Version -> Encoding -> Encoding
toPlainEncoding Version
shelleyProtVer (forall v a. DSIGNAlgorithm v => SignedDSIGN v a -> Encoding
encodeSignedDSIGN SignedDSIGN c (OCertSignable c)
s)
testKeyHash1 :: Crypto c => KeyHash 'Payment c
testKeyHash1 :: forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 = (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey) forall c. Crypto c => KeyPair 'Payment c
testKey1
testKeyHash2 :: Crypto c => KeyHash 'Staking c
testKeyHash2 :: forall c. Crypto c => KeyHash 'Staking c
testKeyHash2 = (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey) forall c (kr :: KeyRole). Crypto c => KeyPair kr c
testKey2
testKESKeys :: Crypto c => KESKeyPair c
testKESKeys :: forall c. Crypto c => KESKeyPair c
testKESKeys = forall c. Crypto c => RawSeed -> KESKeyPair c
mkKESKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
0 Word64
0 Word64
0 Word64
0 Word64
3)
testAddrE :: Crypto c => Addr c
testAddrE :: forall c. Crypto c => Addr c
testAddrE =
forall c.
Network -> PaymentCredential c -> StakeReference c -> Addr c
Addr
Network
Testnet
(forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall c. Crypto c => KeyHash 'Payment c
testKeyHash1)
forall c. StakeReference c
StakeRefNull
testPayCred :: forall c. Crypto c => Credential 'Payment c
testPayCred :: forall c. Crypto c => Credential 'Payment c
testPayCred = forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj (forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 @c)
testStakeCred :: forall c. Crypto c => Credential 'Staking c
testStakeCred :: forall c. Crypto c => Credential 'Staking c
testStakeCred = forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyHash 'Staking c
testKeyHash2 @c
testScript :: forall c. Crypto c => MultiSig (ShelleyEra c)
testScript :: forall c. Crypto c => MultiSig (ShelleyEra c)
testScript = forall era.
ShelleyEraScript era =>
KeyHash 'Witness (EraCrypto era) -> NativeScript era
RequireSignature forall a b. (a -> b) -> a -> b
$ forall (a :: KeyRole -> * -> *) (r :: KeyRole) c.
HasKeyRole a =>
a r c -> a 'Witness c
asWitness (forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 @c)
testScriptHash :: forall c. Crypto c => ScriptHash c
testScriptHash :: forall c. Crypto c => ScriptHash c
testScriptHash = forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @(ShelleyEra c) forall c. Crypto c => MultiSig (ShelleyEra c)
testScript
testScript2 :: forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2 :: forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2 = forall era.
ShelleyEraScript era =>
KeyHash 'Witness (EraCrypto era) -> NativeScript era
RequireSignature forall a b. (a -> b) -> a -> b
$ forall (a :: KeyRole -> * -> *) (r :: KeyRole) c.
HasKeyRole a =>
a r c -> a 'Witness c
asWitness (forall c. Crypto c => KeyHash 'Staking c
testKeyHash2 @c)
testHeaderHash ::
forall c.
Crypto c =>
HashHeader c
=
forall c. Hash c EraIndependentBlockHeader -> HashHeader c
HashHeader forall a b. (a -> b) -> a -> b
$
coerce :: forall a b. Coercible a b => a -> b
coerce
(forall h a.
HashAlgorithm h =>
Version -> (a -> Encoding) -> a -> Hash h a
hashWithEncoder Version
shelleyProtVer forall a. EncCBOR a => a -> Encoding
encCBOR Int
0 :: Hash c Int)
testBHB ::
forall era c.
( EraTx era
, PreAlonzo era
, ExMock c
, c ~ EraCrypto era
, Tx era ~ ShelleyTx era
) =>
BHBody c
testBHB :: forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB =
BHBody
{ bheaderBlockNo :: BlockNo
bheaderBlockNo = Word64 -> BlockNo
BlockNo Word64
44
, bheaderSlotNo :: SlotNo
bheaderSlotNo = Word64 -> SlotNo
SlotNo Word64
33
, bheaderPrev :: PrevHash c
bheaderPrev = forall c. HashHeader c -> PrevHash c
BlockHash forall c. Crypto c => HashHeader c
testHeaderHash
, bheaderVk :: VKey 'BlockIssuer c
bheaderVk = forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall c. Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey
, bheaderVrfVk :: VerKeyVRF c
bheaderVrfVk = forall c. VRFKeyPair c -> VerKeyVRF c
vrfVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @c
, bheaderEta :: CertifiedVRF c Nonce
bheaderEta =
forall v a b.
(Signable v a, VRFAlgorithm v, ContextVRF v ~ (),
Coercible b (CertifiedVRF v a)) =>
a -> SignKeyVRF v -> b
mkCertifiedVRF
( forall a. a -> Word64 -> WithResult a
WithResult
(Nonce -> SlotNo -> Nonce -> Seed
mkSeed Nonce
seedEta (Word64 -> SlotNo
SlotNo Word64
33) (Word64 -> Nonce
mkNonceFromNumber Word64
0))
Word64
1
)
(forall c. VRFKeyPair c -> SignKeyVRF c
vrfSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @c)
, bheaderL :: CertifiedVRF c Natural
bheaderL =
forall v a b.
(Signable v a, VRFAlgorithm v, ContextVRF v ~ (),
Coercible b (CertifiedVRF v a)) =>
a -> SignKeyVRF v -> b
mkCertifiedVRF
( forall a. a -> Word64 -> WithResult a
WithResult
(Nonce -> SlotNo -> Nonce -> Seed
mkSeed Nonce
seedL (Word64 -> SlotNo
SlotNo Word64
33) (Word64 -> Nonce
mkNonceFromNumber Word64
0))
Word64
1
)
(forall c. VRFKeyPair c -> SignKeyVRF c
vrfSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @c)
, bsize :: Word32
bsize = Word32
0
, bhash :: Hash c EraIndependentBlockBody
bhash = forall era.
Era era =>
ShelleyTxSeq era -> Hash (EraCrypto era) EraIndependentBlockBody
bbHash @era forall a b. (a -> b) -> a -> b
$ forall era.
(EraTx era, Tx era ~ ShelleyTx era, SafeToHash (TxWits era)) =>
StrictSeq (Tx era) -> ShelleyTxSeq era
ShelleyTxSeq @era forall a. StrictSeq a
StrictSeq.empty
, bheaderOCert :: OCert c
bheaderOCert =
forall c.
VerKeyKES c
-> Word64
-> KESPeriod
-> SignedDSIGN c (OCertSignable c)
-> OCert c
OCert
(forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @c)
Word64
0
(Word -> KESPeriod
KESPeriod Word
0)
( forall c a.
(Crypto c, Signable (DSIGN c) a) =>
SignKeyDSIGN (DSIGN c) -> a -> SignedDSIGN c a
signedDSIGN @c
(forall (kd :: KeyRole) c. KeyPair kd c -> SignKeyDSIGN (DSIGN c)
sKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'Payment c
testKey1 @c)
(forall c. VerKeyKES c -> Word64 -> KESPeriod -> OCertSignable c
OCertSignable (forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @c) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
)
, bprotver :: ProtVer
bprotver = Version -> Natural -> ProtVer
ProtVer forall a. Bounded a => a
minBound Natural
0
}
testBHBSigTokens ::
forall era.
( EraTx era
, PreAlonzo era
, ExMock (EraCrypto era)
, Tx era ~ ShelleyTx era
) =>
Tokens ->
Tokens
testBHBSigTokens :: forall era.
(EraTx era, PreAlonzo era, ExMock (EraCrypto era),
Tx era ~ ShelleyTx era) =>
Tokens -> Tokens
testBHBSigTokens = Tokens -> Tokens
e
where
s :: SignedKES (KES (EraCrypto era)) (BHBody (EraCrypto era))
s =
forall v a.
(KESAlgorithm v, Signable v a) =>
ContextKES v -> Word -> a -> SignKeyKES v -> SignedKES v a
signedKES @(KES (EraCrypto era))
()
Word
0
(forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @era)
(forall c. KESKeyPair c -> SignKeyKES c
kesSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @(EraCrypto era))
CBOR.Encoding Tokens -> Tokens
e = Version -> Encoding -> Encoding
toPlainEncoding Version
shelleyProtVer (forall v a. KESAlgorithm v => SignedKES v a -> Encoding
encodeSignedKES SignedKES (KES (EraCrypto era)) (BHBody (EraCrypto era))
s)
tests :: TestTree
tests :: TestTree
tests =
String -> [TestTree] -> TestTree
testGroup
String
"CBOR Serialization Tests (Encoding)"
[ forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
byronProtVer
String
"list (Byron)"
([Integer
1] :: [Integer])
((Tokens -> Tokens) -> ToTokens
T (Tokens -> Tokens
TkListBegin forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tokens -> Tokens
TkBreak))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"list (Shelley)"
([Integer
1] :: [Integer])
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
byronProtVer
String
"set (Byron)"
(forall a. a -> Set a
Set.singleton (Integer
1 :: Integer))
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkTag Word
258 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkListLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"set (Shelley)"
(forall a. a -> Set a
Set.singleton (Integer
1 :: Integer))
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"map"
(forall k a. k -> a -> Map k a
Map.singleton (Integer
1 :: Integer) (Integer
1 :: Integer))
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Tokens -> Tokens
TkInteger Integer
1))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"coin"
(Integer -> Coin
Coin Integer
30)
((Tokens -> Tokens) -> ToTokens
T (Word64 -> Tokens -> Tokens
TkWord64 Word64
30))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"rational"
(forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational (Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
2) :: UnitInterval)
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkTag Word
30 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkListLen Word
2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> Tokens -> Tokens
TkWord64 Word64
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> Tokens -> Tokens
TkWord64 Word64
2))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"slot"
(Word64 -> SlotNo
SlotNo Word64
7)
((Tokens -> Tokens) -> ToTokens
T (Word64 -> Tokens -> Tokens
TkWord64 Word64
7))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"neutral_nonce"
Nonce
NeutralNonce
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"nonce"
(Word64 -> Nonce
mkNonceFromNumber Word64
99)
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Tokens -> Tokens
TkBytes (Nonce -> ByteString
getRawNonce forall a b. (a -> b) -> a -> b
$ Word64 -> Nonce
mkNonceFromNumber Word64
99)))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"key_hash"
(forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 @C_Crypto)
((Tokens -> Tokens) -> ToTokens
T (ByteString -> Tokens -> Tokens
TkBytes (forall h. KeyHash 'Payment h -> ByteString
getRawKeyHash (forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 @C_Crypto))))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"credential_key_hash"
(forall c. Crypto c => Credential 'Payment c
testPayCred @C_Crypto)
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0) forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => KeyHash 'Payment c
testKeyHash1 @C_Crypto))
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"txin"
(forall c. TxId c -> TxIx -> TxIn c
TxIn @C_Crypto forall c. HashAlgorithm (HASH c) => TxId c
genesisId forall a. Bounded a => a
minBound)
((Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2) forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. HashAlgorithm (HASH c) => TxId c
genesisId :: TxId C_Crypto) forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word64 -> Tokens -> Tokens
TkWord64 Word64
0))
, let a :: Addr C_Crypto
a = forall c.
Network -> PaymentCredential c -> StakeReference c -> Addr c
Addr Network
Testnet forall c. Crypto c => Credential 'Payment c
testPayCred forall c. StakeReference c
StakeRefNull
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"txout"
(forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C Addr C_Crypto
a (Integer -> Coin
Coin Integer
2))
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Addr C_Crypto
a
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
2)
)
, case forall c (kr :: KeyRole).
(Crypto c, DSignable c (Hash (HASH c) EraIndependentTxBody)) =>
SafeHash c EraIndependentTxBody
-> KeyPair kr c -> WitVKey 'Witness c
mkWitnessVKey @C_Crypto (forall era.
(EraTxOut era, EraTxCert era) =>
SafeHash (EraCrypto era) EraIndependentTxBody
testTxbHash @C) forall c. Crypto c => KeyPair 'Payment c
testKey1 of
w :: WitVKey 'Witness C_Crypto
w@(WitVKey VKey 'Witness C_Crypto
vk SignedDSIGN C_Crypto (Hash (HASH C_Crypto) EraIndependentTxBody)
_sig) ->
forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"vkey_witnesses"
WitVKey 'Witness C_Crypto
w
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S VKey 'Witness C_Crypto
vk
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (forall era.
(EraTxOut era, Mock (EraCrypto era), EraTxCert era) =>
Tokens -> Tokens
testKey1SigToken @C)
)
, forall a.
(HasCallStack, Show a, Eq a) =>
Version
-> (a -> Encoding)
-> (ByteString -> Either DecoderError a)
-> String
-> a
-> ToTokens
-> TestTree
checkEncoding
Version
shelleyProtVer
(Encoding -> Encoding
fromPlainEncoding forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToCBOR a => a -> Encoding
toCBOR)
ByteString -> Either DecoderError MultiSigMap
deserializeMultiSigMap
String
"script_hash_to_scripts"
(forall k a. k -> a -> Map k a
Map.singleton (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript) forall c. Crypto c => MultiSig (ShelleyEra c)
testScript)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
)
,
let r :: RewardAccount C_Crypto
r = forall c. Network -> Credential 'Staking c -> RewardAccount c
RewardAccount Network
Testnet (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"withdrawal"
(forall k a. k -> a -> Map k a
Map.singleton RewardAccount C_Crypto
r (Integer -> Coin
Coin Integer
123))
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkMapLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S RewardAccount C_Crypto
r
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
123)
)
,
let r :: RewardAccount C_Crypto
r = forall c. Network -> Credential 'Staking c -> RewardAccount c
RewardAccount Network
Testnet (forall (kr :: KeyRole) c. ScriptHash c -> Credential kr c
ScriptHashObj (forall c. Crypto c => ScriptHash c
testScriptHash @C_Crypto))
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"withdrawal"
(forall k a. k -> a -> Map k a
Map.singleton RewardAccount C_Crypto
r (Integer -> Coin
Coin Integer
123))
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkMapLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S RewardAccount C_Crypto
r
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
123)
)
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"register_stake_reference"
(forall era.
ShelleyEraTxCert era =>
StakeCredential (EraCrypto era) -> TxCert era
RegTxCert @C (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto))
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
)
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"deregister_stake_reference"
(forall era.
ShelleyEraTxCert era =>
StakeCredential (EraCrypto era) -> TxCert era
UnRegTxCert @C (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto))
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
)
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"stake_delegation"
(forall era.
ShelleyEraTxCert era =>
StakeCredential (EraCrypto era)
-> KeyHash 'StakePool (EraCrypto era) -> TxCert era
DelegStakeTxCert @C (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto) (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall a b. (a -> b) -> a -> b
$ forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey))
( (Tokens -> Tokens) -> ToTokens
T
( Word -> Tokens -> Tokens
TkListLen Word
3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
2
)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey @C_Crypto)
)
,
let poolOwner :: KeyHash 'Staking C_Crypto
poolOwner = forall c. Crypto c => KeyHash 'Staking c
testKeyHash2 @C_Crypto
poolMargin :: UnitInterval
poolMargin = forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational Rational
0.7
poolRAcnt :: RewardAccount C_Crypto
poolRAcnt = forall c. Network -> Credential 'Staking c -> RewardAccount c
RewardAccount Network
Testnet (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
poolPledge :: Coin
poolPledge = Integer -> Coin
Coin Integer
11
poolCost :: Coin
poolCost = Integer -> Coin
Coin Integer
55
poolUrl :: Text
poolUrl = Text
"pool.io"
poolMDHash :: ByteString
poolMDHash = String -> ByteString
BS.pack String
"{}"
ipv4 :: IPv4
ipv4 = [Int] -> IPv4
toIPv4 [Int
127, Int
0, Int
0, Int
1]
ipv4Bytes :: ByteString
ipv4Bytes = IPv4 -> ByteString
ipv4ToBytes forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> IPv4
toIPv4 forall a b. (a -> b) -> a -> b
$ [Int
127, Int
0, Int
0, Int
1]
poolRelays :: StrictSeq StakePoolRelay
poolRelays =
forall a. [a] -> StrictSeq a
StrictSeq.fromList
[ StrictMaybe Port
-> StrictMaybe IPv4 -> StrictMaybe IPv6 -> StakePoolRelay
SingleHostAddr forall a. StrictMaybe a
SNothing (forall a. a -> StrictMaybe a
SJust IPv4
ipv4) forall a. StrictMaybe a
SNothing
, StrictMaybe Port -> DnsName -> StakePoolRelay
SingleHostName (forall a. a -> StrictMaybe a
SJust Port
42) forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
Maybe.fromJust forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadFail m => Int -> Text -> m DnsName
textToDns Int
64 Text
"singlehost.relay.com"
, DnsName -> StakePoolRelay
MultiHostName forall a b. (a -> b) -> a -> b
$ forall a. HasCallStack => Maybe a -> a
Maybe.fromJust forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadFail m => Int -> Text -> m DnsName
textToDns Int
64 Text
"multihost.relay.com"
]
vrfKeyHash :: VRFVerKeyHash 'StakePoolVRF C_Crypto
vrfKeyHash :: VRFVerKeyHash 'StakePoolVRF C_Crypto
vrfKeyHash = forall c (r :: KeyRoleVRF). Crypto c => VRFVerKeyHash r c
testVRFKH
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"register_pool"
( forall era.
EraTxCert era =>
PoolParams (EraCrypto era) -> TxCert era
RegPoolTxCert @C
( PoolParams
{ ppId :: KeyHash 'StakePool C_Crypto
ppId = forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey
, ppVrf :: VRFVerKeyHash 'StakePoolVRF C_Crypto
ppVrf = VRFVerKeyHash 'StakePoolVRF C_Crypto
vrfKeyHash
, ppPledge :: Coin
ppPledge = Coin
poolPledge
, ppCost :: Coin
ppCost = Coin
poolCost
, ppMargin :: UnitInterval
ppMargin = UnitInterval
poolMargin
, ppRewardAccount :: RewardAccount C_Crypto
ppRewardAccount = RewardAccount C_Crypto
poolRAcnt
, ppOwners :: Set (KeyHash 'Staking C_Crypto)
ppOwners = forall a. a -> Set a
Set.singleton KeyHash 'Staking C_Crypto
poolOwner
, ppRelays :: StrictSeq StakePoolRelay
ppRelays = StrictSeq StakePoolRelay
poolRelays
, ppMetadata :: StrictMaybe PoolMetadata
ppMetadata =
forall a. a -> StrictMaybe a
SJust forall a b. (a -> b) -> a -> b
$
PoolMetadata
{ pmUrl :: Url
pmUrl = forall a. HasCallStack => Maybe a -> a
Maybe.fromJust forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadFail m => Int -> Text -> m Url
textToUrl Int
64 Text
poolUrl
, pmHash :: ByteString
pmHash = ByteString
poolMDHash
}
}
)
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
10)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S VRFVerKeyHash 'StakePoolVRF C_Crypto
vrfKeyHash
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
poolPledge
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
poolCost
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S UnitInterval
poolMargin
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S RewardAccount C_Crypto
poolRAcnt
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S KeyHash 'Staking C_Crypto
poolOwner
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
3)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
4 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tokens -> Tokens
TkNull forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Tokens -> Tokens
TkBytes ByteString
ipv4Bytes forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tokens -> Tokens
TkNull)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
3 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Word -> Tokens -> Tokens
TkWord Word
42) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Tokens -> Tokens
TkString (Text
"singlehost.relay.com"))
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Tokens -> Tokens
TkString (Text
"multihost.relay.com"))
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Text
poolUrl
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ByteString
poolMDHash
)
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"retire_pool"
( forall era.
EraTxCert era =>
KeyHash 'StakePool (EraCrypto era) -> EpochNo -> TxCert era
RetirePoolTxCert @C
(forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey @C_Crypto)
(Word64 -> EpochNo
EpochNo Word64
1729)
)
( (Tokens -> Tokens) -> ToTokens
T
( Word -> Tokens -> Tokens
TkListLen Word
3
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
4
)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'StakePool c
testStakePoolKey @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Word64 -> EpochNo
EpochNo Word64
1729)
)
, let vrfKeyHash :: VRFVerKeyHash 'GenDelegVRF C_Crypto
vrfKeyHash :: VRFVerKeyHash 'GenDelegVRF C_Crypto
vrfKeyHash = forall c (r :: KeyRoleVRF). Crypto c => VRFVerKeyHash r c
testVRFKH
genesisDelegate :: KeyHash 'GenesisDelegate C_Crypto
genesisDelegate :: KeyHash 'GenesisDelegate C_Crypto
genesisDelegate = forall c (kd :: KeyRole). Crypto c => VKey kd c -> KeyHash kd c
hashKey forall a b. (a -> b) -> a -> b
$ forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall c. Crypto c => KeyPair 'GenesisDelegate c
testGenesisDelegateKey
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"genesis_delegation"
(forall era.
(ShelleyEraTxCert era, ProtVerAtMost era 8) =>
KeyHash 'Genesis (EraCrypto era)
-> KeyHash 'GenesisDelegate (EraCrypto era)
-> VRFVerKeyHash 'GenDelegVRF (EraCrypto era)
-> TxCert era
GenesisDelegTxCert @C forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash KeyHash 'GenesisDelegate C_Crypto
genesisDelegate VRFVerKeyHash 'GenDelegVRF C_Crypto
vrfKeyHash)
( (Tokens -> Tokens) -> ToTokens
T
(Word -> Tokens -> Tokens
TkListLen Word
4 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
5)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S KeyHash 'GenesisDelegate C_Crypto
genesisDelegate
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S VRFVerKeyHash 'GenDelegVRF C_Crypto
vrfKeyHash
)
,
let rws :: MIRTarget C_Crypto
rws = forall c. Map (Credential 'Staking c) DeltaCoin -> MIRTarget c
StakeAddressesMIR forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto) (Integer -> DeltaCoin
DeltaCoin Integer
77)
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"mir"
(forall era.
(ShelleyEraTxCert era, ProtVerAtMost era 8) =>
MIRCert (EraCrypto era) -> TxCert era
MirTxCert @C (forall c. MIRPot -> MIRTarget c -> MIRCert c
MIRCert MIRPot
ReservesMIR MIRTarget C_Crypto
rws))
( (Tokens -> Tokens) -> ToTokens
T
( Word -> Tokens -> Tokens
TkListLen Word
2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
6
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkListLen Word
2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0
)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S MIRTarget C_Crypto
rws
)
, forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"pparams_update_key_deposit_only"
(forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate @Shelley forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuKeyDepositL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust (Integer -> Coin
Coin Integer
5))
(((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
5) forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
5))
,
let minfeea :: Coin
minfeea = Integer -> Coin
Coin Integer
0
minfeeb :: Coin
minfeeb = Integer -> Coin
Coin Integer
1
maxbbsize :: Word32
maxbbsize = Word32
2
maxtxsize :: Word32
maxtxsize = Word32
3
maxbhsize :: Word16
maxbhsize = Word16
4
keydeposit :: Coin
keydeposit = Integer -> Coin
Coin Integer
5
pooldeposit :: Coin
pooldeposit = Integer -> Coin
Coin Integer
6
emax :: EpochInterval
emax = Word32 -> EpochInterval
EpochInterval Word32
7
nopt :: Natural
nopt = Natural
8
a0 :: NonNegativeInterval
a0 = forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational forall a b. (a -> b) -> a -> b
$ Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
6
rho :: UnitInterval
rho = forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational forall a b. (a -> b) -> a -> b
$ Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
6
tau :: UnitInterval
tau = forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational forall a b. (a -> b) -> a -> b
$ Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
7
d :: UnitInterval
d = forall r.
(HasCallStack, Typeable r, BoundedRational r) =>
Rational -> r
unsafeBoundRational forall a b. (a -> b) -> a -> b
$ Integer
1 forall a. Integral a => a -> a -> Ratio a
% Integer
9
extraEntropy :: Nonce
extraEntropy = Nonce
NeutralNonce
protocolVersion :: ProtVer
protocolVersion = Version -> Natural -> ProtVer
ProtVer forall a. Bounded a => a
minBound Natural
1
minUTxOValue :: Coin
minUTxOValue = Integer -> Coin
Coin Integer
121
minPoolCost :: Coin
minPoolCost = Integer -> Coin
Coin Integer
987
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"pparams_update_all"
( forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate @Shelley
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuMinFeeAL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
minfeea
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuMinFeeBL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
minfeeb
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
ppuMaxBBSizeL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Word32
maxbbsize
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word32)
ppuMaxTxSizeL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Word32
maxtxsize
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Word16)
ppuMaxBHSizeL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Word16
maxbhsize
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuKeyDepositL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
keydeposit
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuPoolDepositL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
pooldeposit
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe EpochInterval)
ppuEMaxL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust EpochInterval
emax
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Natural)
ppuNOptL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Natural
nopt
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe NonNegativeInterval)
ppuA0L forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust NonNegativeInterval
a0
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
ppuRhoL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust UnitInterval
rho
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
ppuTauL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust UnitInterval
tau
forall a b. a -> (a -> b) -> b
& forall era.
(EraPParams era, ProtVerAtMost era 6) =>
Lens' (PParamsUpdate era) (StrictMaybe UnitInterval)
ppuDL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust UnitInterval
d
forall a b. a -> (a -> b) -> b
& forall era.
(EraPParams era, ProtVerAtMost era 6) =>
Lens' (PParamsUpdate era) (StrictMaybe Nonce)
ppuExtraEntropyL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Nonce
extraEntropy
forall a b. a -> (a -> b) -> b
& forall era.
(EraPParams era, ProtVerAtMost era 8) =>
Lens' (PParamsUpdate era) (StrictMaybe ProtVer)
ppuProtocolVersionL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust ProtVer
protocolVersion
forall a b. a -> (a -> b) -> b
& forall era.
(EraPParams era, ProtVerAtMost era 4) =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuMinUTxOValueL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
minUTxOValue
forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Coin)
ppuMinPoolCostL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Coin
minPoolCost
)
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkMapLen Word
17)
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
minfeea
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
minfeeb
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Word32
maxbbsize
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Word32
maxtxsize
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
4)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Word16
maxbhsize
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
5)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
keydeposit
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
6)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
pooldeposit
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
7)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S EpochInterval
emax
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
8)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Natural
nopt
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
9 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkTag Word
30)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall r. BoundedRational r => r -> Rational
unboundRational NonNegativeInterval
a0)
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
10)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S UnitInterval
rho
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
11)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S UnitInterval
tau
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
12)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S UnitInterval
d
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
13)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Nonce
extraEntropy
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
14)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ProtVer
protocolVersion
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
15)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
minUTxOValue
forall a. Semigroup a => a -> a -> a
<> ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkWord Word
16)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Coin
minPoolCost
)
,
let ppup :: ProposedPPUpdates C
ppup =
forall era.
Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
ProposedPPUpdates @C
( forall k a. k -> a -> Map k a
Map.singleton
(forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash @C_Crypto)
(forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Natural)
ppuNOptL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Natural
100)
)
e :: EpochNo
e = Word64 -> EpochNo
EpochNo Word64
0
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"full_update"
(forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update ProposedPPUpdates C
ppup EpochNo
e)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ProposedPPUpdates C
ppup
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S EpochNo
e
)
,
let tout :: ShelleyTxOut C
tout = forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2)
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"txbody"
( forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [TxIn C_Crypto
genesisTxIn1])
(forall a. a -> StrictSeq a
StrictSeq.singleton ShelleyTxOut C
tout)
forall a. StrictSeq a
StrictSeq.empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
500)
forall a. StrictMaybe a
SNothing
forall a. StrictMaybe a
SNothing
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
4)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S TxIn C_Crypto
genesisTxIn1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxOut C
tout
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
2)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word64 -> Tokens -> Tokens
TkWord64 Word64
9)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
3)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word64 -> Tokens -> Tokens
TkWord64 Word64
500)
)
,
let tout :: ShelleyTxOut C
tout = forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2)
ra :: RewardAccount C_Crypto
ra = forall c. Network -> Credential 'Staking c -> RewardAccount c
RewardAccount Network
Testnet (forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall c. Crypto c => KeyHash 'Staking c
testKeyHash2)
ras :: Map (RewardAccount C_Crypto) Coin
ras = forall k a. k -> a -> Map k a
Map.singleton RewardAccount C_Crypto
ra (Integer -> Coin
Coin Integer
123)
up :: Update C
up =
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update
( forall era.
Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
ProposedPPUpdates forall a b. (a -> b) -> a -> b
$
forall k a. k -> a -> Map k a
Map.singleton forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash forall a b. (a -> b) -> a -> b
$
forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Natural)
ppuNOptL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Natural
100
)
(Word64 -> EpochNo
EpochNo Word64
0)
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"txbody_partial"
( forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [TxIn C_Crypto
genesisTxIn1])
(forall a. a -> StrictSeq a
StrictSeq.singleton ShelleyTxOut C
tout)
forall a. StrictSeq a
StrictSeq.Empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals Map (RewardAccount C_Crypto) Coin
ras)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
500)
(forall a. a -> StrictMaybe a
SJust Update C
up)
forall a. StrictMaybe a
SNothing
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
6)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S TxIn C_Crypto
genesisTxIn1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxOut C
tout
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
9)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Word64 -> SlotNo
SlotNo Word64
500)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
5)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Map (RewardAccount C_Crypto) Coin
ras
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
6)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Update C
up
)
,
let tout :: ShelleyTxOut C
tout = forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2)
reg :: TxCert C
reg = forall era.
ShelleyEraTxCert era =>
StakeCredential (EraCrypto era) -> TxCert era
RegTxCert (forall c. Crypto c => Credential 'Staking c
testStakeCred @C_Crypto)
ra :: RewardAccount C_Crypto
ra = forall c. Network -> Credential 'Staking c -> RewardAccount c
RewardAccount Network
Testnet (forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
KeyHashObj forall c. Crypto c => KeyHash 'Staking c
testKeyHash2)
ras :: Map (RewardAccount C_Crypto) Coin
ras = forall k a. k -> a -> Map k a
Map.singleton RewardAccount C_Crypto
ra (Integer -> Coin
Coin Integer
123)
up :: Update C
up =
forall era. ProposedPPUpdates era -> EpochNo -> Update era
Update
( forall era.
Map (KeyHash 'Genesis (EraCrypto era)) (PParamsUpdate era)
-> ProposedPPUpdates era
ProposedPPUpdates forall a b. (a -> b) -> a -> b
$
forall k a. k -> a -> Map k a
Map.singleton forall c. Crypto c => KeyHash 'Genesis c
testGKeyHash forall a b. (a -> b) -> a -> b
$
forall era. EraPParams era => PParamsUpdate era
emptyPParamsUpdate forall a b. a -> (a -> b) -> b
& forall era.
EraPParams era =>
Lens' (PParamsUpdate era) (StrictMaybe Natural)
ppuNOptL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust Natural
100
)
(Word64 -> EpochNo
EpochNo Word64
0)
mdh :: AuxiliaryDataHash (EraCrypto C)
mdh = forall era.
EraTxAuxData era =>
TxAuxData era -> AuxiliaryDataHash (EraCrypto era)
hashTxAuxData @C forall a b. (a -> b) -> a -> b
$ forall era. Era era => Map Word64 Metadatum -> ShelleyTxAuxData era
TxAuxData.ShelleyTxAuxData forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton Word64
13 (Integer -> Metadatum
TxAuxData.I Integer
17)
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"txbody_full"
( forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [TxIn C_Crypto
genesisTxIn1])
(forall a. a -> StrictSeq a
StrictSeq.singleton ShelleyTxOut C
tout)
(forall a. [a] -> StrictSeq a
StrictSeq.fromList [TxCert C
reg])
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals Map (RewardAccount C_Crypto) Coin
ras)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
500)
(forall a. a -> StrictMaybe a
SJust Update C
up)
(forall a. a -> StrictMaybe a
SJust AuxiliaryDataHash C_Crypto
mdh)
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
8)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S TxIn C_Crypto
genesisTxIn1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxOut C
tout
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Integer -> Coin
Coin Integer
9)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (Word64 -> SlotNo
SlotNo Word64
500)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
4)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S TxCert C
reg
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
5)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Map (RewardAccount C_Crypto) Coin
ras
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
6)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Update C
up
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
7)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S AuxiliaryDataHash C_Crypto
mdh
)
,
let txb :: ShelleyTxBody C
txb =
forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [forall c. TxId c -> TxIx -> TxIn c
TxIn forall c. HashAlgorithm (HASH c) => TxId c
genesisId (HasCallStack => Integer -> TxIx
mkTxIxPartial Integer
1)])
(forall a. a -> StrictSeq a
StrictSeq.singleton forall a b. (a -> b) -> a -> b
$ forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2))
forall a. StrictSeq a
StrictSeq.empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
500)
forall a. StrictMaybe a
SNothing
forall a. StrictMaybe a
SNothing
txbh :: SafeHash C_Crypto EraIndependentTxBody
txbh = (forall x index c.
(HashAnnotated x index c, HashAlgorithm (HASH c)) =>
x -> SafeHash c index
hashAnnotated ShelleyTxBody C
txb)
w :: WitVKey 'Witness C_Crypto
w = forall c (kr :: KeyRole).
(Crypto c, DSignable c (Hash (HASH c) EraIndependentTxBody)) =>
SafeHash c EraIndependentTxBody
-> KeyPair kr c -> WitVKey 'Witness c
mkWitnessVKey @C_Crypto SafeHash C_Crypto EraIndependentTxBody
txbh forall c. Crypto c => KeyPair 'Payment c
testKey1
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"tx_min"
( forall era.
EraTx era =>
TxBody era
-> TxWits era -> StrictMaybe (TxAuxData era) -> ShelleyTx era
ShelleyTx @(ShelleyEra C_Crypto)
ShelleyTxBody C
txb
(forall a. Monoid a => a
mempty {addrWits :: Set (WitVKey 'Witness (EraCrypto C))
addrWits = forall a. a -> Set a
Set.singleton WitVKey 'Witness C_Crypto
w} :: ShelleyTxWits C)
forall a. StrictMaybe a
SNothing
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T Tokens -> Tokens
TkNull
)
,
let txb :: ShelleyTxBody C
txb =
forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [TxIn C_Crypto
genesisTxIn1])
(forall a. a -> StrictSeq a
StrictSeq.singleton forall a b. (a -> b) -> a -> b
$ forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2))
forall a. StrictSeq a
StrictSeq.empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
500)
forall a. StrictMaybe a
SNothing
forall a. StrictMaybe a
SNothing
txbh :: SafeHash C_Crypto EraIndependentTxBody
txbh = forall x index c.
(HashAnnotated x index c, HashAlgorithm (HASH c)) =>
x -> SafeHash c index
hashAnnotated ShelleyTxBody C
txb
w :: WitVKey 'Witness C_Crypto
w = forall c (kr :: KeyRole).
(Crypto c, DSignable c (Hash (HASH c) EraIndependentTxBody)) =>
SafeHash c EraIndependentTxBody
-> KeyPair kr c -> WitVKey 'Witness c
mkWitnessVKey @C_Crypto SafeHash C_Crypto EraIndependentTxBody
txbh forall c. Crypto c => KeyPair 'Payment c
testKey1
s :: MultiSigMap
s = forall k a. k -> a -> Map k a
Map.singleton (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript) (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
txwits :: ShelleyTxWits C
txwits :: ShelleyTxWits C
txwits = forall era. EraTxWits era => TxWits era
mkBasicTxWits @C forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Set (WitVKey 'Witness (EraCrypto era)))
addrTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> Set a
Set.singleton WitVKey 'Witness C_Crypto
w forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Map (ScriptHash (EraCrypto era)) (Script era))
scriptTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ MultiSigMap
s
md :: ShelleyTxAuxData C
md = (forall era. Era era => Map Word64 Metadatum -> ShelleyTxAuxData era
TxAuxData.ShelleyTxAuxData @C) forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton Word64
17 (Integer -> Metadatum
TxAuxData.I Integer
42)
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"tx_full"
(forall era.
EraTx era =>
TxBody era
-> TxWits era -> StrictMaybe (TxAuxData era) -> ShelleyTx era
ShelleyTx @(ShelleyEra C_Crypto) ShelleyTxBody C
txb ShelleyTxWits C
txwits (forall a. a -> StrictMaybe a
SJust ShelleyTxAuxData C
md))
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
3)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
2)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxAuxData C
md
)
,
let prevhash :: PrevHash C_Crypto
prevhash = forall c. HashHeader c -> PrevHash c
BlockHash forall c. Crypto c => HashHeader c
testHeaderHash
vrfVkey :: VerKeyVRF C_Crypto
vrfVkey = forall c. VRFKeyPair c -> VerKeyVRF c
vrfVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @C_Crypto
slot :: SlotNo
slot = Word64 -> SlotNo
SlotNo Word64
33
nonce :: Seed
nonce = Nonce -> SlotNo -> Nonce -> Seed
mkSeed Nonce
seedEta (Word64 -> SlotNo
SlotNo Word64
33) (Word64 -> Nonce
mkNonceFromNumber Word64
0)
nonceProof :: CertifiedVRF (VRF C_Crypto) Nonce
nonceProof :: CertifiedVRF (VRF C_Crypto) Nonce
nonceProof =
forall v a b.
(Signable v a, VRFAlgorithm v, ContextVRF v ~ (),
Coercible b (CertifiedVRF v a)) =>
a -> SignKeyVRF v -> b
mkCertifiedVRF
(forall a. a -> Word64 -> WithResult a
WithResult Seed
nonce Word64
1)
(forall c. VRFKeyPair c -> SignKeyVRF c
vrfSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @C_Crypto)
leaderValue :: Seed
leaderValue = Nonce -> SlotNo -> Nonce -> Seed
mkSeed Nonce
seedL (Word64 -> SlotNo
SlotNo Word64
33) (Word64 -> Nonce
mkNonceFromNumber Word64
0)
leaderProof :: CertifiedVRF (VRF C_Crypto) Natural
leaderProof :: CertifiedVRF (VRF C_Crypto) Natural
leaderProof =
forall v a b.
(Signable v a, VRFAlgorithm v, ContextVRF v ~ (),
Coercible b (CertifiedVRF v a)) =>
a -> SignKeyVRF v -> b
mkCertifiedVRF
(forall a. a -> Word64 -> WithResult a
WithResult Seed
leaderValue Word64
1)
(forall c. VRFKeyPair c -> SignKeyVRF c
vrfSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => VRFKeyPair c
testVRF @C_Crypto)
size :: Word32
size = Word32
0
blockNo :: BlockNo
blockNo = Word64 -> BlockNo
BlockNo Word64
44
bbhash :: Hash (EraCrypto C) EraIndependentBlockBody
bbhash = forall era.
Era era =>
ShelleyTxSeq era -> Hash (EraCrypto era) EraIndependentBlockBody
bbHash @C forall a b. (a -> b) -> a -> b
$ forall era.
(EraTx era, Tx era ~ ShelleyTx era, SafeToHash (TxWits era)) =>
StrictSeq (Tx era) -> ShelleyTxSeq era
ShelleyTxSeq forall a. StrictSeq a
StrictSeq.empty
ocert :: OCert C_Crypto
ocert :: OCert C_Crypto
ocert =
forall c.
VerKeyKES c
-> Word64
-> KESPeriod
-> SignedDSIGN c (OCertSignable c)
-> OCert c
OCert
(forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto)
Word64
0
(Word -> KESPeriod
KESPeriod Word
0)
( forall c a.
(Crypto c, Signable (DSIGN c) a) =>
SignKeyDSIGN (DSIGN c) -> a -> SignedDSIGN c a
signedDSIGN @C_Crypto
(forall (kd :: KeyRole) c. KeyPair kd c -> SignKeyDSIGN (DSIGN c)
sKey (forall c. Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey @C_Crypto))
(forall c. VerKeyKES c -> Word64 -> KESPeriod -> OCertSignable c
OCertSignable (forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
)
protover :: ProtVer
protover = Version -> Natural -> ProtVer
ProtVer forall a. Bounded a => a
minBound Natural
0
in forall a.
(HasCallStack, DecCBOR a, EncCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBOR
Version
shelleyProtVer
String
"block_header_body"
( BHBody
{ bheaderBlockNo :: BlockNo
bheaderBlockNo = BlockNo
blockNo
, bheaderSlotNo :: SlotNo
bheaderSlotNo = SlotNo
slot
, bheaderPrev :: PrevHash C_Crypto
bheaderPrev = PrevHash C_Crypto
prevhash
, bheaderVk :: VKey 'BlockIssuer C_Crypto
bheaderVk = forall (kd :: KeyRole) c. KeyPair kd c -> VKey kd c
vKey forall c. Crypto c => KeyPair 'BlockIssuer c
testBlockIssuerKey
, bheaderVrfVk :: VerKeyVRF C_Crypto
bheaderVrfVk = VerKeyVRF FakeVRF
vrfVkey
, bheaderEta :: CertifiedVRF (VRF C_Crypto) Nonce
bheaderEta = CertifiedVRF (VRF C_Crypto) Nonce
nonceProof
, bheaderL :: CertifiedVRF (VRF C_Crypto) Natural
bheaderL = CertifiedVRF (VRF C_Crypto) Natural
leaderProof
, bsize :: Word32
bsize = Word32
size
, bhash :: Hash C_Crypto EraIndependentBlockBody
bhash = Hash Blake2b_256 EraIndependentBlockBody
bbhash
, bheaderOCert :: OCert C_Crypto
bheaderOCert = OCert C_Crypto
ocert
, bprotver :: ProtVer
bprotver = ProtVer
protover
}
)
( (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen forall a b. (a -> b) -> a -> b
$ Word
9 forall a. Num a => a -> a -> a
+ Word
4 forall a. Num a => a -> a -> a
+ Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S BlockNo
blockNo
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S SlotNo
slot
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S PrevHash C_Crypto
prevhash
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T Tokens -> Tokens
testBlockIssuerKeyTokens
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S VerKeyVRF FakeVRF
vrfVkey
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S CertifiedVRF (VRF C_Crypto) Nonce
nonceProof
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S CertifiedVRF (VRF C_Crypto) Natural
leaderProof
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Word32
size
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Hash Blake2b_256 EraIndependentBlockBody
bbhash
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBORGroup a => a -> ToTokens
G OCert C_Crypto
ocert
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBORGroup a => a -> ToTokens
G ProtVer
protover
)
,
let vkHot :: VerKeyKES C_Crypto
vkHot = forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto
counter :: Word64
counter = Word64
0
kesperiod :: KESPeriod
kesperiod = Word -> KESPeriod
KESPeriod Word
0
signature :: SignedDSIGN C_Crypto (OCertSignable C_Crypto)
signature =
forall c a.
(Crypto c, Signable (DSIGN c) a) =>
SignKeyDSIGN (DSIGN c) -> a -> SignedDSIGN c a
signedDSIGN @C_Crypto
(forall (kd :: KeyRole) c. KeyPair kd c -> SignKeyDSIGN (DSIGN c)
sKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KeyPair 'Payment c
testKey1 @C_Crypto)
(forall c. VerKeyKES c -> Word64 -> KESPeriod -> OCertSignable c
OCertSignable (forall c. KESKeyPair c -> VerKeyKES c
kesVerKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
in forall a.
(DecCBORGroup a, EncCBORGroup a, Show a, Eq a) =>
String -> a -> ToTokens -> TestTree
checkEncodingCBORCBORGroup
String
"operational_cert"
( forall c.
VerKeyKES c
-> Word64
-> KESPeriod
-> SignedDSIGN c (OCertSignable c)
-> OCert c
OCert @C_Crypto
VerKeyKES (MockKES 10)
vkHot
Word64
counter
KESPeriod
kesperiod
SignedDSIGN MockDSIGN (OCertSignable C_Crypto)
signature
)
( forall a. EncCBOR a => a -> ToTokens
S VerKeyKES (MockKES 10)
vkHot
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S Word64
counter
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S KESPeriod
kesperiod
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (forall c. Mock c => Tokens -> Tokens
testOpCertSigTokens @C_Crypto)
)
,
let sig :: (SignedKES (KES C_Crypto) (BHBody C_Crypto))
sig :: SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig = forall v a.
(KESAlgorithm v, Signable v a) =>
ContextKES v -> Word -> a -> SignKeyKES v -> SignedKES v a
signedKES () Word
0 (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) (forall c. KESKeyPair c -> SignKeyKES c
kesSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto)
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"block_header"
(forall c.
Crypto c =>
BHBody c -> SignedKES c (BHBody c) -> BHeader c
BHeader (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig)
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (forall era.
(EraTx era, PreAlonzo era, ExMock (EraCrypto era),
Tx era ~ ShelleyTx era) =>
Tokens -> Tokens
testBHBSigTokens @C)
)
,
let sig :: (SignedKES (KES C_Crypto) (BHBody C_Crypto))
sig :: SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig = forall v a.
(KESAlgorithm v, Signable v a) =>
ContextKES v -> Word -> a -> SignKeyKES v -> SignedKES v a
signedKES () Word
0 (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) (forall c. KESKeyPair c -> SignKeyKES c
kesSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto)
bh :: BHeader C_Crypto
bh = forall c.
Crypto c =>
BHBody c -> SignedKES c (BHBody c) -> BHeader c
BHeader (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig
txns :: ShelleyTxSeq C
txns = forall era.
(EraTx era, Tx era ~ ShelleyTx era, SafeToHash (TxWits era)) =>
StrictSeq (Tx era) -> ShelleyTxSeq era
ShelleyTxSeq forall a. StrictSeq a
StrictSeq.Empty
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"empty_block"
(forall era h.
(Era era, EncCBORGroup (TxSeq era), EncCBOR h) =>
h -> TxSeq era -> Block h era
Block @C BHeader C_Crypto
bh ShelleyTxSeq C
txns)
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen Word
4)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S BHeader C_Crypto
bh
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkListLen Word
0 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkMapLen Word
0)
)
,
let sig :: SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig :: SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig = forall v a.
(KESAlgorithm v, Signable v a) =>
ContextKES v -> Word -> a -> SignKeyKES v -> SignedKES v a
signedKES () Word
0 (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) (forall c. KESKeyPair c -> SignKeyKES c
kesSignKey forall a b. (a -> b) -> a -> b
$ forall c. Crypto c => KESKeyPair c
testKESKeys @C_Crypto)
bh :: BHeader C_Crypto
bh = forall c.
Crypto c =>
BHBody c -> SignedKES c (BHBody c) -> BHeader c
BHeader (forall era c.
(EraTx era, PreAlonzo era, ExMock c, c ~ EraCrypto era,
Tx era ~ ShelleyTx era) =>
BHBody c
testBHB @C) SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig
tout :: StrictSeq (ShelleyTxOut C)
tout = forall a. a -> StrictSeq a
StrictSeq.singleton forall a b. (a -> b) -> a -> b
$ forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr (EraCrypto era) -> Value era -> ShelleyTxOut era
ShelleyTxOut @C forall c. Crypto c => Addr c
testAddrE (Integer -> Coin
Coin Integer
2)
txb :: Word64 -> ShelleyTxBody C
txb :: Word64 -> ShelleyTxBody C
txb Word64
s =
forall era.
(EraTxOut era, EncCBOR (TxCert era)) =>
Set (TxIn (EraCrypto era))
-> StrictSeq (TxOut era)
-> StrictSeq (TxCert era)
-> Withdrawals (EraCrypto era)
-> Coin
-> SlotNo
-> StrictMaybe (Update era)
-> StrictMaybe (AuxiliaryDataHash (EraCrypto era))
-> ShelleyTxBody era
ShelleyTxBody @C
(forall a. Ord a => [a] -> Set a
Set.fromList [TxIn C_Crypto
genesisTxIn1])
StrictSeq (ShelleyTxOut C)
tout
forall a. StrictSeq a
StrictSeq.empty
(forall c. Map (RewardAccount c) Coin -> Withdrawals c
Withdrawals forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
9)
(Word64 -> SlotNo
SlotNo Word64
s)
forall a. StrictMaybe a
SNothing
forall a. StrictMaybe a
SNothing
txb1, txb2, txb3, txb4, txb5 :: ShelleyTxBody C
txb1 :: ShelleyTxBody C
txb1 = Word64 -> ShelleyTxBody C
txb Word64
500
txb2 :: ShelleyTxBody C
txb2 = Word64 -> ShelleyTxBody C
txb Word64
501
txb3 :: ShelleyTxBody C
txb3 = Word64 -> ShelleyTxBody C
txb Word64
502
txb4 :: ShelleyTxBody C
txb4 = Word64 -> ShelleyTxBody C
txb Word64
503
txb5 :: ShelleyTxBody C
txb5 = Word64 -> ShelleyTxBody C
txb Word64
504
w1 :: WitVKey 'Witness C_Crypto
w1 = forall c (kr :: KeyRole).
(Crypto c, DSignable c (Hash (HASH c) EraIndependentTxBody)) =>
SafeHash c EraIndependentTxBody
-> KeyPair kr c -> WitVKey 'Witness c
mkWitnessVKey (forall x index c.
(HashAnnotated x index c, HashAlgorithm (HASH c)) =>
x -> SafeHash c index
hashAnnotated ShelleyTxBody C
txb1) forall c. Crypto c => KeyPair 'Payment c
testKey1
w2 :: WitVKey 'Witness C_Crypto
w2 = forall c (kr :: KeyRole).
(Crypto c, DSignable c (Hash (HASH c) EraIndependentTxBody)) =>
SafeHash c EraIndependentTxBody
-> KeyPair kr c -> WitVKey 'Witness c
mkWitnessVKey (forall x index c.
(HashAnnotated x index c, HashAlgorithm (HASH c)) =>
x -> SafeHash c index
hashAnnotated ShelleyTxBody C
txb1) forall c (kr :: KeyRole). Crypto c => KeyPair kr c
testKey2
ws :: Set (WitVKey 'Witness C_Crypto)
ws = forall a. Ord a => [a] -> Set a
Set.fromList [WitVKey 'Witness C_Crypto
w1, WitVKey 'Witness C_Crypto
w2]
tx1, tx2, tx3, tx4, tx5 :: ShelleyTx C
tx1 :: ShelleyTx C
tx1 =
forall era. EraTx era => TxBody era -> Tx era
mkBasicTx ShelleyTxBody C
txb1
forall a b. a -> (a -> b) -> b
& forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL @C forall s t a b. ASetter s t a b -> b -> s -> t
.~ (forall era. EraTxWits era => TxWits era
mkBasicTxWits @C forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Set (WitVKey 'Witness (EraCrypto era)))
addrTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> Set a
Set.singleton WitVKey 'Witness C_Crypto
w1)
tx2 :: ShelleyTx C
tx2 =
forall era. EraTx era => TxBody era -> Tx era
mkBasicTx ShelleyTxBody C
txb2
forall a b. a -> (a -> b) -> b
& forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL @C forall s t a b. ASetter s t a b -> b -> s -> t
.~ (forall era. EraTxWits era => TxWits era
mkBasicTxWits @C forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Set (WitVKey 'Witness (EraCrypto era)))
addrTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Set (WitVKey 'Witness C_Crypto)
ws)
tx3 :: ShelleyTx C
tx3 =
forall era. EraTx era => TxBody era -> Tx era
mkBasicTx ShelleyTxBody C
txb3
forall a b. a -> (a -> b) -> b
& forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL @C
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ( forall era. EraTxWits era => TxWits era
mkBasicTxWits @C
forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Map (ScriptHash (EraCrypto era)) (Script era))
scriptTxWitsL
forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall k a. k -> a -> Map k a
Map.singleton (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript) forall c. Crypto c => MultiSig (ShelleyEra c)
testScript
)
ss :: MultiSigMap
ss =
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript, forall c. Crypto c => MultiSig (ShelleyEra c)
testScript)
, (forall era.
EraScript era =>
Script era -> ScriptHash (EraCrypto era)
hashScript @C forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2, forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2)
]
tx4 :: ShelleyTx C
tx4 =
forall era. EraTx era => TxBody era -> Tx era
mkBasicTx ShelleyTxBody C
txb4
forall a b. a -> (a -> b) -> b
& forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL @C forall s t a b. ASetter s t a b -> b -> s -> t
.~ (forall era. EraTxWits era => TxWits era
mkBasicTxWits @C forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Map (ScriptHash (EraCrypto era)) (Script era))
scriptTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ MultiSigMap
ss)
tx5MD :: ShelleyTxAuxData C
tx5MD = forall era. Era era => Map Word64 Metadatum -> ShelleyTxAuxData era
TxAuxData.ShelleyTxAuxData @C forall a b. (a -> b) -> a -> b
$ forall k a. k -> a -> Map k a
Map.singleton Word64
17 (Integer -> Metadatum
TxAuxData.I Integer
42)
tx5 :: ShelleyTx C
tx5 =
forall era. EraTx era => TxBody era -> Tx era
mkBasicTx ShelleyTxBody C
txb5
forall a b. a -> (a -> b) -> b
& forall era. EraTx era => Lens' (Tx era) (TxWits era)
witsTxL @C forall s t a b. ASetter s t a b -> b -> s -> t
.~ (forall era. EraTxWits era => TxWits era
mkBasicTxWits @C forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Set (WitVKey 'Witness (EraCrypto era)))
addrTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ Set (WitVKey 'Witness C_Crypto)
ws forall a b. a -> (a -> b) -> b
& forall era.
EraTxWits era =>
Lens' (TxWits era) (Map (ScriptHash (EraCrypto era)) (Script era))
scriptTxWitsL forall s t a b. ASetter s t a b -> b -> s -> t
.~ MultiSigMap
ss)
forall a b. a -> (a -> b) -> b
& forall era.
EraTx era =>
Lens' (Tx era) (StrictMaybe (TxAuxData era))
auxDataTxL @C forall s t a b. ASetter s t a b -> b -> s -> t
.~ forall a. a -> StrictMaybe a
SJust ShelleyTxAuxData C
tx5MD
txns :: ShelleyTxSeq C
txns = forall era.
(EraTx era, Tx era ~ ShelleyTx era, SafeToHash (TxWits era)) =>
StrictSeq (Tx era) -> ShelleyTxSeq era
ShelleyTxSeq forall a b. (a -> b) -> a -> b
$ forall a. [a] -> StrictSeq a
StrictSeq.fromList [ShelleyTx C
tx1, ShelleyTx C
tx2, ShelleyTx C
tx3, ShelleyTx C
tx4, ShelleyTx C
tx5]
in forall a.
(HasCallStack, DecCBOR (Annotator a), ToCBOR a, Show a, Eq a) =>
Version -> String -> a -> ToTokens -> TestTree
checkEncodingCBORAnnotated
Version
shelleyProtVer
String
"rich_block"
(forall era h.
(Era era, EncCBORGroup (TxSeq era), EncCBOR h) =>
h -> TxSeq era -> Block h era
Block @C BHeader C_Crypto
bh ShelleyTxSeq C
txns)
( ((Tokens -> Tokens) -> ToTokens
T forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen Word
4)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S BHeader C_Crypto
bh
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
5)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb1
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb2
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb3
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb4
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxBody C
txb5
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
5)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w2
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
1)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2 @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
2)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
0)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w2
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S WitVKey 'Witness C_Crypto
w1
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkWord Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkListLen Word
2)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript2 @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S (forall c. Crypto c => MultiSig (ShelleyEra c)
testScript @C_Crypto)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Word -> Tokens -> Tokens
TkMapLen Word
1)
forall a. Semigroup a => a -> a -> a
<> (Tokens -> Tokens) -> ToTokens
T (Int -> Tokens -> Tokens
TkInt Int
4)
forall a. Semigroup a => a -> a -> a
<> forall a. EncCBOR a => a -> ToTokens
S ShelleyTxAuxData C
tx5MD
)
, let actual :: ByteString
actual =
forall a. ToCBOR a => a -> ByteString
Plain.serialize' forall a b. (a -> b) -> a -> b
$ forall era. ShelleyLedgerExamples era -> NewEpochState era
Ex.sleNewEpochState ShelleyLedgerExamples Shelley
Ex.ledgerExamplesShelley
expected :: ByteString
expected = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. HasCallStack => String -> a
error forall a. a -> a
id forall a b. (a -> b) -> a -> b
$ ByteString -> Either String ByteString
B16.decode ByteString
expectedHex
actualHex :: ByteString
actualHex = ByteString -> ByteString
B16.encode ByteString
actual
expectedHex :: ByteString
expectedHex =
forall a. Monoid a => [a] -> a
mconcat
[ ByteString
"8700a1581ce0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b047b0825410aa158"
, ByteString
"1ca646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a03848219271019"
, ByteString
"03e8828383a0a00084a0a0a0a08482a0a0a0a084a0a0000086a1825820ee155ace9c4029"
, ByteString
"2074cb6aff8c9ccdd273c81648ff1149ef36bcea6ebb8a3e250082583900cb9358529df4"
, ByteString
"729c3246a2a033cb9821abbfd16de4888005904abc410d6a577e9441ad8ed9663931906e"
, ByteString
"4d43ece8f82c712b1d0235affb060a1903e80185a0a092000000190800000000001864d8"
, ByteString
"1e820001d81e820001d81e820001d81e8200018100020001009200000019080000000000"
, ByteString
"1864d81e820001d81e820001d81e820001d81e820001810002000000810082a0a0008483"
, ByteString
"a0a0a083a0a0a083a0a0a00082a000818300880082020082a000000000a0a0840185a080"
, ByteString
"00820200a0a082a0a082a1581ce0a714319812c3f773ba04ec5d6b3ffcd5aad85006805b"
, ByteString
"047b08254183820101015820c5e21ab1c9f6022d81c3b25e3436cb7f1df77f9652ae3e13"
, ByteString
"10c28e621dd87b4c01a0"
]
in String -> Assertion -> TestTree
testCase String
"ledger state golden test" forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (ByteString
actual forall a. Eq a => a -> a -> Bool
== ByteString
expected) forall a b. (a -> b) -> a -> b
$
forall a. HasCallStack => String -> IO a
assertFailure forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc AnsiStyle -> String
ansiDocToString forall a b. (a -> b) -> a -> b
$
forall ann. [Doc ann] -> Doc ann
Pretty.vsep
[ Doc AnsiStyle
"Expected: " forall a. Semigroup a => a -> a -> a
<> forall a ann. Show a => a -> Doc ann
Pretty.viaShow ByteString
expectedHex
, Doc AnsiStyle
"Actual: " forall a. Semigroup a => a -> a -> a
<> forall a ann. Show a => a -> Doc ann
Pretty.viaShow ByteString
actualHex
, Doc AnsiStyle
"Difference:"
, forall ann. Int -> Doc ann -> Doc ann
Pretty.indent Int
2 forall a b. (a -> b) -> a -> b
$ forall a. ToExpr a => a -> a -> Doc AnsiStyle
diffExpr (ByteString -> CBORBytes
CBORBytes ByteString
expected) (ByteString -> CBORBytes
CBORBytes ByteString
actual)
]
]
where
genesisTxIn1 :: TxIn C_Crypto
genesisTxIn1 = forall c. TxId c -> TxIx -> TxIn c
TxIn @C_Crypto forall c. HashAlgorithm (HASH c) => TxId c
genesisId (HasCallStack => Integer -> TxIx
mkTxIxPartial Integer
1)