예제 #1
0
 public void WhenEndorcePeerManyTimes_MoneyIncreaseLessThanTwo()
 {
     Interconnect(MyActor, OtherActor, ThirdActor);
     MyAccount.SetTrust(OtherId, SignedWeight.Max);
     for (int i = 0; i < 100; i++)
     {
         OtherActor.Endorce(ThirdId);
     }
     Assert.InRange(MyAccount.GetMoney(ThirdId), 1f, 2f);
 }
        public void AfterEndorcedUnconnectedAgent_RelationIsIncreaseWithEndorcementFactor()
        {
            Interconnect(MyActor, OtherActor);

            OtherActor.Endorce(ThirdId);

            var expectedRelationWeight = Weight.Min.Increase(EndorcementTrustFactor);
            var actualRelationWeight   = MyAccount.GetPeer(OtherId).GetRelation(ThirdId).Strength;

            Assert.Equal(expectedRelationWeight, actualRelationWeight);
        }
        public void AfterEndorcedConnectedAgent_RelationIsIncreaseWithEndorcementFactor(float initialRelation)
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetRelationWeight(OtherId, ThirdId, (Weight)initialRelation);

            OtherActor.Endorce(ThirdId);

            var expectedRelationWeight = ((Weight)initialRelation).Increase(EndorcementTrustFactor);
            var actualRelationWeight   = MyAccount.GetRelationWeight(OtherId, ThirdId);

            Assert.Equal(expectedRelationWeight, actualRelationWeight);
        }
예제 #4
0
        public void AfterPeerEndorcedMe_MyMoneyIncrease(
            float trustForEndorcingPeer,
            float relationOfEndorcingPeerToEndorcedPeer,
            float expectedMoney)
        {
            Interconnect(MyActor, OtherActor);
            MyAccount.SetTrust(OtherId, (SignedWeight)trustForEndorcingPeer);
            MyAccount.SetRelationWeight(OtherId, MyId, (Weight)relationOfEndorcingPeerToEndorcedPeer);

            OtherActor.Endorce(MyId);
            Assert.Equal(expectedMoney, MyAccount.Self.Money);
        }
예제 #5
0
        public void AfterOnePeerEndorceAnotherPeer_EndorcedPeerIncreaseMoney(
            float trustForEndorcingPeer,
            float relationOfEndorcingPeerToEndorcedPeer,
            float expectedMoney)
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetTrust(OtherId, (SignedWeight)trustForEndorcingPeer);
            MyAccount.SetRelationWeight(OtherId, ThirdId, (Weight)relationOfEndorcingPeerToEndorcedPeer);

            OtherActor.Endorce(ThirdId);

            Assert.Equal(expectedMoney, MyAccount.GetMoney(ThirdId));
        }