@@ -1375,19 +1375,54 @@ mod tests {
1375
1375
}
1376
1376
1377
1377
#[ tokio:: test]
1378
- async fn test_node_run_has_genesis_block ( ) {
1378
+ async fn test_node_has_genesis_block ( ) {
1379
1379
let node = InMemoryNode :: < HttpForkSource > :: default ( ) ;
1380
1380
1381
1381
let block = node
1382
1382
. get_block_by_number ( BlockNumber :: Latest , false )
1383
1383
. await
1384
- . expect ( "failed fetching block by hash " )
1384
+ . expect ( "failed fetching block by number " )
1385
1385
. expect ( "no block" ) ;
1386
1386
1387
1387
assert_eq ! ( 0 , block. number. as_u64( ) ) ;
1388
1388
assert_eq ! ( compute_hash( 0 , H256 :: zero( ) ) , block. hash) ;
1389
1389
}
1390
1390
1391
+ #[ tokio:: test]
1392
+ async fn test_node_creates_genesis_block_with_hash_and_zero_parent_hash ( ) {
1393
+ let node = InMemoryNode :: < HttpForkSource > :: default ( ) ;
1394
+
1395
+ let block = node
1396
+ . get_block_by_hash ( compute_hash ( 0 , H256 :: zero ( ) ) , false )
1397
+ . await
1398
+ . expect ( "failed fetching block by hash" )
1399
+ . expect ( "no block" ) ;
1400
+
1401
+ assert_eq ! ( block. parent_hash, H256 :: zero( ) ) ;
1402
+ }
1403
+
1404
+ #[ tokio:: test]
1405
+ async fn test_node_produces_blocks_with_parent_hash_links ( ) {
1406
+ let node = InMemoryNode :: < HttpForkSource > :: default ( ) ;
1407
+ testing:: apply_tx ( & node, H256 :: repeat_byte ( 0x01 ) ) ;
1408
+
1409
+ let genesis_block = node. get_block_by_number ( BlockNumber :: from ( 0 ) , false )
1410
+ . await
1411
+ . expect ( "failed fetching block by number" )
1412
+ . expect ( "no block" ) ;
1413
+ let first_block = node. get_block_by_number ( BlockNumber :: from ( 1 ) , false )
1414
+ . await
1415
+ . expect ( "failed fetching block by number" )
1416
+ . expect ( "no block" ) ;
1417
+ let second_block = node. get_block_by_number ( BlockNumber :: from ( 2 ) , false )
1418
+ . await
1419
+ . expect ( "failed fetching block by number" )
1420
+ . expect ( "no block" ) ;
1421
+
1422
+ assert_eq ! ( genesis_block. hash, first_block. parent_hash) ;
1423
+ assert_eq ! ( first_block. hash, second_block. parent_hash) ;
1424
+ }
1425
+
1391
1426
#[ tokio:: test]
1392
1427
async fn test_get_block_by_hash_for_produced_block ( ) {
1393
1428
let node = InMemoryNode :: < HttpForkSource > :: default ( ) ;
0 commit comments