Merge pull request #1 from PR0M3TH3AN/codex/start-building-project-with-mvp

feat(cli): basic tests and CI workflow
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2025-05-28 21:48:30 -04:00
commit 39f0c171d5
3 files changed
+49 -1

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cargo test
run: cargo test --locked --all
+6 -1
View File
@@ -31,7 +31,12 @@ cargo build --release
sudo install -m755 target/release/private_proof_of_reserve_cli /usr/local/bin/por
```
---
## Running tests
```bash
cargo test
```
\## Running a local Bitcoin node
+25
View File
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! Prototype CLI for a lower-bound Bitcoin proof-of-reserve.
//! SECURITY: demo code only.
@@ -158,3 +159,27 @@ fn verify_proof(pf: &Proof, rpc_url: &str, rpc_user: &str, rpc_pass: &str) -> Re
let _ = RangeProof::from_bytes(&base64::decode(&pf.range_proof)?)?;
Ok(())
}
// ── tests ───────────────────────────────────────────────────
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn merkle_root_single_leaf() {
let leaf = [42u8; 32];
assert_eq!(merkle_root(vec![leaf]), leaf);
}
#[test]
fn merkle_root_two_leaves() {
let a = [1u8; 32];
let b = [2u8; 32];
let mut h = Sha256::new();
h.update(a);
h.update(b);
let expected: [u8; 32] = h.finalize().into();
assert_eq!(merkle_root(vec![a, b]), expected);
}
}