ImmutableEmulator

scalus.testing.ImmutableEmulator
See theImmutableEmulator companion object
final case class ImmutableEmulator

An immutable emulator for Cardano transactions.

Unlike scalus.cardano.node.Emulator, this emulator is fully immutable: every state-changing operation (submit, produceBlock, rollback, setSlot) returns a new ImmutableEmulator instance, leaving the original unchanged.

It wraps the same EmulatorState the mutable emulator runs on, so the chain, the mempool and the presets of scalus.cardano.node.emulator.ChainConfig behave the same way, spec [SF-11]. The validators and mutators stay parameters, spec [SF-12]. Every transition goes through the EmulatorState transitions that revalidate the mempool, spec [DE-3].

This makes it suitable for use in functional state-threading patterns such as the Scenario monad, where branching and backtracking require independent state copies.

Value parameters

emulatorState

the chain, the mempool and the ledger state

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Advance the slot by the given number of slots. See setSlot for an epoch boundary.

Advance the slot by the given number of slots. See setSlot for an epoch boundary.

Attributes

appliedTxLog by transaction hash.

appliedTxLog by transaction hash.

Attributes

def appliedTxLog: Vector[AppliedTx]

The applied-transaction log, oldest first: the imported log, then the txs of the selected chain, spec [TS-5].

The applied-transaction log, oldest first: the imported log, then the txs of the selected chain, spec [TS-5].

Attributes

Create a read-only scalus.cardano.node.BlockchainReader snapshot.

Create a read-only scalus.cardano.node.BlockchainReader snapshot.

This provides read-only access to the emulator's state without submit capability. Uses ExecutionContext.global to avoid deadlocks when callers use Await.result on the returned futures.

Attributes

The datum store, with the bytes each datum arrived in.

The datum store, with the bytes each datum arrived in.

Attributes

Current CardanoInfo snapshot.

Current CardanoInfo snapshot.

Attributes

Clear the applied-transaction log, keeping ledger state, see EmulatorBase.clearAppliedTxs.

Clear the applied-transaction log, keeping ledger state, see EmulatorBase.clearAppliedTxs.

Attributes

Current slot number.

Current slot number.

Attributes

def datums: Map[DataHash, Data]

binaryDatums, decoded.

binaryDatums, decoded.

Attributes

def env: UtxoEnv

The environment of the tip, at the current slot.

The environment of the tip, at the current slot.

Attributes

def findUtxos(query: UtxoQuery): Either[UtxoQueryError, Utxos]

Find UTxOs matching the given query.

Find UTxOs matching the given query.

Attributes

def getAppliedTx(txHash: TransactionHash): Option[AppliedTx]

Look up the full applied-tx record (transaction + slot + spent inputs) by hash.

Look up the full applied-tx record (transaction + slot + spent inputs) by hash.

Attributes

def getDatum(datumHash: DataHash): Option[Data]

Resolve a datum by its hash, or None if unknown.

Resolve a datum by its hash, or None if unknown.

Attributes

Look up a previously applied transaction by hash, or None if it was never applied.

Look up a previously applied transaction by hash, or None if it was never applied.

Attributes

def hasTx(txHash: TransactionHash): Boolean

Whether the tx is in appliedTxLog: in a block of the selected chain above the clearAppliedTxs cursor, or in the log the emulator was built with. A pending tx, in the Manual preset, reads false. txStatus reads the blocks only, so a tx of the imported log is NotFound there.

Whether the tx is in appliedTxLog: in a block of the selected chain above the clearAppliedTxs cursor, or in the log the emulator was built with. A pending tx, in the Manual preset, reads false. txStatus reads the blocks only, so a tx of the imported log is NotFound there.

Attributes

The ratify result the next epoch boundary enacts, ledger-rules spec [ES-9b].

The ratify result the next epoch boundary enacts, ledger-rules spec [ES-9b].

Attributes

The reward update the next epoch boundary pays, or None before the first boundary, ledger-rules spec [ES-9a].

The reward update the next epoch boundary pays, or None before the first boundary, ledger-rules spec [ES-9a].

Attributes

Forge a block from the mempool, spec section 8.1, and return its point and the new emulator. The original emulator is not modified, spec [SF-14].

Forge a block from the mempool, spec section 8.1, and return its point and the new emulator. The original emulator is not modified, spec [SF-14].

Attributes

Forge a block of txs on on, at slot on.slot + 1, spec [FG-11], [SF-14].

Forge a block of txs on on, at slot on.slot + 1, spec [FG-11], [SF-14].

Attributes

Forge a block of txs at slot on on, a block of the tree or ChainPoint.origin, then run chain selection, spec section 8.2, [SF-14].

Forge a block of txs at slot on on, a block of the tree or ChainPoint.origin, then run chain selection, spec section 8.2, [SF-14].

Attributes

Current protocol parameters.

Current protocol parameters.

Attributes

def reserves: Coin

The reserves of the tip, ledger-rules spec [ES-9]. state does not hold them: they are in the epoch state, which only epoch boundaries change.

The reserves of the tip, ledger-rules spec [ES-9]. state does not hold them: they are in the epoch state, which only epoch boundaries change.

Attributes

Remove the last n blocks of the selected chain, and return the tip after chain selection and the new emulator, spec section 11.3, [SF-14].

Remove the last n blocks of the selected chain, and return the tip after chain selection and the new emulator, spec section 11.3, [SF-14].

Attributes

Set the slot to a specific value, then revalidate the mempool, spec [DE-3]. Crossing epoch boundaries forwards runs their epoch transitions (ledger-rules spec [EB-1]), as the mutable emulator does; see EmulatorState.withSlot for a move back.

Set the slot to a specific value, then revalidate the mempool, spec [DE-3]. Crossing epoch boundaries forwards runs their epoch transitions (ledger-rules spec [EB-1]), as the mutable emulator does; see EmulatorState.withSlot for a move back.

Attributes

Throws
IllegalArgumentException

in the Manual preset, for a slot below the slot of the tip block, spec [RV-8]

The stake snapshots and the fee snapshot of the tip, ledger-rules spec [ES-9a].

The stake snapshots and the fee snapshot of the tip, ledger-rules spec [ES-9a].

Attributes

def state: State

The ledger state of the tip.

The ledger state of the tip.

Attributes

Submit a transaction, returning the transaction hash and a new emulator with updated state. In the Instant preset the tx is in a block at once; in Manual it waits in the mempool until produceBlock, spec section 7.

Submit a transaction, returning the transaction hash and a new emulator with updated state. In the Instant preset the tx is in a block at once; in Manual it waits in the mempool until produceBlock, spec section 7.

The original emulator is not modified.

Attributes

Convert to a mutable scalus.cardano.node.Emulator with the same state: the chain, the mempool, the preset and the whole ledger state.

Convert to a mutable scalus.cardano.node.Emulator with the same state: the chain, the mempool, the preset and the whole ledger state.

Attributes

The status of the tx txHash, spec [TS-1]. It reads the mempool and the blocks, not the applied-tx log: a tx known only from the log the emulator was built with is NotFound.

The status of the tx txHash, spec [TS-1]. It reads the mempool and the blocks, not the applied-tx log: a tx known only from the log the emulator was built with is NotFound.

Attributes

def utxos: Utxos

Current UTxO set.

Current UTxO set.

Attributes

A copy with datum in the datum store getDatum reads, keyed by the hash of its bytes. The immutable form of EmulatorBase.addDatum.

A copy with datum in the datum store getDatum reads, keyed by the hash of its bytes. The immutable form of EmulatorBase.addDatum.

Attributes

withDatum for a datum without its original bytes: the store keeps its canonical CBOR.

withDatum for a datum without its original bytes: the store keeps its canonical CBOR.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product