public static void Initialize(TestContext context)
        {
            _gMiner   = new TestGMiner();
            _beamAlgo = new Algorithm(MinerBaseType.GMiner, AlgorithmType.Beam);
            var dev  = new ComputeDevice(0);
            var pair = new MiningPair(dev, _beamAlgo);

            _gMiner.InitBenchmarkSetup(pair);
            NHSmaData.Initialize();
        }
        public static void Initialize(TestContext context)
        {
            _zHashBMiner = new TestBMiner(AlgorithmType.ZHash);
            _zHashAlgo   = new Algorithm(MinerBaseType.BMiner, AlgorithmType.ZHash);
            var dev = new ComputeDevice(0);

            _zHashBMiner.InitBenchmarkSetup(new MiningPair(dev, _zHashAlgo));

            _ethashBMiner = new TestBMiner(AlgorithmType.DaggerHashimoto);
            _etHashAlgo   = new Algorithm(MinerBaseType.BMiner, AlgorithmType.DaggerHashimoto);
            _ethashBMiner.InitBenchmarkSetup(new MiningPair(dev, _etHashAlgo));

            NHSmaData.Initialize();
        }
Ejemplo n.º 3
0
        public void Paying_ShouldReturnCorrectAndFlagsAreSet()
        {
            var testPaying = new Dictionary <AlgorithmType, double>
            {
                { AlgorithmType.CryptoNight, 0.11 },
                { AlgorithmType.DaggerHashimoto, 0.9 },
                { AlgorithmType.Blake2s, 0 }
            };

            var testZero = new List <AlgorithmType>
            {
                AlgorithmType.Keccak,
                AlgorithmType.Equihash,
                AlgorithmType.Pascal
            };

            // Check initialized flag and initialize
            NHSmaData.Initialize();
            Assert.IsTrue(NHSmaData.Initialized);

            // Check hasdata flag and update with test data
            NHSmaData.UpdateSmaPaying(testPaying);
            Assert.IsTrue(NHSmaData.HasData);

            foreach (var algo in testPaying.Keys)
            {
                // Every key from test dict should return true and paying
                Assert.IsTrue(NHSmaData.TryGetPaying(algo, out var paying));
                Assert.AreEqual(testPaying[algo], paying);
            }

            foreach (var algo in testZero)
            {
                // These algos were not set so their value should be 0 (but still return true)
                Assert.IsTrue(NHSmaData.TryGetPaying(algo, out var paying));
                Assert.AreEqual(0, paying);
            }

            // Should be false since DaggerDecred does not have a valid SMA
            Assert.IsFalse(NHSmaData.TryGetPaying(AlgorithmType.DaggerDecred, out _));
        }
Ejemplo n.º 4
0
        public void Stable_ShouldReturnCorrect()
        {
            // We will update the stable algos multiple times
            var testStable = new List <List <AlgorithmType> >
            {
                new List <AlgorithmType>
                {
                    AlgorithmType.Keccak,
                    AlgorithmType.Equihash,
                    AlgorithmType.Pascal
                },
                new List <AlgorithmType>
                {
                    AlgorithmType.Keccak,
                    AlgorithmType.Equihash,
                    AlgorithmType.Pascal,
                    AlgorithmType.Blake2s
                },
                new List <AlgorithmType>
                {
                    AlgorithmType.DaggerHashimoto,
                    AlgorithmType.Equihash,
                    AlgorithmType.Pascal
                }
            };

            NHSmaData.Initialize();

            foreach (var epoch in testStable)
            {
                NHSmaData.UpdateStableAlgorithms(epoch);

                // Test over all algo types
                foreach (AlgorithmType algo in Enum.GetValues(typeof(AlgorithmType)))
                {
                    var stable = epoch.Contains(algo);
                    Assert.AreEqual(stable, NHSmaData.IsAlgorithmStable(algo));
                }
            }
        }