Exemple #1
0
        public void TestPowServiceAddsTimeStamps()
        {
            var service = new PoWService(new PearlDiverStub());
            var result  = service.DoPoW(new Hash("BRANCH"), new Hash("TRUNK"), this.bundle.Transactions);

            foreach (var transaction in result)
            {
                Assert.AreEqual(0, transaction.AttachmentTimestampLowerBound);
                Assert.AreEqual(PoWService.MaxTimestampValue, transaction.AttachmentTimestampUpperBound);
                var currentTime = Timestamp.UnixSecondsTimestamp * 1000;
                Assert.IsTrue(transaction.AttachmentTimestamp > currentTime - 10000 && transaction.AttachmentTimestamp < currentTime + 10000);
            }
        }
Exemple #2
0
        public void TestPowServiceChainsTransactionsCorrectly()
        {
            var service = new PoWService(new PearlDiverStub());
            var result  = service.DoPoW(new Hash("BRANCH"), new Hash("TRUNK"), this.bundle.Transactions);

            for (var i = 0; i < result.Count; i++)
            {
                if (result[i].CurrentIndex == result[i].LastIndex)
                {
                    Assert.AreEqual(new Hash("BRANCH").Value, result[i].BranchTransaction.Value);
                    Assert.AreEqual(new Hash("TRUNK").Value, result[i].TrunkTransaction.Value);
                }
                else
                {
                    Assert.AreEqual(new Hash("TRUNK").Value, result[i].BranchTransaction.Value);
                    Assert.AreEqual(result[i + 1].Hash.Value, result[i].TrunkTransaction.Value);
                }
            }
        }