Skip to content

Commit 462d9b7

Browse files
committed
Resolve PR comments
1 parent c311626 commit 462d9b7

File tree

6 files changed

+78
-12
lines changed

6 files changed

+78
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Patch
9+
10+
- A bullet item for the Patch category.
11+
12+
-->
13+
### Non-Breaking
14+
15+
- Add new `ProtocolInfo` module to `cardano-testlib`, containing utilities for
16+
creating Cardano `ProtocolInfo`s for testing purposes.
17+
18+
<!--
19+
### Breaking
20+
21+
- A bullet item for the Breaking category.
22+
23+
-->

ouroboros-consensus-cardano/src/cardano-testlib/Test/Consensus/Cardano/ProtocolInfo.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ stayInByron =
137137
versionZero :: SL.Version
138138
versionZero = SL.natVersion @0
139139

140+
-- TODO: could be simplified once we implement something like
141+
-- ouroboros-network#4115.
140142
hardForkInto :: Era -> HardForkSpec
141143
hardForkInto Byron = stayInByron
142144
hardForkInto Shelley =
@@ -280,8 +282,6 @@ mkTestProtocolInfo
280282
protocolInfoCardano
281283
ProtocolParamsByron {
282284
byronGenesis = genesisByron
283-
-- Trivialize the PBFT signature window so that the forks induced by
284-
-- the network partition are as deep as possible.
285285
, byronPbftSignatureThreshold = aByronPbftSignatureThreshold
286286
, byronProtocolVersion = aByronProtocolVersion
287287
, byronSoftwareVersion = softVerByron

ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/MiniProtocol/LocalTxSubmission/ByteStringTxParser.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Test.Consensus.Cardano.MiniProtocol.LocalTxSubmission.ByteStringTxParser
1414
) where
1515

1616

17+
import Cardano.Chain.Epoch.File (mainnetEpochSlots)
1718
import Cardano.Chain.Slotting (EpochSlots (..))
1819
import Codec.CBOR.Read (DeserialiseFailure, deserialiseFromBytes)
1920
import Data.ByteString.Base16.Lazy (decodeLenient)
@@ -32,7 +33,7 @@ import Text.Pretty.Simple (pPrint)
3233
cardanoCodecCfg :: CodecConfig (CardanoBlock StandardCrypto)
3334
cardanoCodecCfg =
3435
CardanoCodecConfig
35-
(ByronCodecConfig (EpochSlots 21600))
36+
(ByronCodecConfig mainnetEpochSlots)
3637
ShelleyCodecConfig
3738
ShelleyCodecConfig
3839
ShelleyCodecConfig
@@ -45,7 +46,13 @@ deserialiseTx ::
4546
-> Either DeserialiseFailure (BL.ByteString, GenTx (CardanoBlock StandardCrypto))
4647
deserialiseTx = deserialiseFromBytes cborDecoder . decodeLenient
4748
where
48-
cborDecoder = decodeNodeToClient cardanoCodecCfg CardanoNodeToClientVersion11
49+
cborDecoder = decodeNodeToClient cardanoCodecCfg latestReleasedBlockNodeToClientVersion
50+
latestReleasedBlockNodeToClientVersion =
51+
case latestReleasedNodeVersion p of
52+
(_, Just n2c) -> supportedNodeToClientVersions p Map.! n2c
53+
_ -> error "no latest released Cardano NodeToClient version"
54+
where
55+
p = Proxy @(CardanoBlock StandardCrypto)
4956

5057
printDeserializedTx :: BL.ByteString -> IO ()
5158
printDeserializedTx bs =

ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/MiniProtocol/LocalTxSubmission/Server.hs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,23 @@ tests =
7171

7272
eraIndex @=? fromEnum era
7373

74-
mempool <- Mocked.openMockedMempool (Mempool.mkCapacityBytesOverride 100_000) -- We don't want the mempool to fill up during these tests.
75-
nullTracer -- Use 'show >$< stdoutTracer' for debugging.
76-
LedgerSupportsMempool.txInBlockSize
77-
Mocked.MempoolAndModelParams {
78-
Mocked.immpInitialState = ledgerState $ pInfoInitLedger pInfo
79-
, Mocked.immpLedgerConfig = topLevelConfigLedger $ pInfoConfig pInfo
80-
}
74+
let
75+
-- We don't want the mempool to fill up during these tests.
76+
capcityBytesOverride = Mempool.mkCapacityBytesOverride 100_000
77+
-- Use 'show >$< stdoutTracer' for debugging.
78+
tracer = nullTracer
79+
mempoolParams = Mocked.MempoolAndModelParams {
80+
Mocked.immpInitialState =
81+
ledgerState $ pInfoInitLedger pInfo
82+
, Mocked.immpLedgerConfig =
83+
topLevelConfigLedger $ pInfoConfig pInfo
84+
}
85+
86+
mempool <- Mocked.openMockedMempool
87+
capcityBytesOverride
88+
tracer
89+
LedgerSupportsMempool.txInBlockSize
90+
mempoolParams
8191

8292
mempool `should_process` [ _137 ]
8393
where

ouroboros-consensus-cardano/test/cardano-test/Test/ThreadNet/Cardano.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ mkProtocolCardanoAndHardForkTxs
486486
initialNonce
487487
genesisByron
488488
generatedSecretsByron
489-
(Just $ PBftSignatureThreshold 1) -- Trivialize the PBFT signature window so that the forks induced by the network partition are as deep as possible.
489+
(Just $ PBftSignatureThreshold 1) -- Trivialize the PBFT signature
490+
-- window so that the forks induced by
491+
-- the network partition are as deep
492+
-- as possible.
490493
HardForkSpec {
491494
shelleyHardForkSpec =
492495
( SL.ProtVer shelleyMajorVersion 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
-->
6+
7+
<!--
8+
### Patch
9+
10+
- A bullet item for the Patch category.
11+
12+
-->
13+
### Non-Breaking
14+
15+
- Add new `mempool-test-utils` public library containing utilities for opening a
16+
mocked mempool.
17+
18+
<!--
19+
### Breaking
20+
21+
- A bullet item for the Breaking category.
22+
23+
-->

0 commit comments

Comments
 (0)