Skip to content

Commit

Permalink
Define CBOR instances for mock Addr
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Apr 16, 2024
1 parent cbfbd69 commit 62a63d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ouroboros-consensus/ouroboros-consensus.cabal
Expand Up @@ -464,6 +464,7 @@ library unstable-mock-block
ouroboros-network-api,
ouroboros-network-mock,
serialise,
text,
time,
unstable-consensus-testlib,

Expand Down
Expand Up @@ -6,11 +6,13 @@ module Ouroboros.Consensus.Mock.Ledger.Address (
, mkAddrDist
) where

import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Codec.Serialise (Serialise)
import Control.DeepSeq (NFData)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.String
import Data.Text (pack, unpack)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.NodeId (NodeId (..))
Expand All @@ -28,6 +30,12 @@ newtype Addr = Addr String
, NoThunks
)

instance ToCBOR Addr where
toCBOR (Addr a) = toCBOR $ pack a

instance FromCBOR Addr where
fromCBOR = Addr . unpack <$> fromCBOR

instance Condense Addr where
condense (Addr addr) = addr

Expand Down

0 comments on commit 62a63d8

Please sign in to comment.