cardano/fuzz

Functions

Address

address() -> Fuzzer<Address>

Generate an arbitrary Address (other than pointer addresses).

address_with(
  payment_credential: Fuzzer<Credential>,
  stake_credential: Fuzzer<Option<StakeCredential>>,
) -> Fuzzer<Address>

Generate an arbitrary Address by specifying its payment and stake credentials.

Examples

// No stake credential whatsoever
cardano.address_with(cardano.credential(), fuzz.constant(None))

// Only script addresses
cardano.address_with(
  cardano.script(),
  fuzz.option(cardano.stake_credential()),
)

Address :: Credential

credential() -> Fuzzer<Credential>

Generate an arbitrary Credential.

constructors

script() -> Fuzzer<Credential>

Generate an arbitrary Script credential.

script_hash() -> Fuzzer<ScriptHash>

Generate an arbitrary ScriptHash

script_with(script_hash: Fuzzer<ScriptHash>) -> Fuzzer<Credential>

Generate an arbitrary Script credential, specifying a hash Fuzzer.

Examples

// Choose amongst a list of known hashes.
cardano.script_with(fuzz.one_of([
  "foo",
  "bar",
]))

verification_key() -> Fuzzer<Credential>

Generate an arbitrary VerificationKey credential.

verification_key_hash() -> Fuzzer<VerificationKeyHash>

Generate an arbitrary VerificationKeyHash.

verification_key_with(
  verification_key_hash: Fuzzer<VerificationKeyHash>,
) -> Fuzzer<Credential>

Generate an arbitrary VerificationKey credential, specifying a hash Fuzzer.

Examples

// Choose amongst a list of known hashes.
cardano.verification_key_with(fuzz.one_of([
  "foo",
  "bar",
]))

Address :: StakeCredential

stake_credential() -> Fuzzer<StakeCredential>

Generate an arbitrary stake credential.

constructors

inline() -> Fuzzer<StakeCredential>

Generate an arbitrary Inline stake credential.

inline_with(credential: Fuzzer<Credential>) -> Fuzzer<StakeCredential>

Generate an Inline stake credential, specifying a Fuzzer for the Credential.

pointer() -> Fuzzer<StakeCredential>

Generate an arbitrary Pointer stake credential.

pointer_with(
  slot_number: Fuzzer<Int>,
  transaction_index: Fuzzer<Int>,
  certificate_index: Fuzzer<Int>,
) -> Fuzzer<StakeCredential>

Generate an arbitrary Pointer stake credential, specifying fuzzers for the sub-elements.

Assets

Assets :: AssetName

asset_name() -> Fuzzer<AssetName>

Generate an arbitrary AssetName, between 0 and 32 bytes length.

asset_name_with(asset_name: Fuzzer<ByteArray>) -> Fuzzer<AssetName>

Generate an arbitrary AssetName from another Fuzzer, enforcing a length smaller than 32 bytes.

Assets :: PolicyId

policy_id() -> Fuzzer<PolicyId>

Generate an arbitrary PolicyId (a.k.a script hash).

policy_id_with(policy_id: Fuzzer<PolicyId>) -> Fuzzer<PolicyId>

Generate an arbitrary PolicyId from another Fuzzer, enforcing a length strictly equal to 28 bytes.

Assets :: Value

lovelace() -> Fuzzer<Value>

Generate a Value holding a positive (i.e. > 0) quantity of lovelace, but no assets.

lovelace_with(lovelace: Fuzzer<Int>) -> Fuzzer<Value>

Generate a Value with no assets, specifying a Fuzzer for the Lovelace quantity.

Examples

cardano.lovelace_with(int_at_least(1)) == cardano.lovelace()

value(self: Value) -> Fuzzer<Value>

Generate an arbitrary Value, extending an existing one. Use assets.zero or cardano.lovelace() as a simple starting point.

Examples

/// Some arbitrary value, possibly empty.
cardano.value(assets.zero)

/// At least some known NFT
cardano.value(assets.from_asset("my_policy", "my_asset_name", 1))

/// At least some lovelace
let quantity <- fuzz.and_then(int_at_least(1))
cardano.value(assets.from_lovelace(lovelace))

value_with(
  self: Value,
  policies: Fuzzer<List<PolicyId>>,
  asset_name: fn(PolicyId) -> Fuzzer<AssetName>,
  quantity: fn(PolicyId, AssetName) -> Fuzzer<Int>,
) -> Fuzzer<Value>

Extend an existing value using the given fuzzers for fine-grained control.

Examples

cardano.value_with(
  assets.zero,
  policies: fuzz.constant([my_policy_1, my_policy_2]),
  asset_name: fn(policy) {
    if policy == my_policy_1 {
       fuzz.one_of([asset_1, asset_2, asset_3])
    } else {
       fuzz.constant(my_other_asset)
    }
  },
  quantity: fn(_, _) { fuzz.constant(1) }
)

Certificate

certificate() -> Fuzzer<Certificate>

Generate an arbitrary Certificate.

constructors

authorize_constitutional_committee_proxy() -> Fuzzer<Certificate>

authorize_constitutional_committee_proxy_with(
  constitutional_committee_member: Fuzzer<Credential>,
  proxy: Fuzzer<Credential>,
) -> Fuzzer<Certificate>

delegate_credential() -> Fuzzer<Certificate>

delegate_credential_with(
  credential: Fuzzer<Credential>,
  delegate: Fuzzer<Delegate>,
) -> Fuzzer<Certificate>

register_and_delegate_credential() -> Fuzzer<Certificate>

register_and_delegate_credential_with(
  credential: Fuzzer<Credential>,
  delegate: Fuzzer<Delegate>,
  deposit: Fuzzer<Lovelace>,
) -> Fuzzer<Certificate>

register_credential() -> Fuzzer<Certificate>

register_credential_with(credential: Fuzzer<Credential>) -> Fuzzer<Certificate>

register_delegate_representative() -> Fuzzer<Certificate>

register_delegate_representative_with(
  credential: Fuzzer<Credential>,
  deposit: Fuzzer<Lovelace>,
) -> Fuzzer<Certificate>

register_stake_pool() -> Fuzzer<Certificate>

register_stake_pool_with(
  stake_pool_id: Fuzzer<StakePoolId>,
  verification_key_hash: Fuzzer<VerificationKeyHash>,
) -> Fuzzer<Certificate>

retire_from_constitutional_committee() -> Fuzzer<Certificate>

retire_from_constitutional_committee_with(
  constitutional_committee_member: Fuzzer<Credential>,
) -> Fuzzer<Certificate>

retire_stake_pool() -> Fuzzer<Certificate>

retire_stake_pool_with(
  stake_pool_id: Fuzzer<StakePoolId>,
  deposit: Fuzzer<Lovelace>,
) -> Fuzzer<Certificate>

unregister_credential() -> Fuzzer<Certificate>

unregister_credential_with(
  credential: Fuzzer<Credential>,
) -> Fuzzer<Certificate>

unregister_delegate_representative() -> Fuzzer<Certificate>

unregister_delegate_representative_with(
  credential: Fuzzer<Credential>,
  deposit: Fuzzer<Lovelace>,
) -> Fuzzer<Certificate>

update_delegate_representative() -> Fuzzer<Certificate>

update_delegate_representative_with(
  credential: Fuzzer<Credential>,
) -> Fuzzer<Certificate>

Certificate :: Delegate

delegate() -> Fuzzer<Delegate>

Generate an arbitrary Delegate.

constructors

delegate_block_production() -> Fuzzer<Delegate>

Generate an arbitrary DelegateBlockProduction delegate.

delegate_block_production_with(
  stake_pool_id: Fuzzer<StakePoolId>,
) -> Fuzzer<Delegate>

Generate an arbitrary DelegateBlockProduction delegate, specifying a Fuzzer for the pool id.

delegate_both() -> Fuzzer<Delegate>

Generate an arbitrary DelegateBoth delegate.

delegate_both_with(
  stake_pool_id: Fuzzer<StakePoolId>,
  delegate_representative: Fuzzer<DelegateRepresentative>,
) -> Fuzzer<Delegate>

Generate an arbitrary DelegateBoth delegate, specifying a Fuzzer for the pool and drep.

delegate_vote() -> Fuzzer<Delegate>

Generate an arbitrary DelegateVote delegate.

delegate_vote_with(
  delegate_representative: Fuzzer<DelegateRepresentative>,
) -> Fuzzer<Delegate>

Generate an arbitrary DelegateVote delegate, specifying a Fuzzer for the drep.

Certificate :: Delegate Representative

delegate_representative() -> Fuzzer<DelegateRepresentative>

Generate an arbitrary DelegateRepresentative.

constructors

always_abstain() -> Fuzzer<DelegateRepresentative>

Generate an arbitrary AlwaysAbstain drep.

always_no_confidence() -> Fuzzer<DelegateRepresentative>

Generate an arbitrary AlwaysNoConfidence drep.

registered() -> Fuzzer<DelegateRepresentative>

Generate an arbitrary Registered drep.

registered_with(
  credential: Fuzzer<Credential>,
) -> Fuzzer<DelegateRepresentative>

Generate an arbitrary Registered drep, specifying a Fuzzer for the credential.

Certificate :: StakePoolId

stake_pool_id() -> Fuzzer<StakePoolId>

Generate an arbitrary StakePoolId.

stake_pool_id_with(stake_pool_id: Fuzzer<ByteArray>) -> Fuzzer<StakePoolId>

Generate an arbitrary StakePoolId, enforcing a pool id size of 28 bytes.

Transaction

transaction_id() -> Fuzzer<TransactionId>

Generate an arbitrary TransactionId

Tx :: Datum

datum() -> Fuzzer<Datum>

Generate an arbitrary Datum.

constructors

datum_hash() -> Fuzzer<Datum>

datum_hash_with(datum_hash: Fuzzer<DataHash>) -> Fuzzer<Datum>

inline_datum() -> Fuzzer<Datum>

inline_datum_with(data: Fuzzer<Data>) -> Fuzzer<Datum>

no_datum() -> Fuzzer<Datum>

Tx :: Input

input() -> Fuzzer<Input>

Generate an arbitrary Input.

input_with(
  output_reference: Fuzzer<OutputReference>,
  output: Fuzzer<Output>,
) -> Fuzzer<Input>

Generate an arbitrary Input, specifying fuzzers for sub-elements.

Tx :: Output

output() -> Fuzzer<Output>

Generate an arbitrary Output.

output_with(
  address: Fuzzer<Address>,
  value: Fuzzer<Value>,
  datum: Fuzzer<Datum>,
  reference_script: Fuzzer<Option<ScriptHash>>,
) -> Fuzzer<Output>

Generate an arbitrary Output, specifying fuzzers for sub-elements.

Tx :: OutputReference

output_reference() -> Fuzzer<OutputReference>

Generate an arbitrary OutputReference, with reasonably sized output indexes.

output_reference_with(
  transaction_id: Fuzzer<TransactionId>,
  output_index: Fuzzer<Int>,
) -> Fuzzer<OutputReference>

Generate an arbitrary OutputReference, specifying fuzzers for sub-elements.

Tx :: ReferenceScript

reference_script() -> Fuzzer<Option<ScriptHash>>

Generate an arbitrary ReferenceScript.

reference_script_with(
  script_hash: Fuzzer<ScriptHash>,
) -> Fuzzer<Option<ScriptHash>>

Generate an arbitrary ReferenceScript, specifying a Fuzzer for the script hash.

Tx :: Withdrawals

withdrawals() -> Fuzzer<Pairs<Credential, Lovelace>>

Generate arbitrary withdrawals, ordered by ascending Credential.

withdrawals_extending(
  self: Pairs<Credential, Lovelace>,
) -> Fuzzer<Pairs<Credential, Lovelace>>

Generate a valid sequence of withdrawals, extending from an existing set.

withdrawals_with(
  credential: Fuzzer<Credential>,
  quantity: fn(Credential) -> Fuzzer<Lovelace>,
) -> Fuzzer<Pairs<Credential, Lovelace>>

Generate arbitrary withdrawals, specifying a Fuzzer for credentials and quantity for fine-grained control.

Search Document