MCPcopy Create free account
hub / github.com/CPChain/chain / testPrecompiled

Function testPrecompiled

core/vm/contracts_test.go:339–351  ·  view source on GitHub ↗
(addr string, test precompiledTest, t *testing.T)

Source from the content-addressed store, hash-verified

337}
338
339func 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
353func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
354 if test.noBenchmark {

Callers 4

TestPrecompiledModExpFunction · 0.85
TestPrecompiledBn256AddFunction · 0.85

Calls 6

NewContractFunction · 0.85
AccountRefTypeAlias · 0.85
RunPrecompiledContractFunction · 0.85
RequiredGasMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected