github.com/ylsGit/go-ethereum@v1.6.5/tests/vm_test.go (about)

     1  // Copyright 2014 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package tests
    18  
    19  import (
    20  	"os"
    21  	"path/filepath"
    22  	"testing"
    23  )
    24  
    25  func BenchmarkVmAckermann32Tests(b *testing.B) {
    26  	fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
    27  	if err := BenchVmTest(fn, bconf{"ackermann32", os.Getenv("JITFORCE") == "true", os.Getenv("JITVM") == "true"}, b); err != nil {
    28  		b.Error(err)
    29  	}
    30  }
    31  
    32  func BenchmarkVmFibonacci16Tests(b *testing.B) {
    33  	fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
    34  	if err := BenchVmTest(fn, bconf{"fibonacci16", os.Getenv("JITFORCE") == "true", os.Getenv("JITVM") == "true"}, b); err != nil {
    35  		b.Error(err)
    36  	}
    37  }
    38  
    39  // I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
    40  func TestVmVMArithmetic(t *testing.T) {
    41  	fn := filepath.Join(vmTestDir, "vmArithmeticTest.json")
    42  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    43  		t.Error(err)
    44  	}
    45  }
    46  
    47  func TestVmBitwiseLogicOperation(t *testing.T) {
    48  	fn := filepath.Join(vmTestDir, "vmBitwiseLogicOperationTest.json")
    49  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    50  		t.Error(err)
    51  	}
    52  }
    53  
    54  func TestVmBlockInfo(t *testing.T) {
    55  	fn := filepath.Join(vmTestDir, "vmBlockInfoTest.json")
    56  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    57  		t.Error(err)
    58  	}
    59  }
    60  
    61  func TestVmEnvironmentalInfo(t *testing.T) {
    62  	fn := filepath.Join(vmTestDir, "vmEnvironmentalInfoTest.json")
    63  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    64  		t.Error(err)
    65  	}
    66  }
    67  
    68  func TestVmFlowOperation(t *testing.T) {
    69  	fn := filepath.Join(vmTestDir, "vmIOandFlowOperationsTest.json")
    70  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    71  		t.Error(err)
    72  	}
    73  }
    74  
    75  func TestVmLogTest(t *testing.T) {
    76  	fn := filepath.Join(vmTestDir, "vmLogTest.json")
    77  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    78  		t.Error(err)
    79  	}
    80  }
    81  
    82  func TestVmPerformance(t *testing.T) {
    83  	fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
    84  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    85  		t.Error(err)
    86  	}
    87  }
    88  
    89  func TestVmPushDupSwap(t *testing.T) {
    90  	fn := filepath.Join(vmTestDir, "vmPushDupSwapTest.json")
    91  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    92  		t.Error(err)
    93  	}
    94  }
    95  
    96  func TestVmVMSha3(t *testing.T) {
    97  	fn := filepath.Join(vmTestDir, "vmSha3Test.json")
    98  	if err := RunVmTest(fn, VmSkipTests); err != nil {
    99  		t.Error(err)
   100  	}
   101  }
   102  
   103  func TestVm(t *testing.T) {
   104  	fn := filepath.Join(vmTestDir, "vmtests.json")
   105  	if err := RunVmTest(fn, VmSkipTests); err != nil {
   106  		t.Error(err)
   107  	}
   108  }
   109  
   110  func TestVmLog(t *testing.T) {
   111  	fn := filepath.Join(vmTestDir, "vmLogTest.json")
   112  	if err := RunVmTest(fn, VmSkipTests); err != nil {
   113  		t.Error(err)
   114  	}
   115  }
   116  
   117  func TestVmInputLimits(t *testing.T) {
   118  	fn := filepath.Join(vmTestDir, "vmInputLimits.json")
   119  	if err := RunVmTest(fn, VmSkipTests); err != nil {
   120  		t.Error(err)
   121  	}
   122  }
   123  
   124  func TestVmInputLimitsLight(t *testing.T) {
   125  	fn := filepath.Join(vmTestDir, "vmInputLimitsLight.json")
   126  	if err := RunVmTest(fn, VmSkipTests); err != nil {
   127  		t.Error(err)
   128  	}
   129  }
   130  
   131  func TestVmVMRandom(t *testing.T) {
   132  	fns, _ := filepath.Glob(filepath.Join(baseDir, "RandomTests", "*"))
   133  	for _, fn := range fns {
   134  		if err := RunVmTest(fn, VmSkipTests); err != nil {
   135  			t.Error(err)
   136  		}
   137  	}
   138  }