Skip to content

Commit 7d2129d

Browse files
jasagredoamesgen
authored andcommitted
Define blockQueryIsSupportedOnVersion for test blocks
1 parent d5acb59 commit 7d2129d

9 files changed

Lines changed: 11 additions & 8 deletions

File tree

  • ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley
  • ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/HardFork/Combinator
  • ouroboros-consensus/src

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/Consensus/Shelley/Generators.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,5 @@ instance CanMock proto era
278278
=> Arbitrary (WithVersion ShelleyNodeToClientVersion (SomeSecond BlockQuery (ShelleyBlock proto era))) where
279279
arbitrary = do
280280
query@(SomeSecond q) <- arbitrary
281-
version <- arbitrary `suchThat` querySupportedVersion q
281+
version <- arbitrary `suchThat` blockQueryIsSupportedOnVersion q
282282
return $ WithVersion version query

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/HardFork/Combinator/A.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ data instance BlockQuery BlockA result
358358

359359
instance BlockSupportsLedgerQuery BlockA where
360360
answerBlockQuery _ qry = case qry of {}
361+
blockQueryIsSupportedOnVersion qry _ = case qry of {}
361362

362363
instance SameDepIndex (BlockQuery BlockA) where
363364
sameDepIndex qry _qry' = case qry of {}

ouroboros-consensus-diffusion/test/consensus-test/Test/Consensus/HardFork/Combinator/B.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ data instance BlockQuery BlockB result
291291

292292
instance BlockSupportsLedgerQuery BlockB where
293293
answerBlockQuery _ qry = case qry of {}
294+
blockQueryIsSupportedOnVersion qry _ = case qry of {}
294295

295296
instance SameDepIndex (BlockQuery BlockB) where
296297
sameDepIndex qry _qry' = case qry of {}

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Dual.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ instance (Typeable m, Typeable a)
528528
-- | Not used in the tests: no constructors
529529
instance Bridge m a => BlockSupportsLedgerQuery (DualBlock m a) where
530530
answerBlockQuery _ = \case {}
531+
blockQueryIsSupportedOnVersion qry _ = case qry of {}
531532

532533
instance SameDepIndex (BlockQuery (DualBlock m a)) where
533534
sameDepIndex = \case {}

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Roundtrip.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ roundtrip_all
214214
, SerialiseNodeToClientConstraints blk
215215

216216
, Show (BlockNodeToNodeVersion blk)
217-
, Show (BlockNodeToClientVersion blk)
218217

219218
, StandardHash blk
220219
, GetHeader blk
@@ -263,7 +262,6 @@ roundtrip_all_skipping
263262
, SerialiseNodeToClientConstraints blk
264263

265264
, Show (BlockNodeToNodeVersion blk)
266-
, Show (BlockNodeToClientVersion blk)
267265

268266
, StandardHash blk
269267
, GetHeader blk
@@ -534,7 +532,6 @@ roundtrip_SerialiseNodeToNode ccfg =
534532
roundtrip_SerialiseNodeToClient
535533
:: forall blk.
536534
( SerialiseNodeToClientConstraints blk
537-
, Show (BlockNodeToClientVersion blk)
538535
, ArbitraryWithVersion (BlockNodeToClientVersion blk) blk
539536
, ArbitraryWithVersion (BlockNodeToClientVersion blk) (GenTx blk)
540537
, ArbitraryWithVersion (BlockNodeToClientVersion blk) (ApplyTxErr blk)

ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/TestBlock.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ data instance BlockQuery TestBlock result where
650650
instance BlockSupportsLedgerQuery TestBlock where
651651
answerBlockQuery _cfg QueryLedgerTip (ExtLedgerState TestLedger { lastAppliedPoint } _) =
652652
lastAppliedPoint
653+
blockQueryIsSupportedOnVersion QueryLedgerTip = const True
653654

654655
instance SameDepIndex (BlockQuery TestBlock) where
655656
sameDepIndex QueryLedgerTip QueryLedgerTip = Just Refl

ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Ledger/Block.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ instance MockProtocolSpecific c ext => BlockSupportsLedgerQuery (SimpleBlock c e
534534
castPoint
535535
. ledgerTipPoint
536536
. ledgerState
537+
blockQueryIsSupportedOnVersion QueryLedgerTip = const True
537538

538539
instance SameDepIndex (BlockQuery (SimpleBlock c ext)) where
539540
sameDepIndex QueryLedgerTip QueryLedgerTip = Just Refl

ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ import Ouroboros.Consensus.Util.RedundantConstraints
3838
RunNode instance for the mock ledger
3939
-------------------------------------------------------------------------------}
4040

41-
instance HasNetworkProtocolVersion (SimpleBlock SimpleMockCrypto ext) where
42-
-- Use defaults
43-
4441
instance SupportedNetworkProtocolVersion (SimpleBlock SimpleMockCrypto ext) where
4542
supportedNodeToNodeVersions _ = Map.singleton maxBound ()
4643
supportedNodeToClientVersions _ = Map.singleton maxBound ()

ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node/Serialisation.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Ouroboros.Consensus.Ledger.Abstract
2323
import Ouroboros.Consensus.Ledger.SupportsMempool
2424
import Ouroboros.Consensus.Mock.Ledger
2525
import Ouroboros.Consensus.Mock.Node.Abstract
26+
import Ouroboros.Consensus.Node.NetworkProtocolVersion
2627
import Ouroboros.Consensus.Node.Run
2728
import Ouroboros.Consensus.Node.Serialisation
2829
import Ouroboros.Consensus.Storage.Serialisation
@@ -66,6 +67,9 @@ instance DecodeDisk (MockBlock ext) (AnnTip (MockBlock ext)) where
6667
possible.
6768
-------------------------------------------------------------------------------}
6869

70+
instance HasNetworkProtocolVersion (MockBlock ext) where
71+
-- Use defaults
72+
6973
instance Serialise ext => SerialiseNodeToNodeConstraints (MockBlock ext) where
7074
estimateBlockSize hdr =
7175
7 {- CBOR-in-CBOR -} + 1 {- encodeListLen 2 -} + hdrSize + bodySize
@@ -95,7 +99,7 @@ instance SerialiseNodeToNode (MockBlock ext) (GenTxId (MockBlock ext))
9599
possible.
96100
-------------------------------------------------------------------------------}
97101

98-
instance (Serialise ext, Typeable ext, Serialise (MockLedgerConfig SimpleMockCrypto ext))
102+
instance (Serialise ext, Typeable ext, Serialise (MockLedgerConfig SimpleMockCrypto ext), MockProtocolSpecific SimpleMockCrypto ext)
99103
=> SerialiseNodeToClientConstraints (MockBlock ext)
100104

101105
instance Serialise ext => SerialiseNodeToClient (MockBlock ext) (MockBlock ext) where

0 commit comments

Comments
 (0)