File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ rlp = { version = "0.4", default-features = false }
1313byteorder = { version = " 1" , default-features = false }
1414sha3 = { version = " 0.8" , default-features = false }
1515
16+ [dev-dependencies ]
17+ hex-literal = " 0.2.1"
18+
1619[features ]
1720default = [" std" ]
1821std = [
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments