public void CanVerifyPrefixWithOutAnyParameter() { var sut = new ProofOfWork(); System.Console.WriteLine($"Prefix: {sut.GetPrefix()}"); Assert.Equal(1, sut.GetPrefix().Length); }
public void CanVerifyPrefixWithOutIntArrayParameter() { var sut = new ProofOfWork(Guid.NewGuid(), null); System.Console.WriteLine($"Prefix: {sut.GetPrefix()}"); Assert.True(string.IsNullOrEmpty(sut.GetPrefix())); }
public void CanCreateBlockWithModerateDifficulty() { var proofOfWork = new ProofOfWork( Guid.NewGuid(), new int[] { 1, 3, 5 } ); var sut = new BlockChain.Block <object> ( new { Amount = 108, Message = "Hello" }, null, proofOfWork ); Assert.True(sut.IsValid()); Assert.Equal( proofOfWork.GetPrefix(), sut.Hash.Substring( 0, proofOfWork.GetPrefix().Length ) ); }
public void CanVerifyPrefixWithParameters() { var guid = Guid.NewGuid(); int[] charsToTake = { 0, 5, 10 }; var expected = string.Empty; var sut = new ProofOfWork(guid, charsToTake); Array.ForEach(charsToTake, element => { expected += guid.ToString().Substring(element, 1); }); Assert.Equal(expected, sut.GetPrefix()); System.Console.WriteLine($"Prefix: {sut.GetPrefix()}"); }