github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/tests/difficulty_test.go (about) 1 // Copyright 2017 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum 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-ethereum 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-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package tests 18 19 import ( 20 "testing" 21 22 "math/big" 23 24 "github.com/vntchain/go-vnt/params" 25 ) 26 27 var ( 28 mainnetChainConfig = params.ChainConfig{ 29 ChainID: big.NewInt(1), 30 HubbleBlock: big.NewInt(1150000), 31 } 32 ) 33 34 func TestDifficulty(t *testing.T) { 35 t.Parallel() 36 37 dt := new(testMatcher) 38 // Not difficulty-tests 39 dt.skipLoad("hexencodetest.*") 40 dt.skipLoad("crypto.*") 41 dt.skipLoad("blockgenesistest\\.json") 42 dt.skipLoad("genesishashestest\\.json") 43 dt.skipLoad("keyaddrtest\\.json") 44 dt.skipLoad("txtest\\.json") 45 46 // files are 2 years old, contains strange values 47 dt.skipLoad("difficultyCustomHomestead\\.json") 48 dt.skipLoad("difficultyMorden\\.json") 49 dt.skipLoad("difficultyOlimpic\\.json") 50 51 dt.config("Frontier", params.ChainConfig{}) 52 53 dt.config("Hubble", params.ChainConfig{ 54 HubbleBlock: big.NewInt(0), 55 }) 56 57 dt.config("Byzantium", params.ChainConfig{ 58 // ByzantiumBlock: big.NewInt(0), 59 }) 60 61 dt.config("MainNetwork", mainnetChainConfig) 62 dt.config("CustomMainNetwork", mainnetChainConfig) 63 dt.config("difficulty.json", mainnetChainConfig) 64 65 dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { 66 cfg := dt.findConfig(name) 67 if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { 68 t.Skip("difficulty below minimum") 69 return 70 } 71 if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil { 72 t.Error(err) 73 } 74 }) 75 }