Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
simbahebinbo committed Jul 12, 2023
1 parent df99546 commit 55f4031
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 58 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,20 @@ The above graph demonstrates a sparse merkle tree with `2 ^ 256` leaves, which c
## License

MIT


### Environment Setup

* Install Rust from https://rustup.rs/

```
$ rustc --version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
$ cargo --version
cargo 1.63.0 (fd9c4297c 2022-07-01)
```

```
$ cargo build
$ cargo test
```
12 changes: 0 additions & 12 deletions c/rust-tests/src/tests/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,6 @@ fn test_smt_c_verify2() {
}
}

// FIXME: uncomment this later
// pub const FIXTURES_DIR: &str = "../deps/sparse-merkle-tree/fixtures";
// #[test]
// fn test_fixtures() {
// for i in 0..100 {
// let path = format!("{}/basic/case-{}.json", FIXTURES_DIR, i);
// let content = fs::read(&path).expect("read");
// let case: Case = serde_json::from_slice(&content).expect("parse json");
// run_test_case(case).expect("test case c impl");
// println!("pass {}", i);
// }
// }

proptest! {
#[test]
Expand Down
10 changes: 0 additions & 10 deletions src/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,3 @@ fn run_test_case(case: Case) -> Result<()> {

const FIXTURES_DIR: &str = "fixtures";

#[test]
fn test_fixtures() {
for i in 0..100 {
let path = format!("{}/basic/case-{}.json", FIXTURES_DIR, i);
let content = fs::read(&path).expect("read");
let case: Case = serde_json::from_slice(&content).expect("parse json");
run_test_case(case).expect("test case");
println!("pass {}", i);
}
}
36 changes: 0 additions & 36 deletions src/tests/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,6 @@ fn test_default_merkle_proof() {
// assert_ne!(root, H256::zero());
}

#[test]
fn test_merkle_root() {
fn new_blake2b() -> blake2b_rs::Blake2b {
blake2b_rs::Blake2bBuilder::new(32).personal(b"SMT").build()
}

let mut tree = SMT::default();
for (i, word) in "The quick brown fox jumps over the lazy dog"
.split_whitespace()
.enumerate()
{
let key: H256 = {
let mut buf = [0u8; 32];
let mut hasher = new_blake2b();
hasher.update(&(i as u32).to_le_bytes());
hasher.finalize(&mut buf);
buf.into()
};
let value: H256 = {
let mut buf = [0u8; 32];
let mut hasher = new_blake2b();
hasher.update(word.as_bytes());
hasher.finalize(&mut buf);
buf.into()
};
tree.update(key, value).expect("update");
}

let expected_root: H256 = [
209, 214, 1, 128, 166, 207, 49, 89, 206, 78, 169, 88, 18, 243, 130, 61, 150, 45, 43, 54,
208, 20, 237, 20, 98, 69, 130, 120, 241, 169, 248, 211,
]
.into();
assert_eq!(tree.store().leaves_map().len(), 9);
assert_eq!(tree.root(), &expected_root);
}

#[test]
fn test_zero_value_donot_change_root() {
Expand Down

0 comments on commit 55f4031

Please sign in to comment.