core.testing / Simulation

# Simulation

`abstract class Simulation`

Base class for network simulations that are based on the unit test / mock environment.

Sets up some nodes that can run protocols between each other, and exposes their progress trackers. Provides banks in a few cities around the world.

### Types

BankFactory | `inner class BankFactory : Factory`
NetworkMapNodeFactory | `object NetworkMapNodeFactory : Factory`
RatesOracleFactory | `object RatesOracleFactory : Factory`
RegulatorFactory | `object RegulatorFactory : Factory`
SimulatedNode | `open class SimulatedNode : MockNode`
TimestampingNodeFactory | `object TimestampingNodeFactory : Factory`

### Constructors

<init> | `Simulation(runAsync: Boolean, latencyInjector: LatencyCalculator?)` Base class for network simulations that are based on the unit test / mock environment.

### Properties

allProtocolSteps | `val allProtocolSteps: <ERROR CLASS><<ERROR CLASS><SimulatedNode, Change>>`
bankFactory | `val bankFactory: BankFactory`
bankLocations | `val bankLocations: <ERROR CLASS>`
banks | `val banks: List<SimulatedNode>`
currentDay | `var currentDay: LocalDate` The current simulated date. By default this never changes. If you want it to change, you should do so from within your overridden iterate call. Changes in the current day surface in the dateChanges observable.
dateChanges | `val dateChanges: <ERROR CLASS><LocalDate>`
doneSteps | `val doneSteps: <ERROR CLASS><Collection<SimulatedNode>>`
extraNodeLabels | `val extraNodeLabels: MutableMap<SimulatedNode, String>` A place for simulations to stash human meaningful text about what the node is "thinking", which might appear in the UI somewhere.
latencyInjector | `val latencyInjector: LatencyCalculator?`
network | `val network: MockNetwork`
networkMap | `val networkMap: SimulatedNode`
ratesOracle | `val ratesOracle: SimulatedNode`
regulators | `val regulators: List<SimulatedNode>`
runAsync | `val runAsync: Boolean`
serviceProviders | `val serviceProviders: List<SimulatedNode>`
timestamper | `val timestamper: SimulatedNode`

### Functions

iterate | `open fun iterate(): Unit` Iterates the simulation by one step.
linkConsensus | `fun linkConsensus(nodes: Collection<SimulatedNode>, protocol: ProtocolLogic<*>): Unit`
linkProtocolProgress | `fun linkProtocolProgress(node: SimulatedNode, protocol: ProtocolLogic<*>): Unit`
start | `open fun start(): Unit`
startTradingCircle | `fun startTradingCircle(tradeBetween: (Int, Int) -> <ERROR CLASS><out <ERROR CLASS>>): Unit` Given a function that returns a future, iterates that function with arguments like (0, 1), (1, 2), (2, 3) etc each time the returned future completes.
stop | `fun stop(): Unit`

### Inheritors

IRSSimulation | `class IRSSimulation : Simulation` A simulation in which banks execute interest rate swaps with each other, including the fixing events.
TradeSimulation | `class TradeSimulation : Simulation` Simulates a never ending series of trades that go pair-wise through the banks (e.g. A and B trade with each other, then B and C trade with each other, then C and A etc).