Skip to content

Function Arguments in Test Fuzzers #1309

Description

@keyan-m

What Git revision are you using?

v1.1.21+42babe5

What operating system are you using, and which version?

  • Linux / Ubuntu
  • Linux / Other
  • macOS
  • Windows

Describe what the problem is?

The following gives syntax error at the first fn:

use aiken/fuzz
use cardano/assets
use cardano/fuzz as cardano_fuzz

test success__positive_quantities(
  v via cardano_fuzz.value_with(
    assets.zero,
    fuzz.list(cardano_fuzz.policy_id()),
    fn(_) { cardano_fuzz.asset_name() },
    fn(_, _) { fuzz.int_at_least(1) },
  ),
) {
  // ...
}

This can be circumvented by defining the two functions outside, but that leads to another error:

const asset_name_fuzzer = fn(_p: PolicyId) { cardano_fuzzer.asset_name() }

const quantity_fuzzer = fn(_p: PolicyId, _a: AssetName) { fuzz.int_at_least(1) }

test success__positive_quantities(
  v via cardano_fuzz.value_with(
    assets.zero,
    fuzz.list(cardano_fuzz.policy_id()),
    asset_name_fuzzer,
    quantity_fuzzer,
  ),
) {
  // ...
}
Operating System: linux
Architecture:     aarch64
Version:          v1.1.21+42babe5

crates/uplc/src/optimize/shrinker.rs:2363:67

    called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "__cyclic_function_6", unique: Unique(293) })

What should be the expected behavior?

Unless I've made an error somewhere, either of the two should compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    🔨 Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions