github.com/aigarnetwork/aigar@v0.0.0-20191115204914-d59a6eb70f8e/tests/difficulty_test.go (about) 1 // Copyright 2018 The go-ethereum Authors 2 // Copyright 2019 The go-aigar Authors 3 // This file is part of the go-aigar library. 4 // 5 // The go-aigar library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-aigar library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-aigar library. If not, see <http://www.gnu.org/licenses/>. 17 18 package tests 19 20 import ( 21 "math/big" 22 "testing" 23 24 "github.com/AigarNetwork/aigar/common" 25 "github.com/AigarNetwork/aigar/params" 26 ) 27 28 var ( 29 mainnetChainConfig = params.ChainConfig{ 30 ChainID: big.NewInt(1), 31 HomesteadBlock: big.NewInt(1150000), 32 DAOForkBlock: big.NewInt(1920000), 33 DAOForkSupport: true, 34 EIP150Block: big.NewInt(2463000), 35 EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"), 36 EIP155Block: big.NewInt(2675000), 37 EIP158Block: big.NewInt(2675000), 38 ByzantiumBlock: big.NewInt(4370000), 39 } 40 ) 41 42 func TestDifficulty(t *testing.T) { 43 t.Parallel() 44 45 dt := new(testMatcher) 46 // Not difficulty-tests 47 dt.skipLoad("hexencodetest.*") 48 dt.skipLoad("crypto.*") 49 dt.skipLoad("blockgenesistest\\.json") 50 dt.skipLoad("genesishashestest\\.json") 51 dt.skipLoad("keyaddrtest\\.json") 52 dt.skipLoad("txtest\\.json") 53 54 // files are 2 years old, contains strange values 55 dt.skipLoad("difficultyCustomHomestead\\.json") 56 dt.skipLoad("difficultyMorden\\.json") 57 dt.skipLoad("difficultyOlimpic\\.json") 58 59 dt.config("Ropsten", *params.TestnetChainConfig) 60 dt.config("Morden", *params.TestnetChainConfig) 61 dt.config("Frontier", params.ChainConfig{}) 62 63 dt.config("Homestead", params.ChainConfig{ 64 HomesteadBlock: big.NewInt(0), 65 }) 66 67 dt.config("Byzantium", params.ChainConfig{ 68 ByzantiumBlock: big.NewInt(0), 69 }) 70 71 dt.config("Frontier", *params.TestnetChainConfig) 72 dt.config("MainNetwork", mainnetChainConfig) 73 dt.config("CustomMainNetwork", mainnetChainConfig) 74 dt.config("Constantinople", params.ChainConfig{ 75 ConstantinopleBlock: big.NewInt(0), 76 }) 77 dt.config("difficulty.json", mainnetChainConfig) 78 79 dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { 80 cfg := dt.findConfig(name) 81 if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { 82 t.Skip("difficulty below minimum") 83 return 84 } 85 if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil { 86 t.Error(err) 87 } 88 }) 89 }