name: Rust Unit Tests
permissions:
contents: read
on:
push:
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dump /proc/cpuinfo
run: |
cat /proc/cpuinfo
- name: Install MSRV toolchain and GNU target
uses: dtolnay/rust-toolchain@beta
with:
components: rust-src
targets: x86_64-unknown-linux-gnu
- name: Build
run: cargo build --features "bin"
- name: Run tests
run: cargo test
- name: Run tests (example)
run: cargo test --examples
- name: Install nightly toolchain and GNU target
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
targets: x86_64-unknown-linux-gnu
- name: Clean Cargo Cache
run: cargo clean
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- name: Build (portable-simd)
run: RUSTFLAGS="-C target-cpu=native" cargo build --features "bin portable-simd"
- name: Run tests (portable-simd)
run: RUSTFLAGS="-C target-cpu=native" cargo test --features "std portable-simd"
- name: Run tests (portable-simd example)
run: RUSTFLAGS="-C target-cpu=native" cargo test --features portable-simd --examples
- name: Build Release (portable-simd)
run: RUSTFLAGS="-C target-cpu=native" cargo build --features "bin portable-simd" --release
- name: Self Test (portable-simd)
run: target/release/scrypt-opt cast
- name: Compute Test (portable-simd release)
run: |
set -e
mkdir -p tmp/test-output
for build in debug release; do
echo -n "pleaseletmein" | target/$build/scrypt-opt compute -s SodiumChloride --cf 14 -r 8 -p 1 | tee tmp/test-output/compute.txt
grep -q '$scrypt$ln=14,r=8,p=1$U29kaXVtQ2hsb3JpZGU$cCO9yzr9c0hGHAbNgf046/2o+7qQT44+qbVD9lRdofLVQylVYT8Pz2LUlwUkKpr55h6F3A1lHkDfzwF7RVdYhw' tmp/test-output/compute.txt
echo -n "password" | target/$build/scrypt-opt compute -s NaCl --cf 10 -r 8 -p 16 | tee tmp/test-output/compute.txt
grep -q '$scrypt$ln=10,r=8,p=16$TmFDbA$/bq+HJ00cgB4VucZDQHp/nxq18vII3gw53N2Y0s3MWIurzDZLiKjiG/xCSedmDDaxyevuUqD7m2DYMvfoswGQA' tmp/test-output/compute.txt
done
- name: PoW Test (portable-simd release)
run: |
set -e
mkdir -p tmp/test-output
target/release/scrypt-opt --num-threads $(nproc) pow --target 0002 --salt KTlmPG9GFcM= --offset 28 | tee tmp/test-output/pow.txt
grep -q cf40000000000000 tmp/test-output/pow.txt