github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/core/vm/instructions_test.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package vm
    13  
    14  import (
    15  	"math/big"
    16  	"testing"
    17  
    18  	"github.com/Sberex/go-sberex/common"
    19  	"github.com/Sberex/go-sberex/params"
    20  )
    21  
    22  type twoOperandTest struct {
    23  	x        string
    24  	y        string
    25  	expected string
    26  }
    27  
    28  func testTwoOperandOp(t *testing.T, tests []twoOperandTest, opFn func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error)) {
    29  	var (
    30  		env   = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false})
    31  		stack = newstack()
    32  		pc    = uint64(0)
    33  	)
    34  	for i, test := range tests {
    35  		x := new(big.Int).SetBytes(common.Hex2Bytes(test.x))
    36  		shift := new(big.Int).SetBytes(common.Hex2Bytes(test.y))
    37  		expected := new(big.Int).SetBytes(common.Hex2Bytes(test.expected))
    38  		stack.push(x)
    39  		stack.push(shift)
    40  		opFn(&pc, env, nil, nil, stack)
    41  		actual := stack.pop()
    42  		if actual.Cmp(expected) != 0 {
    43  			t.Errorf("Testcase %d, expected  %v, got %v", i, expected, actual)
    44  		}
    45  		// Check pool usage
    46  		// 1.pool is not allowed to contain anything on the stack
    47  		// 2.pool is not allowed to contain the same pointers twice
    48  		if env.interpreter.intPool.pool.len() > 0 {
    49  
    50  			poolvals := make(map[*big.Int]struct{})
    51  			poolvals[actual] = struct{}{}
    52  
    53  			for env.interpreter.intPool.pool.len() > 0 {
    54  				key := env.interpreter.intPool.get()
    55  				if _, exist := poolvals[key]; exist {
    56  					t.Errorf("Testcase %d, pool contains double-entry", i)
    57  				}
    58  				poolvals[key] = struct{}{}
    59  			}
    60  		}
    61  	}
    62  }
    63  
    64  func TestByteOp(t *testing.T) {
    65  	var (
    66  		env   = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false})
    67  		stack = newstack()
    68  	)
    69  	tests := []struct {
    70  		v        string
    71  		th       uint64
    72  		expected *big.Int
    73  	}{
    74  		{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 0, big.NewInt(0xAB)},
    75  		{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 1, big.NewInt(0xCD)},
    76  		{"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 0, big.NewInt(0x00)},
    77  		{"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 1, big.NewInt(0xCD)},
    78  		{"0000000000000000000000000000000000000000000000000000000000102030", 31, big.NewInt(0x30)},
    79  		{"0000000000000000000000000000000000000000000000000000000000102030", 30, big.NewInt(0x20)},
    80  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 32, big.NewInt(0x0)},
    81  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0xFFFFFFFFFFFFFFFF, big.NewInt(0x0)},
    82  	}
    83  	pc := uint64(0)
    84  	for _, test := range tests {
    85  		val := new(big.Int).SetBytes(common.Hex2Bytes(test.v))
    86  		th := new(big.Int).SetUint64(test.th)
    87  		stack.push(val)
    88  		stack.push(th)
    89  		opByte(&pc, env, nil, nil, stack)
    90  		actual := stack.pop()
    91  		if actual.Cmp(test.expected) != 0 {
    92  			t.Fatalf("Expected  [%v] %v:th byte to be %v, was %v.", test.v, test.th, test.expected, actual)
    93  		}
    94  	}
    95  }
    96  
    97  func TestSHL(t *testing.T) {
    98  	// Testcases
    99  	tests := []twoOperandTest{
   100  		{"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
   101  		{"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000002"},
   102  		{"0000000000000000000000000000000000000000000000000000000000000001", "ff", "8000000000000000000000000000000000000000000000000000000000000000"},
   103  		{"0000000000000000000000000000000000000000000000000000000000000001", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
   104  		{"0000000000000000000000000000000000000000000000000000000000000001", "0101", "0000000000000000000000000000000000000000000000000000000000000000"},
   105  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   106  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"},
   107  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "8000000000000000000000000000000000000000000000000000000000000000"},
   108  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
   109  		{"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
   110  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"},
   111  	}
   112  	testTwoOperandOp(t, tests, opSHL)
   113  }
   114  
   115  func TestSHR(t *testing.T) {
   116  	// Testcases
   117  	tests := []twoOperandTest{
   118  		{"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
   119  		{"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
   120  		{"8000000000000000000000000000000000000000000000000000000000000000", "01", "4000000000000000000000000000000000000000000000000000000000000000"},
   121  		{"8000000000000000000000000000000000000000000000000000000000000000", "ff", "0000000000000000000000000000000000000000000000000000000000000001"},
   122  		{"8000000000000000000000000000000000000000000000000000000000000000", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
   123  		{"8000000000000000000000000000000000000000000000000000000000000000", "0101", "0000000000000000000000000000000000000000000000000000000000000000"},
   124  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   125  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   126  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "0000000000000000000000000000000000000000000000000000000000000001"},
   127  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
   128  		{"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
   129  	}
   130  	testTwoOperandOp(t, tests, opSHR)
   131  }
   132  
   133  func TestSAR(t *testing.T) {
   134  	// Testcases
   135  	tests := []twoOperandTest{
   136  		{"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
   137  		{"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
   138  		{"8000000000000000000000000000000000000000000000000000000000000000", "01", "c000000000000000000000000000000000000000000000000000000000000000"},
   139  		{"8000000000000000000000000000000000000000000000000000000000000000", "ff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   140  		{"8000000000000000000000000000000000000000000000000000000000000000", "0100", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   141  		{"8000000000000000000000000000000000000000000000000000000000000000", "0101", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   142  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "00", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   143  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "01", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   144  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   145  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},
   146  		{"0000000000000000000000000000000000000000000000000000000000000000", "01", "0000000000000000000000000000000000000000000000000000000000000000"},
   147  		{"4000000000000000000000000000000000000000000000000000000000000000", "fe", "0000000000000000000000000000000000000000000000000000000000000001"},
   148  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "f8", "000000000000000000000000000000000000000000000000000000000000007f"},
   149  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "fe", "0000000000000000000000000000000000000000000000000000000000000001"},
   150  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ff", "0000000000000000000000000000000000000000000000000000000000000000"},
   151  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0100", "0000000000000000000000000000000000000000000000000000000000000000"},
   152  	}
   153  
   154  	testTwoOperandOp(t, tests, opSAR)
   155  }
   156  
   157  func TestSGT(t *testing.T) {
   158  	tests := []twoOperandTest{
   159  		{"0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   160  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   161  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   162  		{"0000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
   163  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   164  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
   165  		{"0000000000000000000000000000000000000000000000000000000000000001", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   166  		{"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   167  		{"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
   168  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   169  	}
   170  	testTwoOperandOp(t, tests, opSgt)
   171  }
   172  
   173  func TestSLT(t *testing.T) {
   174  	tests := []twoOperandTest{
   175  		{"0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   176  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   177  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   178  		{"0000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   179  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
   180  		{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   181  		{"0000000000000000000000000000000000000000000000000000000000000001", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000001"},
   182  		{"8000000000000000000000000000000000000000000000000000000000000001", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000000"},
   183  		{"8000000000000000000000000000000000000000000000000000000000000001", "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000000"},
   184  		{"7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "8000000000000000000000000000000000000000000000000000000000000001", "0000000000000000000000000000000000000000000000000000000000000001"},
   185  	}
   186  	testTwoOperandOp(t, tests, opSlt)
   187  }
   188  
   189  func opBenchmark(bench *testing.B, op func(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error), args ...string) {
   190  	var (
   191  		env   = NewEVM(Context{}, nil, params.TestChainConfig, Config{EnableJit: false, ForceJit: false})
   192  		stack = newstack()
   193  	)
   194  	// convert args
   195  	byteArgs := make([][]byte, len(args))
   196  	for i, arg := range args {
   197  		byteArgs[i] = common.Hex2Bytes(arg)
   198  	}
   199  	pc := uint64(0)
   200  	bench.ResetTimer()
   201  	for i := 0; i < bench.N; i++ {
   202  		for _, arg := range byteArgs {
   203  			a := new(big.Int).SetBytes(arg)
   204  			stack.push(a)
   205  		}
   206  		op(&pc, env, nil, nil, stack)
   207  		stack.pop()
   208  	}
   209  }
   210  
   211  func BenchmarkOpAdd64(b *testing.B) {
   212  	x := "ffffffff"
   213  	y := "fd37f3e2bba2c4f"
   214  
   215  	opBenchmark(b, opAdd, x, y)
   216  }
   217  
   218  func BenchmarkOpAdd128(b *testing.B) {
   219  	x := "ffffffffffffffff"
   220  	y := "f5470b43c6549b016288e9a65629687"
   221  
   222  	opBenchmark(b, opAdd, x, y)
   223  }
   224  
   225  func BenchmarkOpAdd256(b *testing.B) {
   226  	x := "0802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9"
   227  	y := "a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57"
   228  
   229  	opBenchmark(b, opAdd, x, y)
   230  }
   231  
   232  func BenchmarkOpSub64(b *testing.B) {
   233  	x := "51022b6317003a9d"
   234  	y := "a20456c62e00753a"
   235  
   236  	opBenchmark(b, opSub, x, y)
   237  }
   238  
   239  func BenchmarkOpSub128(b *testing.B) {
   240  	x := "4dde30faaacdc14d00327aac314e915d"
   241  	y := "9bbc61f5559b829a0064f558629d22ba"
   242  
   243  	opBenchmark(b, opSub, x, y)
   244  }
   245  
   246  func BenchmarkOpSub256(b *testing.B) {
   247  	x := "4bfcd8bb2ac462735b48a17580690283980aa2d679f091c64364594df113ea37"
   248  	y := "97f9b1765588c4e6b69142eb00d20507301545acf3e1238c86c8b29be227d46e"
   249  
   250  	opBenchmark(b, opSub, x, y)
   251  }
   252  
   253  func BenchmarkOpMul(b *testing.B) {
   254  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   255  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   256  
   257  	opBenchmark(b, opMul, x, y)
   258  }
   259  
   260  func BenchmarkOpDiv256(b *testing.B) {
   261  	x := "ff3f9014f20db29ae04af2c2d265de17"
   262  	y := "fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611"
   263  	opBenchmark(b, opDiv, x, y)
   264  }
   265  
   266  func BenchmarkOpDiv128(b *testing.B) {
   267  	x := "fdedc7f10142ff97"
   268  	y := "fbdfda0e2ce356173d1993d5f70a2b11"
   269  	opBenchmark(b, opDiv, x, y)
   270  }
   271  
   272  func BenchmarkOpDiv64(b *testing.B) {
   273  	x := "fcb34eb3"
   274  	y := "f97180878e839129"
   275  	opBenchmark(b, opDiv, x, y)
   276  }
   277  
   278  func BenchmarkOpSdiv(b *testing.B) {
   279  	x := "ff3f9014f20db29ae04af2c2d265de17"
   280  	y := "fe7fb0d1f59dfe9492ffbf73683fd1e870eec79504c60144cc7f5fc2bad1e611"
   281  
   282  	opBenchmark(b, opSdiv, x, y)
   283  }
   284  
   285  func BenchmarkOpMod(b *testing.B) {
   286  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   287  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   288  
   289  	opBenchmark(b, opMod, x, y)
   290  }
   291  
   292  func BenchmarkOpSmod(b *testing.B) {
   293  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   294  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   295  
   296  	opBenchmark(b, opSmod, x, y)
   297  }
   298  
   299  func BenchmarkOpExp(b *testing.B) {
   300  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   301  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   302  
   303  	opBenchmark(b, opExp, x, y)
   304  }
   305  
   306  func BenchmarkOpSignExtend(b *testing.B) {
   307  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   308  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   309  
   310  	opBenchmark(b, opSignExtend, x, y)
   311  }
   312  
   313  func BenchmarkOpLt(b *testing.B) {
   314  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   315  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   316  
   317  	opBenchmark(b, opLt, x, y)
   318  }
   319  
   320  func BenchmarkOpGt(b *testing.B) {
   321  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   322  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   323  
   324  	opBenchmark(b, opGt, x, y)
   325  }
   326  
   327  func BenchmarkOpSlt(b *testing.B) {
   328  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   329  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   330  
   331  	opBenchmark(b, opSlt, x, y)
   332  }
   333  
   334  func BenchmarkOpSgt(b *testing.B) {
   335  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   336  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   337  
   338  	opBenchmark(b, opSgt, x, y)
   339  }
   340  
   341  func BenchmarkOpEq(b *testing.B) {
   342  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   343  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   344  
   345  	opBenchmark(b, opEq, x, y)
   346  }
   347  
   348  func BenchmarkOpAnd(b *testing.B) {
   349  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   350  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   351  
   352  	opBenchmark(b, opAnd, x, y)
   353  }
   354  
   355  func BenchmarkOpOr(b *testing.B) {
   356  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   357  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   358  
   359  	opBenchmark(b, opOr, x, y)
   360  }
   361  
   362  func BenchmarkOpXor(b *testing.B) {
   363  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   364  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   365  
   366  	opBenchmark(b, opXor, x, y)
   367  }
   368  
   369  func BenchmarkOpByte(b *testing.B) {
   370  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   371  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   372  
   373  	opBenchmark(b, opByte, x, y)
   374  }
   375  
   376  func BenchmarkOpAddmod(b *testing.B) {
   377  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   378  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   379  	z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   380  
   381  	opBenchmark(b, opAddmod, x, y, z)
   382  }
   383  
   384  func BenchmarkOpMulmod(b *testing.B) {
   385  	x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   386  	y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   387  	z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
   388  
   389  	opBenchmark(b, opMulmod, x, y, z)
   390  }
   391  
   392  func BenchmarkOpSHL(b *testing.B) {
   393  	x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
   394  	y := "ff"
   395  
   396  	opBenchmark(b, opSHL, x, y)
   397  }
   398  func BenchmarkOpSHR(b *testing.B) {
   399  	x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
   400  	y := "ff"
   401  
   402  	opBenchmark(b, opSHR, x, y)
   403  }
   404  func BenchmarkOpSAR(b *testing.B) {
   405  	x := "FBCDEF090807060504030201ffffffffFBCDEF090807060504030201ffffffff"
   406  	y := "ff"
   407  
   408  	opBenchmark(b, opSAR, x, y)
   409  }