Beispiel #1
0
        public void WhenEndorceArtefactMayTimes_MoneyIncreaseWithLessThan_1()
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetTrust(OtherId, SignedWeight.Max);
            var artefact = ThirdActor.CreateArtefact(Artefact.Name);

            for (int i = 0; i < 100; i++)
            {
                MyActor.EndorceArtefact(artefact);
            }
            Assert.InRange(MyAccount.GetMoney(ThirdId), 0.5f, 1);
        }
Beispiel #2
0
        public void WhenEndorceDifferentArtefactsWithSameOwner_MoneyIncreaseWithLessThan_1()
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetTrust(OtherId, SignedWeight.Max);
            var artefacts = Enumerable.Range(1, 100).Select(i => ThirdActor.CreateArtefact(Artefact.Name + i));

            foreach (Artefact artefact in artefacts)
            {
                MyActor.EndorceArtefact(artefact);
            }
            Assert.InRange(MyAccount.GetMoney(ThirdId), 0.5f, 1);
        }
Beispiel #3
0
        public void WhenSync_LearnAboutUnknownArtefactsPossessedByPeers()
        {
            Interconnect(OtherActor, ThirdActor);
            var artefact = ThirdActor.CreateArtefact(Artefact.Name);

            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetTrust(OtherId, (SignedWeight)1);
            MyAccount.SetTrust(ThirdId, (SignedWeight)1);

            MyActor.SyncAll();

            Assert.True(MyAccount.KnowsArtefact(artefact.Id));
        }
Beispiel #4
0
        public void GivenMinorityOfPeersBelieveKnownArtefactHasDifferentOwner_WhenSync_ArtefactOwnerIsNotChanged(float otherTrust, float thirdTrust)
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            var artefact = ThirdActor.CreateArtefact(Artefact.Name);

            MyAccount.SetTrust(OtherId, (SignedWeight)otherTrust);
            MyAccount.SetTrust(ThirdId, (SignedWeight)thirdTrust);
            MyAccount.MoveArtefact(artefact, MyId);

            MyActor.SyncAll();

            Assert.True(MyAccount.Self.HasArtefact(artefact.Id));
            Assert.Equal(MyId, MyAccount.GetArtefact(artefact.Id).OwnerId);
        }
Beispiel #5
0
        public void AfterPeerEndorceArtefact_ArtefactOwnerIncreaseMoney(
            float trustForEndorcingPeer,
            float relationOfEndorcingPeerToEndorcedPeer,
            float expectedIncrease)
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            MyAccount.SetTrust(OtherId, (SignedWeight)trustForEndorcingPeer);
            MyAccount.SetRelationWeight(OtherId, ThirdId, (Weight)relationOfEndorcingPeerToEndorcedPeer);
            var artefact = ThirdActor.CreateArtefact(Artefact.Name);

            OtherActor.EndorceArtefact(artefact);

            Assert.Equal(expectedIncrease, MyAccount.GetMoney(ThirdId));
        }
Beispiel #6
0
        public void WhenPeerEndorceArtefactWithWrongOwner_PeerLoosesTrust()
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            var artefact    = ThirdActor.CreateArtefact(Artefact.Name);
            var trustBefore = MyAccount.GetTrust(OtherId);

            OtherAccount.ForgetArtefact(artefact.Id);

            var fakeArtefact = new Artefact(artefact, OtherId);

            OtherActor.EndorceArtefact(fakeArtefact);

            var expectedTrust = trustBefore.Decrease(EndorceCounterfeitArtefactDistrustFactor);

            Assert.Equal(expectedTrust, MyAccount.GetTrust(OtherId));
        }