Exemplo n.º 1
0
        public void TestCanCancelMining()
        {
            var snoop = new Rapper(420, "snoop dogg");

            var cts = new CancellationTokenSource();
            var ct  = cts.Token;

            cts.CancelAfter(1337);

            // The difficulty is over nine thouuuuusssaaaaaaannnnnnndddddddddddddddddddddd
            var mined_snoop = Miner.Mine(snoop, 9001, ct);

            Assert.AreEqual(null, mined_snoop);
        }
Exemplo n.º 2
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));
        }