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); }
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); }
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)); }
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); }
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)); }
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)); }