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
42 changes: 42 additions & 0 deletions .github/workflows/base64-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run base64_example Tests on PR
on:
pull_request:
paths:
- "lib_examples/base64_example/**"
schedule:
- cron: "0 2 * * *"
workflow_dispatch:

jobs:
test:
defaults:
run:
working-directory: lib_examples/base64_example
permissions:
issues: write

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/[email protected]
with:
toolchain: stable

- name: Run Noir unit tests
run: |
nargo test

- name: Create issue on failure (nightly)
if: failure() && github.event_name == 'schedule'
uses: actions/github-script@v6
with:
script: |
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '[Nightly] base64_example workflow failed',
body: `The nightly base64_example workflow failed. Please investigate.\n\n/cc @noir-lang/developerrelations`,
labels: ['nightly', 'bug']
})
2 changes: 1 addition & 1 deletion lib_examples/base64_example/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = [""]
compiler_version = ">=0.36.0"

[dependencies]
base64 = {tag = "v0.3.1", git = "https://github.com/noir-lang/noir_base64.git"}
noir_base64 = {tag = "v0.4.2", git = "https://github.com/noir-lang/noir_base64.git"}
10 changes: 5 additions & 5 deletions lib_examples/base64_example/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod test_inputs;
use base64::{BASE64_ENCODER, BASE64_DECODER};
use noir_base64;

// Choose number of encode and/or decode runs
pub global ENCODE_RUNS: u32 = 3;
Expand All @@ -13,20 +13,20 @@ comptime global U: u32 = comptime { TEST_INPUT.as_bytes().len() };
comptime global B: u32 = comptime {
let mut q = U / 3;
let r = U - q * 3;
if (r > 0) { q += 1; }; // round up since encoded base64 gets padded
if (r > 0) { q += 1; } // round up since encoded base64 gets padded
q * 4
};

fn main(input: str<U>, base64_encoded: str<B>) {
for _ in 0..ENCODE_RUNS {
let _encoded: [u8; B] = BASE64_ENCODER.encode(input.as_bytes());
let _encoded: [u8; B] = noir_base64::BASE64_ENCODER::encode(input.as_bytes());
}
for _ in 0..DECODE_RUNS {
let _decoded: [u8; U] = BASE64_DECODER.decode(base64_encoded.as_bytes());
let _decoded: [u8; U] = noir_base64::BASE64_DECODER::decode(base64_encoded.as_bytes());
}
}

#[test]
fn test() {
main(TEST_INPUT, TEST_BASE64_ENCODED);
}
}