2017-09-27 13:30:41 +00:00
|
|
|
// Copyright 2017 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/>.
|
|
|
|
|
2022-05-04 03:35:59 +00:00
|
|
|
//go:build integration
|
|
|
|
|
2017-09-27 13:30:41 +00:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
2021-12-07 17:24:59 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2018-10-05 19:52:05 +00:00
|
|
|
"testing"
|
2017-09-27 13:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDifficulty(t *testing.T) {
|
2022-11-10 23:47:35 +00:00
|
|
|
//t.Parallel()
|
2017-09-27 13:30:41 +00:00
|
|
|
|
|
|
|
dt := new(testMatcher)
|
|
|
|
|
2021-12-07 17:24:59 +00:00
|
|
|
dt.walk(t, difficultyTestDir, func(t *testing.T, name string, superTest map[string]json.RawMessage) {
|
|
|
|
for fork, rawTests := range superTest {
|
|
|
|
if fork == "_info" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
var tests map[string]DifficultyTest
|
|
|
|
if err := json.Unmarshal(rawTests, &tests); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg, ok := Forks[fork]
|
|
|
|
if !ok {
|
|
|
|
t.Error(UnsupportedForkError{fork})
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
for subname, subtest := range tests {
|
|
|
|
key := fmt.Sprintf("%s/%s", fork, subname)
|
|
|
|
t.Run(key, func(t *testing.T) {
|
|
|
|
if err := dt.checkFailure(t, subtest.Run(cfg)); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2017-09-27 13:30:41 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|