Пример #1
0
        public void TestSerializeBlockchainObject()
        {
            BlockChain genesisBlockTemplate = new BlockChain(null, DateTime.Now, 4, "Howdy World!");

            DagNode genesisNode = IpfsDagSerialization.MapToDag <BlockChain>(genesisBlockTemplate);

            var links = genesisNode.Links.ToList();

            Assert.AreEqual(6, links.Count);
            Assert.True(genesisNode.Size > 10);
        }
Пример #2
0
        public bool Validate(Nonced <BlockChain> chain)
        {
            DagNode chainNode     = IpfsDagSerialization.MapToDag(chain);
            var     chainNodeHash = Base58.Decode(chainNode.Hash);

            if (Miner.FoundGoldenNonce(chainNodeHash, chain.Value.Target))
            {
                return(Validate(chain.Value));
            }
            return(false);
        }
Пример #3
0
        public void TestCanMineForBasicNoncedValue()
        {
            var snoop = new Rapper(420, "snoop dogg");

            var mined_snoop = Miner.Mine(snoop, 3, CancellationToken.None);

            Assert.AreEqual(mined_snoop.Value.Name, "snoop dogg");
            Assert.AreEqual(mined_snoop.Value.Level, 420);
            Assert.AreEqual(mined_snoop.Nonce, 1347);

            var mined_dag = IpfsDagSerialization.MapToDag(mined_snoop);

            Assert.True(Miner.FoundGoldenNonce(Base58.Decode(mined_dag.Hash), 3));
        }