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 IfPeerDontAgreeGiverHasArtefact_TransactionIsNotAcceptedByDisagreeingPeer() { Interconnect(MyActor, OtherActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); ThirdActor.CounterfeitArtefact(artefact); Interconnect(MyActor, OtherActor, ThirdActor); MyAccount.SetTrust(OtherId, (SignedWeight)1); MyAccount.SetTrust(ThirdId, (SignedWeight)1); Assert.True(MakeTransaction(OtherActor, MyActor, artefact)); Assert.True(ThirdAccount.Self.HasArtefact(artefact.Id)); }
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 WhenPeerCreateArtefactThatOtherPeerAlreadyHas_PeerLoosesTrust() { Interconnect(MyActor, OtherActor, ThirdActor); var otherTrustBefore = MyAccount.GetTrust(OtherId); var thirdTrustBefore = MyAccount.GetTrust(ThirdId); var artefact = OtherActor.CreateArtefact(Artefact.Name); ThirdActor.CounterfeitArtefact(artefact); Assert.Equal(otherTrustBefore, MyAccount.GetTrust(OtherId)); var expectedThirdTrust = thirdTrustBefore.Decrease(MakeCounterfeitArtefactDistrustFactor); Assert.Equal(expectedThirdTrust, MyAccount.GetTrust(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)); }