github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/tests/difficulty_test.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 // 10 // 11 // 12 // 13 // 14 // 15 // 16 // 17 // 18 // 19 // 20 // 21 // 22 // 23 // 24 25 package tests 26 27 import ( 28 "testing" 29 30 "math/big" 31 32 "github.com/ethereum/go-ethereum/common" 33 "github.com/ethereum/go-ethereum/params" 34 ) 35 36 var ( 37 mainnetChainConfig = params.ChainConfig{ 38 ChainID: big.NewInt(1), 39 HomesteadBlock: big.NewInt(1150000), 40 DAOForkBlock: big.NewInt(1920000), 41 DAOForkSupport: true, 42 EIP150Block: big.NewInt(2463000), 43 EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"), 44 EIP155Block: big.NewInt(2675000), 45 EIP158Block: big.NewInt(2675000), 46 ByzantiumBlock: big.NewInt(4370000), 47 } 48 ) 49 50 func TestDifficulty(t *testing.T) { 51 t.Parallel() 52 53 dt := new(testMatcher) 54 // 55 dt.skipLoad("hexencodetest.*") 56 dt.skipLoad("crypto.*") 57 dt.skipLoad("blockgenesistest\\.json") 58 dt.skipLoad("genesishashestest\\.json") 59 dt.skipLoad("keyaddrtest\\.json") 60 dt.skipLoad("txtest\\.json") 61 62 // 63 dt.skipLoad("difficultyCustomHomestead\\.json") 64 dt.skipLoad("difficultyMorden\\.json") 65 dt.skipLoad("difficultyOlimpic\\.json") 66 67 dt.config("Ropsten", *params.TestnetChainConfig) 68 dt.config("Morden", *params.TestnetChainConfig) 69 dt.config("Frontier", params.ChainConfig{}) 70 71 dt.config("Homestead", params.ChainConfig{ 72 HomesteadBlock: big.NewInt(0), 73 }) 74 75 dt.config("Byzantium", params.ChainConfig{ 76 ByzantiumBlock: big.NewInt(0), 77 }) 78 79 dt.config("Frontier", *params.TestnetChainConfig) 80 dt.config("MainNetwork", mainnetChainConfig) 81 dt.config("CustomMainNetwork", mainnetChainConfig) 82 dt.config("difficulty.json", mainnetChainConfig) 83 84 dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { 85 cfg := dt.findConfig(name) 86 if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { 87 t.Skip("difficulty below minimum") 88 return 89 } 90 if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil { 91 t.Error(err) 92 } 93 }) 94 }