github.com/core-coin/go-core/v2@v2.1.9/tests/difficulty_test.go (about) 1 // Copyright 2017 by the Authors 2 // This file is part of the go-core library. 3 // 4 // The go-core library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-core library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-core library. If not, see <http://www.gnu.org/licenses/>. 16 17 package tests 18 19 import ( 20 "math/big" 21 "testing" 22 23 "github.com/core-coin/go-core/v2/params" 24 ) 25 26 var ( 27 mainnetChainConfig = params.ChainConfig{ 28 NetworkID: big.NewInt(1), 29 } 30 ) 31 32 func TestDifficulty(t *testing.T) { 33 t.Parallel() 34 35 dt := new(testMatcher) 36 // Not difficulty-tests 37 dt.skipLoad("hexencodetest.*") 38 dt.skipLoad("crypto.*") 39 dt.skipLoad("blockgenesistest\\.json") 40 dt.skipLoad("genesishashestest\\.json") 41 dt.skipLoad("keyaddrtest\\.json") 42 dt.skipLoad("txtest\\.json") 43 44 // files are 2 years old, contains strange values 45 dt.skipLoad("difficultyCustomHomestead\\.json") 46 dt.skipLoad("difficultyMorden\\.json") 47 dt.skipLoad("difficultyOlimpic\\.json") 48 49 dt.config("Devin", *params.DevinChainConfig) 50 dt.config("Morden", *params.DevinChainConfig) 51 dt.config("Frontier", params.ChainConfig{}) 52 53 dt.config("Frontier", *params.DevinChainConfig) 54 dt.config("MainNetwork", mainnetChainConfig) 55 dt.config("CustomMainNetwork", mainnetChainConfig) 56 dt.config("difficulty.json", mainnetChainConfig) 57 58 dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { 59 cfg := dt.findConfig(name) 60 if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { 61 t.Skip("difficulty below minimum") 62 return 63 } 64 if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil { 65 t.Error(err) 66 } 67 }) 68 }