Пример #1
0
        public IEnumerable <EthereumTestResult> RunTests()
        {
            List <EthereumTestResult>      results = new List <EthereumTestResult>();
            IEnumerable <GeneralStateTest> tests   = (IEnumerable <GeneralStateTest>)_testsSource.LoadTests();

            foreach (GeneralStateTest test in tests)
            {
                EthereumTestResult result = null;
                if (_whenTrace != WhenTrace.Always)
                {
                    result = RunTest(test, NullTxTracer.Instance);
                }

                if (_whenTrace != WhenTrace.Never && !(result?.Pass ?? false))
                {
                    StateTestTxTracer txTracer = new StateTestTxTracer();
                    txTracer.IsTracingMemory = _traceMemory;
                    txTracer.IsTracingStack  = _traceStack;
                    result = RunTest(test, txTracer);

                    var txTrace = txTracer.BuildResult();
                    txTrace.Result.Time     = result.TimeInMs;
                    txTrace.State.StateRoot = result.StateRoot;
                    txTrace.Result.GasUsed -= _calculator.Calculate(test.Transaction, test.Fork);
                    WriteErr(txTrace);
                }

                results.Add(result);
            }

            WriteOut(results);

            Console.ReadLine();
            return(results);
        }
        public async Task <IEnumerable <EthereumTestResult> > RunTestsAsync()
        {
            List <EthereumTestResult> testResults = new List <EthereumTestResult>();
            string directoryName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "FailingTests");
            IEnumerable <BlockchainTest> tests = (IEnumerable <BlockchainTest>)_testsSource.LoadTests();

            foreach (BlockchainTest test in tests)
            {
                Setup(LimboLogs.Instance);

                Console.Write($"{test,-120} ");
                if (test.LoadFailure != null)
                {
                    WriteRed(test.LoadFailure);
                    testResults.Add(new EthereumTestResult(test.Name, test.LoadFailure));
                }
                else
                {
                    EthereumTestResult result = await RunTest(test);

                    testResults.Add(result);
                    if (result.Pass)
                    {
                        WriteGreen("PASS");
                    }
                    else
                    {
                        WriteRed("FAIL");
                        NLogManager manager = new NLogManager(string.Concat(test.Category, "_", test.Name, ".txt"), directoryName);
                        if (!Directory.Exists(directoryName))
                        {
                            Directory.CreateDirectory(directoryName);
                        }

                        Setup(manager);
                        await RunTest(test);
                    }
                }
            }

            return(testResults);
        }
Пример #3
0
        public IEnumerable <EthereumTestResult> RunTests()
        {
            List <EthereumTestResult> results = new List <EthereumTestResult>();

            Console.WriteLine($"RUNNING tests");
            Stopwatch stopwatch = new Stopwatch();
            IEnumerable <GeneralStateTest> tests = (IEnumerable <GeneralStateTest>)_testsSource.LoadTests();
            bool isNewLine = true;

            foreach (GeneralStateTest test in tests)
            {
                if (test.LoadFailure != null)
                {
                    continue;
                }

                Setup(LimboLogs.Instance);
                stopwatch.Restart();
                EthereumTestResult result = RunTest(test);
                stopwatch.Stop();
                results.Add(result);

                if (!result.Pass)
                {
                    ConsoleColor mem = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    if (!isNewLine)
                    {
                        Console.WriteLine();
                        isNewLine = true;
                    }

                    Console.WriteLine($"  {test.Name,-80} FAIL");
                    Console.ForegroundColor = mem;
                }

                long ns = 1_000_000_000L * stopwatch.ElapsedTicks / Stopwatch.Frequency;
                long ms = 1_000L * stopwatch.ElapsedTicks / Stopwatch.Frequency;
                if (ms > 100)
                {
                    if (!isNewLine)
                    {
                        Console.WriteLine();
                        isNewLine = true;
                    }

                    Console.WriteLine($"  {test.Name,-80}{ns,14}ns{ms,8}ms");
                }
                else
                {
                    Console.Write(".");
                    isNewLine = false;
                }
            }

            if (!isNewLine)
            {
                Console.WriteLine();
            }

            return(results);
        }