Skip to content

Conversation

@ariady-putra
Copy link
Contributor

Like,

test prop_tuple2((a, b) via tuple(int(), bytearray())) {
  expect _: Int = a
  expect _: ByteArray = b
}

..

test prop_tuple9((a, b, .., h, i) via tuple9(int(), bytearray(), .., fuzzer_h(), fuzzer_i())) {
  expect _: Int = a
  expect _: ByteArray = b
  ..
  expect _: H = h
  expect _: I = i
}

@ariady-putra
Copy link
Contributor Author

ariady-putra commented Dec 30, 2024

Usecase example: https://github.com/Anastasia-Labs/aiken-linked-list/pull/6/files#diff-51e35fd3abb5d42a8369c9f66d32af9e2f278f41300d151945281397249a4835R227-R241

test mint_validator_insert(
  (blake2b_224s, o_refs, now, penalty_address, contract_address) via fuzzer.tuple5(
    blake2b_224_fuzzer(count: 3),
    fuzz.set_between(output_reference_fuzzer(), 2, 2),
    fuzz.int_at_least(1000),
    address_fuzzer(
      FromScript(Specified(mock_script_hash("P"))),
      WithFuzzedDelegation,
    ),
    address_fuzzer(
      FromScript(Specified(mock_script_hash("I"))),
      WithFuzzedDelegation,
    ),
  ),
) {
 ..
}

Can also be combined with #22

@MicroProofs
Copy link
Member

Merged commits to main

@ariady-putra
Copy link
Contributor Author

Hey @MicroProofs ,


  1. Are these worthy additions to be included in aiken/fuzz? I'll happily move the code over and create a PR.
  2. Will there be a new Set type in Aiken? If so, I'll wait for it instead of returning tuples for unique fuzzers.

@MicroProofs
Copy link
Member

  1. I think those belong more to stdlib

  2. Have not heard anyone talk about Set type??

@ariady-putra
Copy link
Contributor Author

  1. I think those belong more to stdlib

  2. Have not heard anyone talk about Set type??

  1. But stdlib would depend on fuzz?

  2. I saw this CDDL and I thought there will be a new type https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/conway/impl/cddl-files/extra.cddl
    I must confess I'm not proficient reading CDDL though

@MicroProofs
Copy link
Member

  1. ahh I see now. I think it's ok to add as a PR, but I'm wondering about the use cases for unique
  2. No new types on-chain that's exclusive to offchain

@ariady-putra
Copy link
Contributor Author

  1. ahh I see now. I think it's ok to add as a PR, but I'm wondering about the use cases for unique

It's for type-safety, for example:

test prop(creds via set_between(cred_fuzzer(), 3, 3))

this works, but inside the test block you'll need to have

expect [a, b, c] = creds

If the set_between count is changed, either accidentally or otherwise, it will cause a runtime error.

With unique you can have

test prop((a, b, c) via unique3(cred_fuzzer()))

preventing accidental test failure during arrangement instead of assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants