Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4.1.7
- uses: aiken-lang/setup-aiken@v1
with:
version: v1.1.9
version: v1.1.21
- run: aiken fmt --check
- run: aiken check -D
- run: aiken build
50 changes: 17 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@
This library contains a set of tools, mainly for testing purposes:

- [`print`](#print) (pretty-print data with label)
- [`to_data`](#to_data) (upcast any serialisable type to `Data`)
- [`collections`](#collections) (contains some `list` and `zip3` functions)
- [`fuzzy`](#fuzzy) (`address`, `assets`, `certificate`, `governance`, and `transaction` fuzzers)
- [`time`](#time) (to `add`/`subtract` intervals and unwrapping finite time, taking its inclusivity into account)
- [`tx`](#tx) (helps mocking and constructing transaction data using the `transaction` builder)

| ℹ️ | Package info | aiken-extra/test_kit | 🧰 |
| --- | --------------- | ---------------------------------------------------------------------------------------- | --- |
| 🔴 | **Version** | **v0.0.2** | 🛠️ |
| 🔴 | **Codename** | **helium** | 🔥 |
| 🔴 | **Status** | **alpha** | 🧪 |
| 🟢 | **Depends on** | [**aiken-lang/fuzz v2.1.0**](https://github.com/aiken-lang/fuzz/releases/tag/v2.1.0) | ✅ |
| 🟢 | **Depends on** | [**aiken-lang/stdlib v2.2.0**](https://github.com/aiken-lang/stdlib/releases/tag/v2.2.0) | ✅ |
| 🟢 | **Tested with** | [**aiken v1.1.9**](https://github.com/aiken-lang/aiken/releases/tag/v1.1.9) | ✅ |
| 🟡 | **Version** | **v0.1.0** | 🛠️ |
| 🟡 | **Codename** | **lithium** | ☄️ |
| 🟡 | **Status** | **beta** | ⚗️ |
| 🟢 | **Depends on** | [**aiken-lang/fuzz v2.2.0**](https://github.com/aiken-lang/fuzz/releases/tag/v2.1.0) | ✅ |
| 🟢 | **Depends on** | [**aiken-lang/stdlib v3.0.0**](https://github.com/aiken-lang/stdlib/releases/tag/v2.2.0) | ✅ |
| 🟢 | **Tested with** | [**aiken v1.1.21**](https://github.com/aiken-lang/aiken/releases/tag/v1.1.9) | ✅ |

<!-- | 🟢 | **Version** | **boron** | ✅ | -->

<!-- | 🟡 | **Codename** | **lithium** | ☄️ | -->
<!-- | 🟡 | **Version** | **v0.1.1** | 🛠️ | -->
<!-- | 🟡 | **Codename** | **beryllium** | ☄️ | -->

<!-- | 🟡 | **Status** | **beta** | ⚗️ | -->

## `print`

Pretty-print data with label:

```gleam
```aiken
use test_kit.{print}

print("Label", data) // fuzz.label(@"Label: cbor.diagnostic(data)")
Expand All @@ -38,21 +36,11 @@ print("Label", data) // fuzz.label(@"Label: cbor.diagnostic(data)")
By calling [`fuzz.label`](https://aiken-lang.github.io/fuzz/aiken/fuzz.html#label) internally,
`print` will also work with property testing.

## `to_data`

Upcast any serialisable type to `Data`:

```gleam
use test_kit.{to_data}

any |> to_data // let data: Data = any
```

## `collections`

Zip3:

```gleam
```aiken
use test_kit/collections

collections.zip3(list_a, list_b, list_c) // -> [(a, b, c)..]
Expand All @@ -61,7 +49,7 @@ collections.unzip3(list_abc) // -> ([a..], [b..], [c..])

List `and` & `or`:

```gleam
```aiken
use test_kit/collections/logic

[..bools] |> logic.all_true // -> True | False
Expand All @@ -72,23 +60,19 @@ use test_kit/collections/logic

## `fuzzy`

Tuple and unique fuzzers:
Unique fuzzers:

```gleam
```aiken
use test_kit/fuzzy

// A convenient way of generating tuples instead of doing map:
test prop_tuple((a, b) via fuzzy.tuple(fuzzer_a, fuzzer_b)) { .. }
// also available: tuple3 to tuple9

// Generates 3 unique elements from the given fuzzer:
test prop_unique((x1, x2, x3) via fuzzy.unique3(fuzzer_x)) { .. }
// other element counts are also available
```

Transaction data fuzzers:

```gleam
```aiken
use test_kit/fuzzy/fuzzer.{ .. }

test prop_address(address via address_fuzzer(FromFuzzed, WithFuzzedDelegation)) { .. } // random addresses
Expand All @@ -106,7 +90,7 @@ test prop_transaction(inputs via user_inputs_fuzzer()) { .. } // simple (non-scr

Interval additions and subtractions:

```gleam
```aiken
use test_kit/time.{ .. }

interval.after(25200000) |> add_interval(lower_bound: 6 |> Minute, upper_bound: 5 |> Hour) // == interval.after(25200000 + 6 * 60 * 1_000)
Expand All @@ -122,7 +106,7 @@ interval.between(4, 5000) |> sub_interval(lower_bound: 2 |> MS, upper_bound: 1 |

Unwrapping finite time:

```gleam
```aiken
use test_kit/time/unwrap

unwrap.finite_start_of(interval) // -> PosixTime
Expand All @@ -135,7 +119,7 @@ unwrap.finite_end_of(interval) // -> PosixTime

Constructing transaction data:

```gleam
```aiken
use test_kit/tx.{ .. }

test validate_something() {
Expand All @@ -155,7 +139,7 @@ test validate_something() {

Mocking transaction data:

```gleam
```aiken
use test_kit/tx/mock.{ .. }

mock_address(from_payment: 1, from_stake: 2)
Expand Down
8 changes: 4 additions & 4 deletions aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@

[[requirements]]
name = "aiken-lang/stdlib"
version = "v2.2.0"
version = "3.0.0"
source = "github"

[[requirements]]
name = "aiken-lang/fuzz"
version = "v2.1.0"
version = "2.2.0"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "v2.2.0"
version = "3.0.0"
requirements = []
source = "github"

[[packages]]
name = "aiken-lang/fuzz"
version = "v2.1.0"
version = "2.2.0"
requirements = []
source = "github"

Expand Down
45 changes: 3 additions & 42 deletions aiken.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,10 @@ echo -e "${MAGENTA}Running${RESET} ${WHITE}aiken check${RESET}:"
aiken c 2>&1 | tee ${PROJECT}.tests
echo "" # new line

# aiken build
echo -e "${MAGENTA}Running${RESET} ${WHITE}aiken build${RESET}:"
aiken b $1
echo "" # new line

# aiken blueprint & address
echo -e "${MAGENTA}Running${RESET} ${WHITE}aiken blueprint${RESET} & ${WHITE}aiken address${RESET}:"
aiken blueprint convert > ${PROJECT}.plutus
aiken address > ${PROJECT}.address
echo "" # new line

# aiken docs
if [ $# -eq 0 ]; then
# README.md
GLEAM_CODE=("\`\`\`gleam")
AIKEN_CODE=("\`\`\`aiken")

# README.md - aiken docs: preprocessing - replace ```gleam with ```aiken
README=()
while IFS= read -r LINE; do
if [ "$LINE" == "$GLEAM_CODE" ]; then
README+=("$AIKEN_CODE")
else
README+=("$LINE")
fi
done < README.md
printf "%s\n" "${README[@]}" > README.md

# Running `aiken docs`
echo -e "${MAGENTA}Running${RESET} ${WHITE}aiken docs${RESET}:"
aiken docs

# README.md - aiken docs: postprocessing - replace ```aiken with ```gleam
README=()
while IFS= read -r LINE; do
if [ "$LINE" == "$AIKEN_CODE" ]; then
README+=("$GLEAM_CODE")
else
README+=("$LINE")
fi
done < README.md
printf "%s\n" "${README[@]}" > README.md
fi
# Running `aiken docs`
echo -e "${MAGENTA}Running${RESET} ${WHITE}aiken docs${RESET}:"
aiken docs

# .gitignore
GITIGNORE=()
Expand Down
11 changes: 6 additions & 5 deletions aiken.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "aiken-extra/test_kit"
version = "helium-α"
compiler = "v1.1.9"
version = "lithium-β"
compiler = "1.1.21"
plutus = "v3"
license = "Apache-2.0"
description = "An Aiken utility library containing various tools, mainly for testing purposes"
Expand All @@ -12,12 +12,13 @@ platform = "github"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "v2.2.0"
version = "3.0.0"
source = "github"

[[dependencies]]
name = "aiken-lang/fuzz"
version = "v2.1.0"
version = "2.2.0"
source = "github"

[config]
[config.default]
now = 1768998897000
Loading