mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
* chore: `golangci-lint` CI workflow
* fix: make `golangci-lint` happy
* chore: bump `actions/{checkout,setup-go}` versions
* chore: overhaul `.golanci.yml` config
* fix: all linter issues
* chore: exclude non-libevm linters + change deprecated option
* fix: add overflow check in example
* fix: try again; different local version?
* chore: this is trying my patience
* chore: enable `gci` and fix ordering
* chore: mark `ethclient/gethclient` test as flaky
* chore: mark `eth/catalyst` test as flaky
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package core_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/core"
|
|
"github.com/ethereum/go-ethereum/libevm"
|
|
"github.com/ethereum/go-ethereum/libevm/ethtest"
|
|
"github.com/ethereum/go-ethereum/libevm/hookstest"
|
|
)
|
|
|
|
func TestCanExecuteTransaction(t *testing.T) {
|
|
rng := ethtest.NewPseudoRand(42)
|
|
account := rng.Address()
|
|
slot := rng.Hash()
|
|
|
|
makeErr := func(from common.Address, to *common.Address, val common.Hash) error {
|
|
return fmt.Errorf("From: %v To: %v State: %v", from, to, val)
|
|
}
|
|
hooks := &hookstest.Stub{
|
|
CanExecuteTransactionFn: func(from common.Address, to *common.Address, s libevm.StateReader) error {
|
|
return makeErr(from, to, s.GetState(account, slot))
|
|
},
|
|
}
|
|
hooks.Register(t)
|
|
|
|
value := rng.Hash()
|
|
|
|
state, evm := ethtest.NewZeroEVM(t)
|
|
state.SetState(account, slot, value)
|
|
msg := &core.Message{
|
|
From: rng.Address(),
|
|
To: rng.AddressPtr(),
|
|
}
|
|
_, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(30e6))
|
|
require.EqualError(t, err, makeErr(msg.From, msg.To, value).Error())
|
|
}
|