Skip to content

Commit 65f6f06

Browse files
committed
Merge branch 'transaction_fuzz'
2 parents eb2443e + c9b6b03 commit 65f6f06

File tree

5 files changed

+983
-1
lines changed

5 files changed

+983
-1
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## v2.2.0 - UNRELEASED
4+
5+
### Added
6+
7+
- New Cardano-specific fuzzers covering
8+
- [Address](https://aiken-lang.github.io/fuzz/cardano/fuzz.html#Address)
9+
- [Assets](https://aiken-lang.github.io/fuzz/cardano/fuzz.html#Assets)
10+
- [Certificate](https://aiken-lang.github.io/fuzz/cardano/fuzz.html#Certificate)
11+
- [Transaction](https://aiken-lang.github.io/fuzz/cardano/fuzz.html#Transaction)
12+
13+
- New [`data() -> Fuzzer<Data>`](https://aiken-lang.github.io/fuzz/aiken/fuzz.html#data)
14+
15+
## v2.1.1 - 2025-01-21
16+
17+
### Added
18+
19+
- More primitives for fuzzers:
20+
- `tuple`, `tuple3`, `tuple4`, `tuple5`, `tuple6`, `tuple7`, `tuple8`, `tuple9`
21+
322
## v2.1.0 - 2024-09-24
423

524
### Added

aiken.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "aiken-lang/fuzz"
22
version = "main"
3-
compiler = "v1.1.13"
3+
compiler = "v1.1.16"
44
plutus = "v3"
55
license = "Apache-2.0"
66
description = "A library for writing Aiken's fuzzers."

lib/aiken/fuzz.ak

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,45 @@ fn bytearray_fixed_inner(len: Int) -> Fuzzer<ByteArray> {
7474
}
7575
}
7676

77+
/// Generate an arbitrary `Data`.
78+
pub fn data() -> Fuzzer<Data> {
79+
do_data(depth: 3)
80+
}
81+
82+
fn do_data(depth: Int) -> Fuzzer<Data> {
83+
let data_type <- and_then(byte())
84+
if data_type < 128 || depth <= 0 {
85+
if data_type < 64 {
86+
map(int(), builtin.i_data)
87+
} else {
88+
map(bytearray(), builtin.b_data)
89+
}
90+
} else {
91+
if data_type < 170 {
92+
map(list_between(do_data(depth - 1), 0, depth), builtin.list_data)
93+
} else if data_type < 212 {
94+
map(
95+
list_between(
96+
{
97+
let k <- and_then(do_data(depth - 1))
98+
let v <- map(do_data(depth - 1))
99+
Pair(k, v)
100+
},
101+
0,
102+
depth - 1,
103+
),
104+
builtin.map_data,
105+
)
106+
} else {
107+
map2(
108+
byte(),
109+
list_between(do_data(depth - 1), 0, depth),
110+
builtin.constr_data,
111+
)
112+
}
113+
}
114+
}
115+
77116
const int_bucket_small: Int = 128
78117

79118
const int_bucket_zero: Int = 132

0 commit comments

Comments
 (0)