fn check_find_block_by_height_or_hash(
        conn: &StorageProcessor,
        expected_block_detail: &BlockDetails,
    ) -> diesel::QueryResult<()> {
        let mut queries = vec![
            expected_block_detail.block_number.to_string(),
            hex::encode(&expected_block_detail.new_state_root),
            hex::encode(&expected_block_detail.commit_tx_hash.as_ref().unwrap()),
        ];
        if let Some(verify_tx_hash) = expected_block_detail.verify_tx_hash.as_ref() {
            queries.push(hex::encode(&verify_tx_hash));
        }

        for query in queries {
            let actual_block_detail = BlockSchema(&conn)
                .find_block_by_height_or_hash(query.clone())
                .unwrap_or_else(|| {
                    panic!(format!(
                        "Can't load the existing block with the index {} using query {}",
                        expected_block_detail.block_number, query
                    ))
                });
            assert_eq!(
                actual_block_detail.block_number,
                expected_block_detail.block_number
            );
            assert_eq!(
                actual_block_detail.new_state_root,
                expected_block_detail.new_state_root
            );
            assert_eq!(
                actual_block_detail.commit_tx_hash,
                expected_block_detail.commit_tx_hash
            );
            assert_eq!(
                actual_block_detail.verify_tx_hash,
                expected_block_detail.verify_tx_hash
            );
        }

        Ok(())
    }
/// The actual test check. It obtains the block details using
/// the `find_block_by_height_or_hash` method with different types of query,
/// and compares them against the provided sample.
The actual test check. It obtains the block details using
the `find_block_by_height_or_hash` method with different types of query,
and compares them against the provided sample.
The actual test check . It obtains the block details using the ` find_block_by_height_or_hash ` method with different types of query and compares them against the provided sample .
fn check_find_block_by_height_or_hash(
        conn: &StorageProcessor,
        expected_block_detail: &BlockDetails,
    ) -> diesel::QueryResult<()> {
        let mut queries = vec![
            expected_block_detail.block_number.to_string(),
            hex::encode(&expected_block_detail.new_state_root),
            hex::encode(&expected_block_detail.commit_tx_hash.as_ref().unwrap()),
        ];
        if let Some(verify_tx_hash) = expected_block_detail.verify_tx_hash.as_ref() {
            queries.push(hex::encode(&verify_tx_hash));
        }
        for query in queries {
            let actual_block_detail = BlockSchema(&conn)
                .find_block_by_height_or_hash(query.clone())
                .unwrap_or_else(|| {
                    panic!(format!(
                        "Can't load the existing block with the index {} using query {}",
                        expected_block_detail.block_number, query
                    ))
                });
            assert_eq!(
                actual_block_detail.block_number,
                expected_block_detail.block_number
            );
            assert_eq!(
                actual_block_detail.new_state_root,
                expected_block_detail.new_state_root
            );
            assert_eq!(
                actual_block_detail.commit_tx_hash,
                expected_block_detail.commit_tx_hash
            );
            assert_eq!(
                actual_block_detail.verify_tx_hash,
                expected_block_detail.verify_tx_hash
            );
        }
        Ok(())
    }
fn check_find_block_by_height_or_hash ( conn : & StorageProcessor , expected_block_detail : & BlockDetails , ) -> diesel :: QueryResult < ( ) > { let mut queries = vec ! [ expected_block_detail block_number to_string ( ) hex encode ( expected_block_detail new_state_root ) hex encode ( expected_block_detail commit_tx_hash as_ref ( ) unwrap ( ) ) ] ; if let Some ( verify_tx_hash ) = expected_block_detail . verify_tx_hash . as_ref ( ) { queries . push ( hex :: encode ( & verify_tx_hash ) ) ; } for query in queries { let actual_block_detail = BlockSchema ( & conn ) . find_block_by_height_or_hash ( query . clone ( ) ) . unwrap_or_else ( | | { panic ! ( format ( " " expected_block_detail block_number query ) ) } ) ; assert_eq ! ( actual_block_detail block_number expected_block_detail block_number ) ; assert_eq ! ( actual_block_detail new_state_root expected_block_detail new_state_root ) ; assert_eq ! ( actual_block_detail commit_tx_hash expected_block_detail commit_tx_hash ) ; assert_eq ! ( actual_block_detail verify_tx_hash expected_block_detail verify_tx_hash ) ; } Ok ( ( ) ) }
The actual test check.
The actual test check .
conn
&StorageProcessor
expected_block_detail
&BlockDetails