(addr string, test precompiledTest, t *testing.T)
| 337 | } |
| 338 | |
| 339 | func testPrecompiled(addr string, test precompiledTest, t *testing.T) { |
| 340 | p := PrimitiveContracts[common.HexToAddress(addr)] |
| 341 | in := common.Hex2Bytes(test.input) |
| 342 | contract := NewContract(AccountRef(common.HexToAddress("1337")), |
| 343 | nil, new(big.Int), p.RequiredGas(in)) |
| 344 | t.Run(fmt.Sprintf("%s-Gas=%d", test.name, contract.Gas), func(t *testing.T) { |
| 345 | if res, err := RunPrecompiledContract(p, in, contract); err != nil { |
| 346 | t.Error(err) |
| 347 | } else if common.Bytes2Hex(res) != test.expected { |
| 348 | t.Errorf("Expected %v, got %v", test.expected, common.Bytes2Hex(res)) |
| 349 | } |
| 350 | }) |
| 351 | } |
| 352 | |
| 353 | func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) { |
| 354 | if test.noBenchmark { |
no test coverage detected