// Smoldot
// Copyright (C) 2023  Pierre Krieger
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

// TODO: add more tests

#![cfg(test)]

use core::{num::NonZero, time::Duration};

use super::{Config, HeaderVerifySuccess, NonFinalizedTree};
use crate::{chain::chain_information, header};

#[test]
fn polkadot_blocks_0_to_2() {
    let mut tree = NonFinalizedTree::new(Config {
        chain_information: chain_information::ChainInformation {
            finalized_block_header: Box::new(header::Header {
                parent_hash: [
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0,
                ],
                number: 0,
                state_root: [
                    41, 208, 217, 114, 205, 39, 203, 197, 17, 233, 88, 159, 203, 122, 69, 6, 213,
                    235, 106, 158, 141, 242, 5, 240, 4, 114, 229, 171, 53, 74, 78, 23,
                ],
                extrinsics_root: [
                    3, 23, 10, 46, 117, 151, 183, 183, 227, 216, 76, 5, 57, 29, 19, 154, 98, 177,
                    87, 231, 135, 134, 216, 192, 130, 242, 157, 207, 76, 17, 19, 20,
                ],
                digest: header::Digest::from(header::DigestRef::empty()),
            }),
            consensus: chain_information::ChainInformationConsensus::Babe {
                slots_per_epoch: NonZero::<u64>::new(2400).unwrap(),
                finalized_block_epoch_information: None,
                finalized_next_epoch_transition: Box::new(
                    chain_information::BabeEpochInformation {
                        epoch_index: 0,
                        start_slot_number: None,
                        authorities: vec![
                            header::BabeAuthority {
                                public_key: [
                                    250, 52, 55, 177, 15, 110, 122, 248, 243, 19, 98, 223, 58, 23,
                                    155, 153, 26, 140, 86, 49, 61, 27, 205, 99, 7, 164, 208, 199,
                                    52, 193, 174, 49,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    210, 65, 155, 200, 131, 84, 147, 172, 137, 235, 9, 213, 152,
                                    82, 129, 245, 223, 244, 188, 108, 122, 126, 169, 136, 253, 35,
                                    175, 5, 243, 1, 88, 10,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    204, 182, 190, 246, 13, 239, 195, 7, 36, 84, 93, 87, 68, 3,
                                    148, 237, 28, 113, 234, 126, 230, 216, 128, 237, 14, 121, 135,
                                    26, 5, 181, 228, 6,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    94, 103, 182, 76, 240, 125, 77, 37, 138, 71, 223, 99, 131, 81,
                                    33, 66, 53, 81, 113, 40, 68, 245, 182, 125, 230, 142, 54, 187,
                                    154, 33, 225, 39,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    98, 54, 135, 123, 5, 55, 2, 101, 100, 12, 19, 63, 236, 7, 230,
                                    77, 124, 168, 35, 219, 29, 197, 111, 45, 53, 132, 179, 215,
                                    192, 241, 97, 88,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    108, 82, 208, 45, 149, 195, 10, 165, 103, 253, 162, 132, 172,
                                    242, 80, 37, 202, 116, 112, 240, 176, 197, 22, 221, 249, 68,
                                    117, 161, 128, 124, 77, 37,
                                ],
                                weight: 1,
                            },
                        ],
                        randomness: [
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0,
                        ],
                        c: (1, 4),
                        allowed_slots: header::BabeAllowedSlots::PrimaryAndSecondaryVrfSlots,
                    },
                ),
            },
            finality: chain_information::ChainInformationFinality::Grandpa {
                after_finalized_block_authorities_set_id: 0,
                finalized_triggered_authorities: vec![
                    header::GrandpaAuthority {
                        public_key: [
                            222, 166, 244, 167, 39, 211, 178, 57, 146, 117, 214, 238, 136, 23, 136,
                            31, 16, 89, 116, 113, 220, 29, 39, 241, 68, 41, 90, 214, 251, 147, 60,
                            122,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            72, 182, 35, 148, 28, 42, 77, 65, 207, 37, 239, 73, 84, 8, 105, 15,
                            200, 83, 247, 119, 25, 36, 152, 192, 146, 46, 171, 30, 157, 244, 240,
                            97,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            247, 45, 175, 46, 86, 14, 79, 15, 34, 251, 92, 187, 4, 173, 29, 127,
                            238, 133, 10, 171, 35, 143, 208, 20, 193, 120, 118, 158, 126, 58, 155,
                            132,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            28, 21, 28, 17, 203, 114, 51, 77, 38, 215, 7, 105, 227, 175, 123, 191,
                            243, 128, 26, 78, 45, 202, 43, 9, 183, 204, 224, 175, 141, 216, 19, 7,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            104, 13, 39, 130, 19, 249, 8, 101, 138, 73, 161, 2, 90, 127, 70, 108,
                            25, 126, 143, 182, 250, 187, 94, 98, 34, 10, 123, 215, 95, 134, 12,
                            171,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            142, 89, 54, 135, 0, 234, 137, 226, 191, 137, 34, 204, 158, 75, 134,
                            214, 101, 29, 28, 104, 154, 13, 87, 129, 63, 151, 104, 219, 170, 222,
                            207, 113,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                ],
                finalized_scheduled_change: None,
            },
        }
        .try_into()
        .unwrap(),
        blocks_capacity: 8,
        block_number_bytes: 4,
        allow_unknown_consensus_engines: false,
    });

    let block1 = vec![
        145, 177, 113, 187, 21, 142, 45, 56, 72, 250, 35, 169, 241, 194, 81, 130, 251, 142, 32, 49,
        59, 44, 30, 180, 146, 25, 218, 122, 112, 206, 144, 195, 4, 197, 111, 205, 110, 122, 117,
        121, 38, 172, 227, 225, 236, 255, 155, 64, 16, 252, 120, 185, 13, 69, 146, 2, 163, 57, 38,
        106, 127, 99, 96, 0, 47, 154, 135, 246, 175, 100, 239, 151, 175, 242, 211, 27, 235, 253,
        213, 159, 143, 226, 239, 96, 25, 39, 139, 99, 75, 37, 21, 163, 143, 28, 76, 36, 32, 12, 6,
        66, 65, 66, 69, 181, 1, 1, 0, 0, 0, 0, 147, 222, 204, 15, 0, 0, 0, 0, 54, 46, 216, 214, 5,
        86, 69, 72, 127, 228, 46, 156, 134, 64, 190, 101, 31, 112, 163, 162, 160, 54, 88, 4, 107,
        43, 67, 240, 33, 102, 87, 4, 80, 26, 249, 177, 202, 110, 151, 76, 37, 126, 61, 38, 96, 155,
        95, 104, 181, 176, 161, 218, 83, 247, 242, 82, 187, 229, 217, 73, 72, 195, 151, 5, 201,
        143, 250, 75, 134, 157, 212, 74, 194, 149, 40, 227, 114, 61, 97, 156, 199, 237, 241, 211,
        247, 183, 165, 122, 149, 127, 106, 126, 155, 219, 39, 10, 4, 66, 65, 66, 69, 73, 4, 1, 24,
        250, 52, 55, 177, 15, 110, 122, 248, 243, 19, 98, 223, 58, 23, 155, 153, 26, 140, 86, 49,
        61, 27, 205, 99, 7, 164, 208, 199, 52, 193, 174, 49, 1, 0, 0, 0, 0, 0, 0, 0, 210, 65, 155,
        200, 131, 84, 147, 172, 137, 235, 9, 213, 152, 82, 129, 245, 223, 244, 188, 108, 122, 126,
        169, 136, 253, 35, 175, 5, 243, 1, 88, 10, 1, 0, 0, 0, 0, 0, 0, 0, 204, 182, 190, 246, 13,
        239, 195, 7, 36, 84, 93, 87, 68, 3, 148, 237, 28, 113, 234, 126, 230, 216, 128, 237, 14,
        121, 135, 26, 5, 181, 228, 6, 1, 0, 0, 0, 0, 0, 0, 0, 94, 103, 182, 76, 240, 125, 77, 37,
        138, 71, 223, 99, 131, 81, 33, 66, 53, 81, 113, 40, 68, 245, 182, 125, 230, 142, 54, 187,
        154, 33, 225, 39, 1, 0, 0, 0, 0, 0, 0, 0, 98, 54, 135, 123, 5, 55, 2, 101, 100, 12, 19, 63,
        236, 7, 230, 77, 124, 168, 35, 219, 29, 197, 111, 45, 53, 132, 179, 215, 192, 241, 97, 88,
        1, 0, 0, 0, 0, 0, 0, 0, 108, 82, 208, 45, 149, 195, 10, 165, 103, 253, 162, 132, 172, 242,
        80, 37, 202, 116, 112, 240, 176, 197, 22, 221, 249, 68, 117, 161, 128, 124, 77, 37, 1, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1, 1, 212, 104, 104, 12, 132, 75, 25, 25, 77,
        77, 251, 220, 102, 151, 163, 91, 242, 180, 148, 189, 162, 197, 166, 150, 29, 77, 78, 172,
        251, 247, 69, 116, 55, 155, 160, 217, 123, 91, 182, 80, 194, 232, 103, 10, 99, 121, 26,
        114, 121, 67, 188, 182, 153, 220, 122, 34, 139, 219, 158, 10, 152, 201, 208, 137,
    ];

    let block2 = vec![
        192, 9, 99, 88, 83, 78, 200, 210, 29, 1, 211, 75, 131, 110, 237, 71, 106, 28, 52, 63, 135,
        36, 250, 33, 83, 220, 7, 37, 173, 121, 122, 144, 8, 85, 55, 218, 60, 103, 78, 2, 10, 176,
        179, 225, 183, 0, 154, 97, 43, 138, 222, 224, 104, 10, 126, 97, 3, 44, 219, 227, 236, 94,
        34, 17, 190, 156, 234, 173, 148, 161, 214, 207, 170, 62, 116, 246, 169, 244, 255, 178, 243,
        150, 24, 78, 13, 56, 242, 6, 44, 174, 255, 65, 103, 51, 114, 121, 43, 8, 6, 66, 65, 66, 69,
        181, 1, 1, 1, 0, 0, 0, 152, 222, 204, 15, 0, 0, 0, 0, 68, 63, 119, 185, 238, 85, 22, 152,
        35, 197, 11, 218, 203, 234, 24, 167, 79, 160, 103, 58, 175, 151, 224, 30, 122, 217, 103,
        94, 252, 171, 54, 118, 80, 124, 210, 23, 130, 125, 198, 216, 66, 26, 245, 1, 43, 239, 186,
        217, 142, 38, 119, 133, 215, 6, 130, 115, 135, 48, 106, 35, 164, 135, 213, 1, 53, 129, 112,
        83, 84, 15, 67, 161, 176, 248, 239, 145, 115, 80, 47, 215, 100, 243, 17, 106, 176, 133, 91,
        183, 94, 158, 31, 42, 136, 128, 98, 12, 5, 66, 65, 66, 69, 1, 1, 48, 255, 112, 94, 54, 208,
        26, 138, 9, 200, 2, 10, 46, 98, 24, 167, 215, 23, 117, 157, 130, 206, 250, 124, 193, 231,
        26, 77, 147, 33, 218, 103, 174, 2, 6, 143, 29, 1, 175, 29, 29, 124, 133, 17, 32, 124, 4,
        148, 131, 74, 156, 58, 185, 152, 11, 51, 226, 55, 115, 244, 139, 198, 207, 133,
    ];

    let verified_header1 = match tree.verify_header(block1, Duration::new(0, 0)).unwrap() {
        HeaderVerifySuccess::Verified {
            verified_header, ..
        } => verified_header,
        _ => panic!(),
    };

    tree.insert_verified_header(verified_header1, ());

    let verified_header2 = match tree.verify_header(block2, Duration::new(0, 0)).unwrap() {
        HeaderVerifySuccess::Verified {
            verified_header, ..
        } => verified_header,
        _ => panic!(),
    };

    tree.insert_verified_header(verified_header2, ());
}

#[test]
fn kusama_blocks_0_to_2() {
    let mut tree = NonFinalizedTree::new(Config {
        chain_information: chain_information::ChainInformation {
            finalized_block_header: Box::new(header::Header {
                parent_hash: [
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0,
                ],
                number: 0,
                state_root: [
                    176, 0, 98, 3, 195, 166, 230, 189, 44, 106, 23, 177, 212, 174, 140, 164, 154,
                    49, 218, 15, 69, 121, 218, 149, 11, 18, 119, 116, 180, 74, 239, 107,
                ],
                extrinsics_root: [
                    3, 23, 10, 46, 117, 151, 183, 183, 227, 216, 76, 5, 57, 29, 19, 154, 98, 177,
                    87, 231, 135, 134, 216, 192, 130, 242, 157, 207, 76, 17, 19, 20,
                ],
                digest: header::Digest::from(header::DigestRef::empty()),
            }),
            consensus: chain_information::ChainInformationConsensus::Babe {
                slots_per_epoch: NonZero::<u64>::new(600).unwrap(),
                finalized_block_epoch_information: None,
                finalized_next_epoch_transition: Box::new(
                    chain_information::BabeEpochInformation {
                        epoch_index: 0,
                        start_slot_number: None,
                        authorities: vec![
                            header::BabeAuthority {
                                public_key: [
                                    202, 35, 147, 146, 150, 4, 115, 254, 27, 198, 95, 148, 238, 39,
                                    216, 144, 164, 156, 27, 32, 12, 0, 111, 245, 220, 197, 37, 51,
                                    14, 204, 22, 119,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    180, 111, 1, 135, 76, 231, 171, 187, 82, 32, 232, 253, 137,
                                    190, 222, 10, 218, 209, 76, 115, 3, 157, 145, 226, 142, 136,
                                    24, 35, 67, 62, 114, 63,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    214, 132, 217, 23, 109, 110, 182, 152, 135, 84, 12, 154, 137,
                                    250, 96, 151, 173, 234, 130, 252, 75, 15, 242, 109, 16, 98,
                                    180, 136, 243, 82, 225, 121,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    104, 25, 90, 113, 189, 222, 73, 17, 122, 97, 100, 36, 189, 198,
                                    10, 23, 51, 233, 106, 203, 29, 165, 174, 171, 93, 38, 140, 242,
                                    165, 114, 233, 65,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    26, 5, 117, 239, 74, 226, 75, 223, 211, 31, 76, 181, 189, 97,
                                    35, 154, 230, 124, 18, 212, 230, 74, 229, 26, 199, 86, 4, 74,
                                    166, 173, 130, 0,
                                ],
                                weight: 1,
                            },
                            header::BabeAuthority {
                                public_key: [
                                    24, 22, 143, 42, 173, 0, 129, 162, 87, 40, 150, 30, 224, 6, 39,
                                    207, 227, 94, 57, 131, 60, 128, 80, 22, 99, 43, 247, 193, 77,
                                    165, 128, 9,
                                ],
                                weight: 1,
                            },
                        ],
                        randomness: [
                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                            0, 0, 0, 0, 0, 0, 0, 0,
                        ],
                        c: (1, 4),
                        allowed_slots: header::BabeAllowedSlots::PrimaryAndSecondaryPlainSlots,
                    },
                ),
            },
            finality: chain_information::ChainInformationFinality::Grandpa {
                after_finalized_block_authorities_set_id: 0,
                finalized_triggered_authorities: vec![
                    header::GrandpaAuthority {
                        public_key: [
                            49, 110, 204, 43, 155, 120, 0, 132, 237, 16, 186, 123, 64, 22, 150,
                            175, 210, 16, 101, 97, 184, 25, 44, 61, 130, 24, 17, 237, 220, 133,
                            190, 18,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            65, 31, 193, 165, 200, 138, 178, 187, 127, 99, 178, 59, 21, 195, 153,
                            131, 207, 56, 243, 172, 45, 253, 156, 81, 104, 213, 215, 235, 186, 216,
                            53, 68,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            213, 72, 196, 144, 255, 110, 114, 142, 208, 147, 167, 64, 103, 17, 215,
                            107, 44, 125, 4, 199, 114, 119, 251, 136, 177, 195, 199, 137, 250, 100,
                            23, 55,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            185, 140, 147, 11, 155, 74, 120, 44, 163, 146, 88, 13, 2, 237, 17, 133,
                            250, 50, 20, 190, 158, 118, 105, 255, 125, 192, 150, 209, 125, 40, 107,
                            210,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            92, 227, 13, 140, 0, 125, 10, 67, 140, 146, 195, 122, 102, 11, 119, 9,
                            253, 31, 243, 187, 167, 156, 108, 72, 50, 234, 65, 7, 210, 102, 224, 1,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                    header::GrandpaAuthority {
                        public_key: [
                            244, 84, 117, 193, 93, 68, 115, 23, 183, 222, 56, 151, 38, 86, 210, 7,
                            227, 98, 247, 250, 68, 41, 214, 101, 206, 16, 169, 218, 42, 206, 37,
                            76,
                        ],
                        weight: NonZero::<u64>::new(1).unwrap(),
                    },
                ],
                finalized_scheduled_change: None,
            },
        }
        .try_into()
        .unwrap(),
        blocks_capacity: 8,
        block_number_bytes: 4,
        allow_unknown_consensus_engines: false,
    });

    let block1 = vec![
        176, 168, 212, 147, 40, 92, 45, 247, 50, 144, 223, 183, 230, 31, 135, 15, 23, 180, 24, 1,
        25, 122, 20, 156, 169, 54, 84, 73, 158, 163, 218, 254, 4, 250, 187, 12, 110, 146, 210, 158,
        139, 178, 22, 127, 60, 111, 176, 221, 235, 149, 106, 66, 120, 163, 207, 133, 54, 97, 175,
        116, 160, 118, 252, 156, 183, 163, 95, 183, 247, 97, 111, 92, 151, 157, 72, 34, 43, 61, 47,
        167, 203, 35, 49, 239, 115, 149, 71, 38, 113, 77, 145, 202, 148, 92, 195, 79, 216, 12, 6,
        66, 65, 66, 69, 52, 2, 1, 0, 0, 0, 239, 85, 165, 15, 0, 0, 0, 0, 4, 66, 65, 66, 69, 73, 4,
        1, 24, 202, 35, 147, 146, 150, 4, 115, 254, 27, 198, 95, 148, 238, 39, 216, 144, 164, 156,
        27, 32, 12, 0, 111, 245, 220, 197, 37, 51, 14, 204, 22, 119, 1, 0, 0, 0, 0, 0, 0, 0, 180,
        111, 1, 135, 76, 231, 171, 187, 82, 32, 232, 253, 137, 190, 222, 10, 218, 209, 76, 115, 3,
        157, 145, 226, 142, 136, 24, 35, 67, 62, 114, 63, 1, 0, 0, 0, 0, 0, 0, 0, 214, 132, 217,
        23, 109, 110, 182, 152, 135, 84, 12, 154, 137, 250, 96, 151, 173, 234, 130, 252, 75, 15,
        242, 109, 16, 98, 180, 136, 243, 82, 225, 121, 1, 0, 0, 0, 0, 0, 0, 0, 104, 25, 90, 113,
        189, 222, 73, 17, 122, 97, 100, 36, 189, 198, 10, 23, 51, 233, 106, 203, 29, 165, 174, 171,
        93, 38, 140, 242, 165, 114, 233, 65, 1, 0, 0, 0, 0, 0, 0, 0, 26, 5, 117, 239, 74, 226, 75,
        223, 211, 31, 76, 181, 189, 97, 35, 154, 230, 124, 18, 212, 230, 74, 229, 26, 199, 86, 4,
        74, 166, 173, 130, 0, 1, 0, 0, 0, 0, 0, 0, 0, 24, 22, 143, 42, 173, 0, 129, 162, 87, 40,
        150, 30, 224, 6, 39, 207, 227, 94, 57, 131, 60, 128, 80, 22, 99, 43, 247, 193, 77, 165,
        128, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1, 1, 70, 37, 40, 72, 131, 229, 100,
        188, 30, 64, 99, 245, 234, 43, 73, 132, 108, 221, 218, 163, 118, 29, 4, 245, 67, 182, 152,
        193, 195, 238, 147, 92, 64, 210, 91, 134, 146, 71, 195, 108, 107, 138, 140, 187, 215, 187,
        39, 104, 245, 96, 171, 124, 39, 109, 243, 198, 45, 243, 87, 167, 227, 177, 236, 141,
    ];

    let block2 = vec![
        205, 155, 142, 47, 194, 245, 124, 69, 112, 168, 99, 25, 176, 5, 131, 32, 128, 224, 196,
        120, 171, 65, 174, 93, 68, 226, 55, 5, 135, 47, 90, 211, 8, 255, 150, 206, 251, 45, 135,
        125, 246, 130, 224, 54, 106, 95, 245, 49, 208, 120, 103, 209, 119, 57, 200, 93, 225, 26,
        88, 0, 194, 10, 128, 229, 204, 79, 133, 232, 31, 56, 113, 82, 250, 111, 61, 32, 44, 149,
        220, 57, 97, 234, 129, 229, 66, 134, 140, 116, 118, 106, 66, 255, 166, 203, 49, 13, 95, 8,
        6, 66, 65, 66, 69, 52, 2, 3, 0, 0, 0, 242, 85, 165, 15, 0, 0, 0, 0, 5, 66, 65, 66, 69, 1,
        1, 30, 94, 174, 6, 178, 65, 184, 201, 171, 92, 53, 248, 22, 33, 130, 13, 174, 76, 172, 14,
        50, 0, 42, 120, 77, 188, 35, 60, 193, 16, 250, 123, 117, 227, 254, 70, 249, 151, 51, 51,
        131, 155, 40, 151, 214, 202, 179, 155, 107, 97, 230, 47, 86, 51, 175, 4, 94, 167, 224, 20,
        123, 155, 99, 130,
    ];

    let verified_header1 = match tree.verify_header(block1, Duration::new(0, 0)).unwrap() {
        HeaderVerifySuccess::Verified {
            verified_header, ..
        } => verified_header,
        _ => panic!(),
    };

    tree.insert_verified_header(verified_header1, ());

    let verified_header2 = match tree.verify_header(block2, Duration::new(0, 0)).unwrap() {
        HeaderVerifySuccess::Verified {
            verified_header, ..
        } => verified_header,
        _ => panic!(),
    };

    tree.insert_verified_header(verified_header2, ());
}
