Пример #1
0
        public void ReturnTrueWhenHashStartsWithZeroes()
        {
            var block = TestFactory.CreateBlock();

            block.Hash = string.Empty.PadRight(Constants.NumZeros, '0') + "aaasdsaa";
            Assert.IsFalse(block.IsValid());
        }
Пример #2
0
        public void ConvertToJson()
        {
            var block    = TestFactory.CreateBlock();
            var json     = block.ToJson();
            var desBlock = _serializer.Deserialize <Block>(json);

            Assert.IsTrue(Block.BlockComparer.Equals(block, desBlock));
        }
Пример #3
0
        public void ProperlyIConstructed()
        {
            var block = TestFactory.CreateBlock();

            Assert.AreEqual(block.Index, 123);
            Assert.AreEqual(block.Timestamp, "12-24-2017");
            Assert.AreEqual(block.PrevHash, "123-prevhash-123");
            Assert.AreEqual(block.Hash, "123-hash-123");
            Assert.AreEqual(block.Data, "some data");
            Assert.AreEqual(block.Nonce, 1232);
        }
Пример #4
0
        public void ReturnFalseWhenHashNotStartsWithZeroes()
        {
            var block = TestFactory.CreateBlock();

            Assert.IsFalse(block.IsValid());
        }
Пример #5
0
        public void CreateProperlyFormatedHeader()
        {
            var block = TestFactory.CreateBlock();

            Assert.AreEqual(block.Header, $"{block.Index}{block.PrevHash}{block.Data}{block.Timestamp}{block.Nonce}");
        }