Skip to content

Commit 75af2aa

Browse files
authored
Merge pull request #2 from hammeWang/master
add tests about verifying mixhash computation
2 parents 37e0a83 + ac6e42b commit 75af2aa

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ rlp = { version = "0.4", default-features = false }
1313
byteorder = { version = "1", default-features = false }
1414
sha3 = { version = "0.8", default-features = false }
1515

16+
[dev-dependencies]
17+
hex-literal = "0.2.1"
18+
1619
[features]
1720
default = ["std"]
1821
std = [

src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,20 @@ pub fn get_seedhash(epoch: usize) -> H256 {
308308
}
309309
H256::from_slice(s.as_ref())
310310
}
311+
312+
#[cfg(test)]
313+
mod tests {
314+
use crate::{LightDAG, EthereumPatch};
315+
use hex_literal::*;
316+
use ethereum_types::{H256, H64};
317+
318+
#[test]
319+
fn hashimoto_should_work() {
320+
type DAG = LightDAG<EthereumPatch>;
321+
let light_dag = DAG::new(0x8947a9.into());
322+
// bare_hash of block#8996777 on ethereum mainnet
323+
let partial_header_hash = H256::from(hex!("3c2e6623b1de8862a927eeeef2b6b25dea6e1d9dad88dca3c239be3959dc384a"));
324+
let mixh = light_dag.hashimoto(partial_header_hash, H64::from(hex!("a5d3d0ccc8bb8a29"))).0;
325+
assert_eq!(mixh, H256::from(hex!("543bc0769f7d5df30e7633f4a01552c2cee7baace8a6da37fddaa19e49e81209")));
326+
}
327+
}

0 commit comments

Comments
 (0)