mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-22 14:44:30 +00:00
These changes were migrated from EVMOS v1.10.26-evmos-rc2 tag. Relevant precompile EVMOS commits that were part of this tag: - 8d407912cad95d41db1e472f35a1eba6dc7dc363 - fcf5e42ce33b315dc294d200ad0c3da96fbc441f - f24eefdf82c19088c36fee898d66370a8489c9e7 - 359caee7e31063a6fa8a01832cabe0a35d383fff - d7a659397e07fca3a3516851aa8feefc0d632f1d The above changes were added on top of the latest available go-ethereum tag which is v1.14.8 Now we have the latest go-ethereum code with all the latest fixes along with the EVMOS like custom precompile support.
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
// Copyright 2023 The go-ethereum Authors
|
|
// This file is part of the go-ethereum library.
|
|
//
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package vm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/holiman/uint256"
|
|
)
|
|
|
|
func FuzzPrecompiledContracts(f *testing.F) {
|
|
// Create list of addresses
|
|
var addrs []common.Address
|
|
for k := range allPrecompiles {
|
|
addrs = append(addrs, k)
|
|
}
|
|
f.Fuzz(func(t *testing.T, addr uint8, input []byte) {
|
|
a := addrs[int(addr)%len(addrs)]
|
|
p := allPrecompiles[a]
|
|
gas := p.RequiredGas(input)
|
|
if gas > 10_000_000 {
|
|
return
|
|
}
|
|
inWant := string(input)
|
|
runPrecompiledContract(nil, p, AccountRef(common.Address{}), input, gas, new(uint256.Int), false)
|
|
if inHave := string(input); inWant != inHave {
|
|
t.Errorf("Precompiled %v modified input data", a)
|
|
}
|
|
})
|
|
}
|