core: check if sender is EOA (#23303)
This adds a check to verify that a sender-account does not have code, which means that the codehash is either `emptyCodeHash` _OR_ not present. The latter occurs IFF the sender did not previously exist, a situation which can only occur with zero cost gasprices.
This commit is contained in:
committed by
GitHub
parent
d3e3a460ec
commit
0658712f65
@ -34,10 +34,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
baseDir = filepath.Join(".", "testdata")
|
||||
blockTestDir = filepath.Join(baseDir, "BlockchainTests")
|
||||
stateTestDir = filepath.Join(baseDir, "GeneralStateTests")
|
||||
legacyStateTestDir = filepath.Join(baseDir, "LegacyTests", "Constantinople", "GeneralStateTests")
|
||||
baseDir = filepath.Join(".", "testdata")
|
||||
blockTestDir = filepath.Join(baseDir, "BlockchainTests")
|
||||
stateTestDir = filepath.Join(baseDir, "GeneralStateTests")
|
||||
//legacyStateTestDir = filepath.Join(baseDir, "LegacyTests", "Constantinople", "GeneralStateTests")
|
||||
transactionTestDir = filepath.Join(baseDir, "TransactionTests")
|
||||
vmTestDir = filepath.Join(baseDir, "VMTests")
|
||||
rlpTestDir = filepath.Join(baseDir, "RLPTests")
|
||||
@ -89,10 +89,11 @@ func findLine(data []byte, offset int64) (line int) {
|
||||
|
||||
// testMatcher controls skipping and chain config assignment to tests.
|
||||
type testMatcher struct {
|
||||
configpat []testConfig
|
||||
failpat []testFailure
|
||||
skiploadpat []*regexp.Regexp
|
||||
slowpat []*regexp.Regexp
|
||||
configpat []testConfig
|
||||
failpat []testFailure
|
||||
skiploadpat []*regexp.Regexp
|
||||
slowpat []*regexp.Regexp
|
||||
runonlylistpat *regexp.Regexp
|
||||
}
|
||||
|
||||
type testConfig struct {
|
||||
@ -123,6 +124,10 @@ func (tm *testMatcher) fails(pattern string, reason string) {
|
||||
tm.failpat = append(tm.failpat, testFailure{regexp.MustCompile(pattern), reason})
|
||||
}
|
||||
|
||||
func (tm *testMatcher) runonly(pattern string) {
|
||||
tm.runonlylistpat = regexp.MustCompile(pattern)
|
||||
}
|
||||
|
||||
// config defines chain config for tests matching the pattern.
|
||||
func (tm *testMatcher) config(pattern string, cfg params.ChainConfig) {
|
||||
tm.configpat = append(tm.configpat, testConfig{regexp.MustCompile(pattern), cfg})
|
||||
@ -212,6 +217,11 @@ func (tm *testMatcher) runTestFile(t *testing.T, path, name string, runTest inte
|
||||
if r, _ := tm.findSkip(name); r != "" {
|
||||
t.Skip(r)
|
||||
}
|
||||
if tm.runonlylistpat != nil {
|
||||
if !tm.runonlylistpat.MatchString(name) {
|
||||
t.Skip("Skipped by runonly")
|
||||
}
|
||||
}
|
||||
t.Parallel()
|
||||
|
||||
// Load the file as map[string]<testType>.
|
||||
@ -265,3 +275,14 @@ func runTestFunc(runTest interface{}, t *testing.T, name string, m reflect.Value
|
||||
m.MapIndex(reflect.ValueOf(key)),
|
||||
})
|
||||
}
|
||||
|
||||
func TestMatcherRunonlylist(t *testing.T) {
|
||||
t.Parallel()
|
||||
tm := new(testMatcher)
|
||||
tm.runonly("invalid*")
|
||||
tm.walk(t, rlpTestDir, func(t *testing.T, name string, test *RLPTest) {
|
||||
if name[:len("invalidRLPTest.json")] != "invalidRLPTest.json" {
|
||||
t.Fatalf("invalid test found: %s != invalidRLPTest.json", name)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user