Skip to content

Commit

Permalink
fix(ledger): fuzz loop bug and add to ci (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnut authored Jan 15, 2025
1 parent 7b961e8 commit 0404e2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ jobs:
- name: run
run: ./zig-out/bin/fuzz allocators 19 10000

ledger_fuzz:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
timeout-minutes: 60
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: setup zig
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: build
run: zig build -Doptimize=ReleaseSafe -Dno-run fuzz
- name: run
run: ./zig-out/bin/fuzz ledger 19 10000

# benchmarks:
# if: ${{ github.ref != 'refs/heads/main' }}
# strategy:
Expand Down
4 changes: 2 additions & 2 deletions src/ledger/fuzz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn run(initial_seed: u64, args: *std.process.ArgIterator) !void {

var count: u64 = 0;

while (true) outer: {
outer: while (true) {
var prng = std.Random.DefaultPrng.init(seed);
const random = prng.random();
// This is a simpler blockstore which is used to make sure
Expand All @@ -97,7 +97,7 @@ pub fn run(initial_seed: u64, args: *std.process.ArgIterator) !void {
for (0..1_000) |_| {
if (maybe_max_actions) |max| {
if (count >= max) {
std.debug.print("{s} reached max actions: {}\n", .{ "action_name", max });
std.debug.print("reached max actions: {}\n", .{max});
break :outer;
}
}
Expand Down

0 comments on commit 0404e2d

Please sign in to comment.