示例#1
0
        CampaigningProductionSubscription_Should_Trigger_TryGetFavouriteDelta_On_Campaigning_Producing_Phase()
        {
            var favourite = DeltaHelper.GetFavouriteDelta(_hashProvider);

            _deltaVoter.TryGetFavouriteDelta(Arg.Any <Cid>(), out Arg.Any <FavouriteDeltaBroadcast>())
            .Returns(ci =>
            {
                ci[1] = favourite;
                return(true);
            });

            _cycleEventProvider.MovePastNextPhase(PhaseName.Campaigning);

            _deltaVoter.Received(1).TryGetFavouriteDelta(
                Arg.Is <Cid>(b => b == PreviousDeltaBytes),
                out Arg.Any <FavouriteDeltaBroadcast>());
            _deltaHub.Received(1).BroadcastFavouriteCandidateDelta(Arg.Is(favourite));
        }
示例#2
0
        public void HandleBroadcast_Should_Cast_Hashes_To_Multihash_And_Send_To_Voter()
        {
            var receivedMessage = PrepareReceivedMessage(_newHash.ToArray(), _prevHash.ToArray(), _producerId);

            _candidateDeltaObserver.HandleBroadcast(receivedMessage);

            _deltaVoter.Received(1).OnNext(Arg.Is <CandidateDeltaBroadcast>(c =>
                                                                            c.Hash.SequenceEqual(_newHash.ToArray().ToByteString()) &&
                                                                            c.PreviousDeltaDfsHash.Equals(_prevHash.ToArray().ToByteString()) &&
                                                                            c.ProducerId.Equals(_producerId)));
        }