Skip to content

Commit

Permalink
Added txs to the testnet diffusion sim
Browse files Browse the repository at this point in the history
  • Loading branch information
bolt12 committed Aug 22, 2024
1 parent eecc50f commit da7ff95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ unit_4177 = prop_inbound_governor_transitions_coverage absNoAttenuation script
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [JoinNetwork 1.742857142857
,Reconfigure 6.33333333333 [(1,1,Map.fromList [(RelayAccessDomain "test2" 65535,(DoAdvertisePeer, IsNotTrustable))]),
(1,1,Map.fromList [(RelayAccessAddress "0:6:0:3:0:6:0:5" 65530,(DoAdvertisePeer, IsNotTrustable))
Expand Down Expand Up @@ -769,6 +770,7 @@ unit_4177 = prop_inbound_governor_transitions_coverage absNoAttenuation script
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [JoinNetwork 0.183783783783
,Reconfigure 4.533333333333 [(1,1,Map.fromList [])]
]
Expand Down Expand Up @@ -1351,6 +1353,7 @@ unit_4191 = testWithIOSim prop_diffusion_dns_can_recover 125000 absInfo script
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [ JoinNetwork 6.710144927536
, Kill 7.454545454545
, JoinNetwork 10.763157894736
Expand Down Expand Up @@ -2280,7 +2283,8 @@ async_demotion_network_script =
= False,
naPeerSharing = PeerSharingDisabled,
naFetchModeScript = singletonScript FetchModeDeadline,
naTxDecisionPolicy = defaultTxDecisionPolicy
naTxDecisionPolicy = defaultTxDecisionPolicy,
naTxs = []
}


Expand Down Expand Up @@ -2725,6 +2729,7 @@ prop_unit_4258 =
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [ JoinNetwork 4.166666666666,
Kill 0.3,
JoinNetwork 1.517857142857,
Expand Down Expand Up @@ -2766,6 +2771,7 @@ prop_unit_4258 =
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [ JoinNetwork 3.384615384615,
Reconfigure 3.583333333333 [(1,1,Map.fromList [(RelayAccessAddress "0.0.0.4" 9,(DoNotAdvertisePeer, IsNotTrustable))])],
Kill 15.55555555555,
Expand Down Expand Up @@ -2829,6 +2835,7 @@ prop_unit_reconnect =
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [ JoinNetwork 0
])
, (NodeArgs
Expand Down Expand Up @@ -2857,6 +2864,7 @@ prop_unit_reconnect =
False
(Script (FetchModeDeadline :| []))
defaultTxDecisionPolicy
[]
, [ JoinNetwork 10
])
]
Expand Down Expand Up @@ -3263,7 +3271,8 @@ unit_peer_sharing =
naChainSyncEarlyExit = False,
naChainSyncExitOnBlockNo = Nothing,
naFetchModeScript = singletonScript FetchModeDeadline,
naTxDecisionPolicy = defaultTxDecisionPolicy
naTxDecisionPolicy = defaultTxDecisionPolicy,
naTxs = []
}

script = DiffusionScript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ import Ouroboros.Network.Protocol.TxSubmission2.Codec (byteLimitsTxSubmission2,
import Ouroboros.Network.TxSubmission.Inbound.Policy (TxDecisionPolicy)
import Test.Ouroboros.Network.LedgerPeers (LedgerPools (..), genLedgerPoolsFrom)
import Test.Ouroboros.Network.PeerSelection.LocalRootPeers ()
import Test.Ouroboros.Network.TxSubmission.Common (ArbTxDecisionPolicy (..))
import Test.Ouroboros.Network.TxSubmission.Common (ArbTxDecisionPolicy (..),
Tx (..))
import Test.QuickCheck

-- | Diffusion Simulator Arguments
Expand Down Expand Up @@ -219,6 +220,7 @@ data NodeArgs =
, naChainSyncEarlyExit :: Bool
, naFetchModeScript :: Script FetchMode
, naTxDecisionPolicy :: TxDecisionPolicy
, naTxs :: [Tx String]
}

instance Show NodeArgs where
Expand Down Expand Up @@ -434,6 +436,10 @@ genNodeArgs relays minConnected localRootPeers relay = flip suchThat hasUpstream
let bootstrapPeersDomain = Script (firstBootstrapPeer :| bootstrapPeers)

ArbTxDecisionPolicy decisionPolicy <- arbitrary
nTxs <- chooseInt (0, 10)
placeholderTxs <- vectorOf nTxs (arbitrary :: Gen (Tx Int))
let txs = map (\(t, i) -> t { getTxId = show relay ++ " " ++ show i })
(zip placeholderTxs [0 :: Int ..])

return
$ NodeArgs
Expand All @@ -455,6 +461,7 @@ genNodeArgs relays minConnected localRootPeers relay = flip suchThat hasUpstream
, naPeerSharing = peerSharing
, naFetchModeScript = fetchModeScript
, naTxDecisionPolicy = decisionPolicy
, naTxs = txs
}
where
hasActive :: SmallPeerSelectionTargets -> Bool
Expand Down

0 comments on commit da7ff95

Please sign in to comment.