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