cardano/fuzz
Functions
Address
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
constructors
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",
]))
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
constructors
Generate an Inline
stake credential, specifying a Fuzzer
for the 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
Generate an arbitrary AssetName
from another Fuzzer
, enforcing a length smaller than 32 bytes.
Assets :: PolicyId
Generate an arbitrary PolicyId
from another Fuzzer
, enforcing a length strictly equal to 28 bytes.
Assets :: Value
Generate a Value
holding a positive (i.e. > 0) quantity of lovelace, but no assets.
Generate a Value
with no assets, specifying a Fuzzer
for the Lovelace
quantity.
Examples
cardano.lovelace_with(int_at_least(1)) == cardano.lovelace()
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
constructors
Certificate :: Delegate
constructors
Generate an arbitrary DelegateBlockProduction
delegate.
Generate an arbitrary DelegateBlockProduction
delegate, specifying a Fuzzer
for the pool id.
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.
Generate an arbitrary DelegateVote
delegate, specifying a Fuzzer
for the drep.
Certificate :: Delegate Representative
Generate an arbitrary DelegateRepresentative
.
constructors
Generate an arbitrary AlwaysNoConfidence
drep.
Generate an arbitrary Registered
drep, specifying a Fuzzer
for the credential.
Certificate :: StakePoolId
Generate an arbitrary StakePoolId
, enforcing a pool id size of 28 bytes.
Transaction
Tx :: Datum
constructors
Tx :: Input
Generate an arbitrary Input
, specifying fuzzers for sub-elements.
Tx :: 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
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
Generate an arbitrary ReferenceScript
, specifying a Fuzzer
for the script hash.
Tx :: Withdrawals
Generate arbitrary withdrawals, ordered by ascending Credential
.
Generate a valid sequence of withdrawals, extending from an existing set.
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()),
)
constructors
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",
]))
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
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",
]))
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",
]))
constructors
Generate an Inline
stake credential, specifying a Fuzzer
for the 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
Generate an Inline
stake credential, specifying a Fuzzer
for the 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.
Generate an arbitrary AssetName
from another Fuzzer
, enforcing a length smaller than 32 bytes.
Assets :: PolicyId
Generate an arbitrary PolicyId
from another Fuzzer
, enforcing a length strictly equal to 28 bytes.
Assets :: Value
Generate a Value
holding a positive (i.e. > 0) quantity of lovelace, but no assets.
Generate a Value
with no assets, specifying a Fuzzer
for the Lovelace
quantity.
Examples
cardano.lovelace_with(int_at_least(1)) == cardano.lovelace()
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
constructors
Certificate :: Delegate
constructors
Generate an arbitrary DelegateBlockProduction
delegate.
Generate an arbitrary DelegateBlockProduction
delegate, specifying a Fuzzer
for the pool id.
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.
Generate an arbitrary DelegateVote
delegate, specifying a Fuzzer
for the drep.
Certificate :: Delegate Representative
Generate an arbitrary DelegateRepresentative
.
constructors
Generate an arbitrary AlwaysNoConfidence
drep.
Generate an arbitrary Registered
drep, specifying a Fuzzer
for the credential.
Certificate :: StakePoolId
Generate an arbitrary StakePoolId
, enforcing a pool id size of 28 bytes.
Transaction
Generate an arbitrary PolicyId
from another Fuzzer
, enforcing a length strictly equal to 28 bytes.
Generate a Value
holding a positive (i.e. > 0) quantity of lovelace, but no assets.
Generate a Value
with no assets, specifying a Fuzzer
for the Lovelace
quantity.
Examples
cardano.lovelace_with(int_at_least(1)) == cardano.lovelace()
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 :: Delegate
Generate an arbitrary DelegateBlockProduction
delegate.
Generate an arbitrary DelegateBlockProduction
delegate, specifying a Fuzzer
for the pool id.
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.
Generate an arbitrary DelegateVote
delegate, specifying a Fuzzer
for the drep.
Certificate :: Delegate Representative
Generate an arbitrary DelegateRepresentative
.
Generate an arbitrary AlwaysNoConfidence
drep.
Generate an arbitrary Registered
drep, specifying a Fuzzer
for the credential.
Certificate :: StakePoolId
Generate an arbitrary StakePoolId
, enforcing a pool id size of 28 bytes.
Tx :: Datum
constructors
Tx :: Input
Generate an arbitrary Input
, specifying fuzzers for sub-elements.
Tx :: 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
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
Generate an arbitrary ReferenceScript
, specifying a Fuzzer
for the script hash.
Tx :: Withdrawals
Generate arbitrary withdrawals, ordered by ascending Credential
.
Generate a valid sequence of withdrawals, extending from an existing set.
Tx :: Input
Generate an arbitrary Input
, specifying fuzzers for sub-elements.
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
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
Generate an arbitrary ReferenceScript
, specifying a Fuzzer
for the script hash.
Tx :: Withdrawals
Generate arbitrary withdrawals, ordered by ascending Credential
.
Generate a valid sequence of withdrawals, extending from an existing set.
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.
Generate an arbitrary ReferenceScript
, specifying a Fuzzer
for the script hash.
Tx :: Withdrawals
Generate arbitrary withdrawals, ordered by ascending Credential
.
Generate a valid sequence of withdrawals, extending from an existing set.
Generate arbitrary withdrawals, ordered by ascending Credential
.
Generate a valid sequence of withdrawals, extending from an existing set.