fn active_validator() {
        let mut test = TestState::new(
            State::new_test(&[Weight(3), Weight(4)], 0),
            410.into(),
            1u64,
            FinalityDetector::new(Weight(2)),
            vec![ALICE, BOB],
        );

        assert!(test.handle_timer(ALICE, 415.into()).is_empty()); // Too early: No new effects.

        // We start at time 410, with round length 16, so the first leader tick is
        // 416, and the first witness tick 426.
        // Alice wants to propose a block, and also make her witness unit at 426.
        let bctx = match &*test.handle_timer(ALICE, 416.into()) {
            [Eff::ScheduleTimer(timestamp), Eff::RequestNewBlock(bctx)]
                if *timestamp == 426.into() =>
            {
                bctx.clone()
            }
            effects => panic!("unexpected effects {:?}", effects),
        };
        assert_eq!(
            Timestamp::from(416),
            bctx.timestamp(),
            "Proposal should be scheduled for the expected timestamp."
        );

        // She has a pending deploy from Colin who wants to pay for a hot beverage.
        let (effects, new_unit) = test.propose(ALICE, 0xC0FFEE, bctx);
        assert!(
            effects.is_empty(),
            "No effects by creator after proposing a unit."
        );

        // Bob creates a confirmation unit for Alice's proposal.
        let effects = test.handle_new_unit(BOB, &new_unit.hash());
        // Validate that `effects` contain only one new unit – that is Bob's confirmation of Alice's
        // vote.
        let _ = unwrap_single(&effects).unwrap_unit();

        // Bob creates his witness message 2/3 through the round.
        let mut effects = test.handle_timer(BOB, 426.into()).into_iter();
        assert_eq!(Some(Eff::ScheduleTimer(432.into())), effects.next()); // Bob is the next leader.
        let _ = effects.next().unwrap().unwrap_unit();
        assert_eq!(None, effects.next());

        // Alice has not witnessed Bob's unit yet.
        assert_eq!(None, test.next_finalized());

        // Alice also sends her own witness message, completing the summit for her proposal.
        let mut effects = test.handle_timer(ALICE, 426.into()).into_iter();
        assert_eq!(Some(Eff::ScheduleTimer(442.into())), effects.next()); // Timer for witness unit.
        let _ = effects.next().unwrap().unwrap_unit();
        assert_eq!(None, effects.next());

        // Payment finalized! "One Pumpkin Spice Mochaccino for Corbyn!"
        assert_eq!(Some(&new_unit.hash()), test.next_finalized());
    }
// 0xC0FFEE is more readable than 0x00C0_FFEE.
0xC0FFEE is more readable than 0x00C0_FFEE.
0xC0FFEE is more readable than 0x00C0_FFEE .
fn active_validator() {
        let mut test = TestState::new(
            State::new_test(&[Weight(3), Weight(4)], 0),
            410.into(),
            1u64,
            FinalityDetector::new(Weight(2)),
            vec![ALICE, BOB],
        );
        assert!(test.handle_timer(ALICE, 415.into()).is_empty()); // Too early: No new effects.
        // We start at time 410, with round length 16, so the first leader tick is
        // 416, and the first witness tick 426.
        // Alice wants to propose a block, and also make her witness unit at 426.
        let bctx = match &*test.handle_timer(ALICE, 416.into()) {
            [Eff::ScheduleTimer(timestamp), Eff::RequestNewBlock(bctx)]
                if *timestamp == 426.into() =>
            {
                bctx.clone()
            }
            effects => panic!("unexpected effects {:?}", effects),
        };
        assert_eq!(
            Timestamp::from(416),
            bctx.timestamp(),
            "Proposal should be scheduled for the expected timestamp."
        );
        // She has a pending deploy from Colin who wants to pay for a hot beverage.
        let (effects, new_unit) = test.propose(ALICE, 0xC0FFEE, bctx);
        assert!(
            effects.is_empty(),
            "No effects by creator after proposing a unit."
        );
        // Bob creates a confirmation unit for Alice's proposal.
        let effects = test.handle_new_unit(BOB, &new_unit.hash());
        // Validate that `effects` contain only one new unit – that is Bob's confirmation of Alice's
        // vote.
        let _ = unwrap_single(&effects).unwrap_unit();
        // Bob creates his witness message 2/3 through the round.
        let mut effects = test.handle_timer(BOB, 426.into()).into_iter();
        assert_eq!(Some(Eff::ScheduleTimer(432.into())), effects.next()); // Bob is the next leader.
        let _ = effects.next().unwrap().unwrap_unit();
        assert_eq!(None, effects.next());
        // Alice has not witnessed Bob's unit yet.
        assert_eq!(None, test.next_finalized());
        // Alice also sends her own witness message, completing the summit for her proposal.
        let mut effects = test.handle_timer(ALICE, 426.into()).into_iter();
        assert_eq!(Some(Eff::ScheduleTimer(442.into())), effects.next()); // Timer for witness unit.
        let _ = effects.next().unwrap().unwrap_unit();
        assert_eq!(None, effects.next());
        // Payment finalized! "One Pumpkin Spice Mochaccino for Corbyn!"
        assert_eq!(Some(&new_unit.hash()), test.next_finalized());
    }
fn active_validator ( ) { let mut test = TestState :: new ( State :: new_test ( & [ Weight ( 3 ) , Weight ( 4 ) ] , 0 ) , 410 . into ( ) , 1u64 , FinalityDetector :: new ( Weight ( 2 ) ) , vec ! [ ALICE BOB ] , ) ; assert ! ( test handle_timer ( ALICE 415 into ( ) ) is_empty ( ) ) ; // Too early: No new effects. // We start at time 410, with round length 16, so the first leader tick is // 416, and the first witness tick 426. // Alice wants to propose a block, and also make her witness unit at 426. let bctx = match & * test . handle_timer ( ALICE , 416 . into ( ) ) { [ Eff :: ScheduleTimer ( timestamp ) , Eff :: RequestNewBlock ( bctx ) ] if * timestamp == 426 . into ( ) => { bctx . clone ( ) } effects => panic ! ( " " effects ) , } ; assert_eq ! ( Timestamp from ( 416 ) bctx timestamp ( ) " " ) ; // She has a pending deploy from Colin who wants to pay for a hot beverage. let ( effects , new_unit ) = test . propose ( ALICE , 0xC0FFEE , bctx ) ; assert ! ( effects is_empty ( ) " " ) ; // Bob creates a confirmation unit for Alice's proposal. let effects = test . handle_new_unit ( BOB , & new_unit . hash ( ) ) ; // Validate that `effects` contain only one new unit – that is Bob's confirmation of Alice's // vote. let _ = unwrap_single ( & effects ) . unwrap_unit ( ) ; // Bob creates his witness message 2/3 through the round. let mut effects = test . handle_timer ( BOB , 426 . into ( ) ) . into_iter ( ) ; assert_eq ! ( Some ( Eff ScheduleTimer ( 432 into ( ) ) ) effects next ( ) ) ; // Bob is the next leader. let _ = effects . next ( ) . unwrap ( ) . unwrap_unit ( ) ; assert_eq ! ( None effects next ( ) ) ; // Alice has not witnessed Bob's unit yet. assert_eq ! ( None test next_finalized ( ) ) ; // Alice also sends her own witness message, completing the summit for her proposal. let mut effects = test . handle_timer ( ALICE , 426 . into ( ) ) . into_iter ( ) ; assert_eq ! ( Some ( Eff ScheduleTimer ( 442 into ( ) ) ) effects next ( ) ) ; // Timer for witness unit. let _ = effects . next ( ) . unwrap ( ) . unwrap_unit ( ) ; assert_eq ! ( None effects next ( ) ) ; // Payment finalized! "One Pumpkin Spice Mochaccino for Corbyn!" assert_eq ! ( Some ( new_unit hash ( ) ) test next_finalized ( ) ) ; }
0xC0FFEE is more readable than 0x00C0_FFEE.
0xC0FFEE is more readable than 0x00C0_FFEE .