Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fuzz testing #9

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
26 changes: 26 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Fuzz

on:
workflow_dispatch: # because sometimes you just want to force a branch to have tests run
push:
branches:
- "**"
paths:
- .github/workflows/fuzz.yml

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use OCaml 4.08.1-afl
uses: avsm/setup-ocaml@v1
with:
ocaml-version: 4.08.1+afl
- run: opam pin add libmacaroons.dev . --no-action
- run: opam depext libmacaroons
- run: opam install . --deps-only
- run: opam install . -y bun crowbar base64
- run: opam exec -- dune build libmacaroons/fuzz/libmacaroons_fuzz.exe
- run: opam exec -- bun _build/default/libmacaroons/fuzz/libmacaroons_fuzz.exe
1 change: 1 addition & 0 deletions libmacaroons/fuzz/input/start
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bWFjYXJvb25z
2 changes: 1 addition & 1 deletion libmacaroons/fuzz/libmacaroons_fuzz.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let max_len = bytes_fixed 10
let non_zero =
map [bytes] (fun s ->
match (String.length s) with
| 0 -> (bad_test ())
| 0 | 1 -> (bad_test ())
| _ -> s)

let b64 =
Expand Down
41 changes: 0 additions & 41 deletions libmacaroons/test/.merlin

This file was deleted.

13 changes: 13 additions & 0 deletions libmacaroons/test/readme_tests.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module L = Libmacaroons

let rt () =
let m = Utils.unwrap_ok @@ L.Macaroon.create ~location:"http://mybank/" ~key:"his is our super secret key; only we should know it" ~id:"we used our secret key" in
Alcotest.(check string) "Should have location" "http://mybank/" (L.Macaroon.location m);
Alcotest.(check string) "Should have identifier" "we used our secret key" (L.Macaroon.identifier m);
Alcotest.(check string) "Should have correct signature" "ap3k78qHp7k2vd6FGCHVlS_lkuzrQiPU-HXi4QTgECg" (L.Macaroon.signature m)

let v =
let open Alcotest in
"readme_tests", [
test_case "Readme Tests" `Quick rt;
]