Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 protected TestBase(ICryptographyFactory cryptographyFactory = null)
 {
     _network        = new Network(cryptographyFactory ?? new SimpleCryptographyFactory());
     MyAccount       = _network.CreateRootAccount("MyAccount", 1);
     OtherAccount    = _network.CreateRootAccount("OtherAccount", 2);
     ThirdAccount    = _network.CreateRootAccount("ThirdAccount", 3);
     MyActor         = MyAccount.GetActor(_network, _transactionFactory);
     OtherActor      = OtherAccount.GetActor(_network, _transactionFactory);
     ThirdActor      = ThirdAccount.GetActor(_network, _transactionFactory);
     Artefact        = new Artefact((ArtefactId)"255:1", "SomeArtefact", (AgentId)"255");
     AnotherArtefact = new Artefact((ArtefactId)"255:2", "AnotherArtefact", (AgentId)"255");
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public void Given_2_PeersWithFullTrustAndConnectivity_WhenSyncSelf_ThenGetMeanPeerMoney(
            float myMoneyBefore,
            float firstPeerAssessment,
            float secondPeerAssessment,
            float myMoneyAfter)
        {
            Interconnect(MyActor, OtherActor, ThirdActor);
            OtherAccount.SetMoney(MyId, (Money)firstPeerAssessment);
            ThirdAccount.SetMoney(MyId, (Money)secondPeerAssessment);
            MyAccount.Self.Money = (Money)myMoneyBefore;
            MyAccount.SetTrust(OtherId, (SignedWeight)1);
            MyAccount.SetTrust(ThirdId, (SignedWeight)1);

            MyActor.SyncAll();

            Assert.Equal(myMoneyAfter, MyAccount.Self.Money);
        }