public void Mine_NegativeDifficulty_Throws() { // Arrange int index = 5; int nonce = 0; string data = "Hello, I'm some data"; DateTime timestamp = DateTime.UtcNow; var bloq = new Bloq <string>(index, nonce, timestamp, data, "Some Hash"); bloq.PreviousHash = "Some Hash"; // Act and Assert int difficulty = -3; Assert.Throws <ArgumentOutOfRangeException>(() => bloq.Mine(difficulty)); }
public void CalculateHash_AllSameData_ExceptIndex_GivesDifferentSameHash() { // Arrange int nonce = 0; DateTime timestamp = DateTime.UtcNow; string data = "Hello, I'm some data"; string previousHash = "41aa65db55b7bfd4af15c2945d3943c202ee77728719fed39703a2f03855c703"; var bloq1 = new Bloq <string>(1, nonce, timestamp, data, previousHash); var bloq2 = new Bloq <string>(2, nonce, timestamp, data, previousHash); // Act int difficulty = 0; bloq1.Mine(difficulty); bloq2.Mine(difficulty); string hashOfBLoq1 = bloq1.Hash; string hashOfBLoq2 = bloq2.Hash; // Assert Assert.NotEqual(hashOfBLoq1, hashOfBLoq2); }
public void CalculateHash_AllSameData_ExceptPreviousHash_GivesDifferentSameHash() { // Arrange int index = 5; int nonce = 0; string data = "Hello, I'm some data"; DateTime timestamp = DateTime.UtcNow; var bloq1 = new Bloq <string>(index, nonce, timestamp, data, "Some Hash"); var bloq2 = new Bloq <string>(index, nonce, timestamp, data, "Some Other Hash"); // Act int difficulty = 0; bloq1.Mine(difficulty); bloq2.Mine(difficulty); string hashOfBLoq1 = bloq1.Hash; string hashOfBLoq2 = bloq2.Hash; // Assert Assert.NotEqual(hashOfBLoq1, hashOfBLoq2); }