corda / net.corda.contracts.testing

Package net.corda.contracts.testing

Types

CommandDataGenerator class CommandDataGenerator : Generator<CommandData>
CommandGenerator class CommandGenerator : Generator<Command>
ContractStateGenerator class ContractStateGenerator : Generator<ContractState>

This file contains generators for quickcheck style testing. The idea is that we can write random instance generators for each type we have in the code and test against those instead of predefined mock data. This style of testing can catch corner case bugs and test algebraic properties of the code, for example deserialize(serialize(generatedThing)) == generatedThing

DummyDealContract class DummyDealContract : Contract
DummyLinearContract class DummyLinearContract : Contract
ExitGenerator class ExitGenerator : Generator<Exit>
IssueGenerator class IssueGenerator : Generator<Issue>
MoveGenerator class MoveGenerator : Generator<Move>
SignedTransactionGenerator class SignedTransactionGenerator : Generator<SignedTransaction>
WiredTransactionGenerator class WiredTransactionGenerator : Generator<WireTransaction>

Functions

calculateRandomlySizedAmounts fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, max: Int, rng: Random): LongArray
fillWithSomeTestCash fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>, outputNotary: Party = DUMMY_NOTARY, atLeastThisManyStates: Int = 3, atMostThisManyStates: Int = 10, rng: Random = Random(), ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 1 })), ownedBy: CompositeKey? = null, issuedBy: PartyAndReference = DUMMY_CASH_ISSUER, issuerKey: KeyPair = DUMMY_CASH_ISSUER_KEY): Vault<State>

Creates a random set of between (by default) 3 and 10 cash states that add up to the given amount and adds them to the vault. This is intended for unit tests. The cash is issued by DUMMY_CASH_ISSUER and owned by the legal identity key from the storage service.

fillWithSomeTestDeals fun ServiceHub.fillWithSomeTestDeals(dealIds: List<String>): Unit
fillWithSomeTestLinearStates fun ServiceHub.fillWithSomeTestLinearStates(numberToCreate: Int): Unit