public void MiningBenchmark() { var controller = new ChainAuthority(); var id = Guid.NewGuid(); const int mineAmount = 10; TimeSpan span; var watch = new Stopwatch(); for (var i = 0; i < mineAmount; i++) { watch.Start(); controller.Mine(id.ToString()); watch.Stop(); span += watch.Elapsed; watch.Reset(); } span /= mineAmount; var average = span.TotalSeconds; Console.WriteLine($"Average mining time is {average} seconds for {mineAmount} mined blocks."); }
public void CanMine() { var controller = new ChainAuthority(); var id = Guid.NewGuid(); controller.Mine(id.ToString()); var chain = controller.GetFullChain(); Assert.AreEqual(chain.Length, 2); }
public void CanAddTransaction() { var controller = new ChainAuthority(); var index = controller.CreateTransaction("ABC", "DEF", 1500432); var id = Guid.NewGuid(); controller.Mine(id.ToString()); var transaction = controller.GetFullChain()[index].Transactions .FirstOrDefault(d => d.Sender == "ABC" && d.Recipient == "DEF" && d.Amount == 1500432); Assert.IsNotNull(transaction); }
public void CanSend() { var id = Guid.NewGuid(); const int amount = 3; var controller = new ChainAuthority(); for (var i = 0; i < amount; i++) { controller.Mine(id.ToString()); } var canSend = controller.CanSend(id.ToString(), 2); Assert.IsTrue(canSend); }
public void CanGetBalance() { var id = Guid.NewGuid(); const int amount = 3; var controller = new ChainAuthority(); for (var i = 0; i < amount; i++) { controller.Mine(id.ToString()); } var balance = controller.GetBalance(id.ToString()); Assert.AreEqual(Convert.ToDecimal(amount), balance); }