public void AfterOtherAccountCreateAndDestroyArtefact_ICanCreateSameArtefact() { Interconnect(MyActor, OtherActor, ThirdActor); var a1 = OtherActor.CreateArtefact(Artefact.Name); OtherActor.DestroyArtefact(a1.Id); var a2 = MyActor.CreateArtefact(Artefact.Name); Assert.True(ThirdAccount.GetPeer(MyId).HasArtefact(a2.Id)); }
public void AfterPeerTransferArtefactToMe_AllPeersPeersKnowIHaveIt() { Interconnect(MyActor, OtherActor); Interconnect(OtherActor, ThirdActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); MakeTransaction(OtherActor, MyActor, artefact); Assert.Equal(MyId, ThirdAccount.GetArtefact(artefact.Id).OwnerId); }
public void AfterEndorcedArtefact_OwnerGainsTrust() { Interconnect(MyActor, OtherActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); var trustBefore = MyAccount.GetTrust(OtherId); MyActor.EndorceArtefact(artefact); var expectedTrust = trustBefore.Increase(ArtefactEndorcementTrustFactor); Assert.Equal(expectedTrust, MyAccount.GetTrust(OtherId)); }
public void WhenActorCreateArtefact_IdIsBasedOnAccountIdWithIncrementalNumber() { var a1 = MyActor.CreateArtefact("abc"); var a2 = MyActor.CreateArtefact("abc"); var b1 = OtherActor.CreateArtefact("abc"); var b2 = OtherActor.CreateArtefact("abc"); Assert.Equal(MyAccount.Id / 1, a1.Id); Assert.Equal(MyAccount.Id / 2, a2.Id); Assert.Equal(OtherAccount.Id / 1, b1.Id); Assert.Equal(OtherAccount.Id / 2, b2.Id); }
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 WhenPeerEndorceArtefact_PeerRelationWithOwnerIsStrengthened() { Interconnect(MyActor, OtherActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); var strengthBefore = MyAccount.Self.GetRelation(OtherId).Strength; MyActor.EndorceArtefact(artefact); var expectedStrength = strengthBefore.Increase(ArtefactEndorcementTrustFactor); var strengthAfter = MyAccount.Self.GetRelation(OtherId).Strength; Assert.Equal(expectedStrength, strengthAfter); }
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 GivenMinorityOfPeersBelieveKnownArtefactHasDifferentOwner_WhenSync_TheyLooseTrust(float trustValueBefore) { var trustBefore = (SignedWeight)trustValueBefore; Interconnect(MyActor, OtherActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); MyAccount.SetTrust(OtherId, trustBefore); MyAccount.MoveArtefact(artefact, MyId); MyActor.SyncAll(); var expectedTrust = trustBefore.Decrease(HoldCounterfeitArtefactDistrustFactor); Assert.Equal(expectedTrust, MyAccount.GetTrust(OtherId)); }
public void CanExchangeArtefactsForMoney() { var money = (Money)100; Interconnect(MyActor, OtherActor, ThirdActor); SetMutualTrust((SignedWeight)1, MyActor, OtherActor, ThirdActor); InitializeMoney(money, MyActor, OtherActor, ThirdActor); var a1 = OtherActor.CreateArtefact(Artefact.Name); var a2 = OtherActor.CreateArtefact(AnotherArtefact.Name); Assert.True(MakeTransaction(OtherActor, MyActor, money, a1, a2)); Assert.Equal(Money.Min, ThirdAccount.GetMoney(MyId)); Assert.Equal(2 * money, ThirdAccount.GetMoney(OtherId)); Assert.Equal(MyId, ThirdAccount.GetArtefact(a1.Id).OwnerId); Assert.Equal(MyId, ThirdAccount.GetArtefact(a2.Id).OwnerId); }
public void WhenTransactionIsAccounted_InvolvedPeersGainTrust() { Interconnect(MyActor, OtherActor, ThirdActor); var artefact = OtherActor.CreateArtefact(Artefact.Name); var otherTrustBefore = MyAccount.GetTrust(OtherId); var thirdTrustBefore = MyAccount.GetTrust(ThirdId); MakeTransaction(OtherActor, ThirdActor, artefact); var expectedOtherTrust = otherTrustBefore.Increase(AccountedTransactionTrustFactor); var expectedThirdTrust = thirdTrustBefore.Increase(AccountedTransactionTrustFactor); var actualOtherTrust = MyAccount.GetTrust(OtherId); var actualThirdTrust = MyAccount.GetTrust(ThirdId); Assert.Equal(expectedOtherTrust, actualOtherTrust); Assert.Equal(expectedThirdTrust, actualThirdTrust); }