github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/tests/difficulty_test.go (about) 1 package tests 2 3 import ( 4 "testing" 5 6 "math/big" 7 8 "github.com/neatlab/neatio/params" 9 "github.com/neatlab/neatio/utilities/common" 10 ) 11 12 var ( 13 mainnetChainConfig = params.ChainConfig{ 14 ChainId: big.NewInt(1), 15 HomesteadBlock: big.NewInt(1150000), 16 DAOForkBlock: big.NewInt(1920000), 17 DAOForkSupport: true, 18 EIP150Block: big.NewInt(2463000), 19 EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), 20 EIP155Block: big.NewInt(2675000), 21 EIP158Block: big.NewInt(2675000), 22 ByzantiumBlock: big.NewInt(4370000), 23 } 24 ) 25 26 func TestDifficulty(t *testing.T) { 27 t.Parallel() 28 29 dt := new(testMatcher) 30 31 dt.skipLoad("hexencodetest.*") 32 dt.skipLoad("crypto.*") 33 dt.skipLoad("blockgenesistest\\.json") 34 dt.skipLoad("genesishashestest\\.json") 35 dt.skipLoad("keyaddrtest\\.json") 36 dt.skipLoad("txtest\\.json") 37 38 dt.skipLoad("difficultyCustomHomestead\\.json") 39 dt.skipLoad("difficultyMorden\\.json") 40 dt.skipLoad("difficultyOlimpic\\.json") 41 42 dt.config("Ropsten", *params.TestnetChainConfig) 43 dt.config("Morden", *params.TestnetChainConfig) 44 dt.config("Frontier", params.ChainConfig{}) 45 46 dt.config("Homestead", params.ChainConfig{ 47 HomesteadBlock: big.NewInt(0), 48 }) 49 50 dt.config("Byzantium", params.ChainConfig{ 51 ByzantiumBlock: big.NewInt(0), 52 }) 53 54 dt.config("Frontier", *params.TestnetChainConfig) 55 dt.config("MainNetwork", mainnetChainConfig) 56 dt.config("CustomMainNetwork", mainnetChainConfig) 57 dt.config("difficulty.json", mainnetChainConfig) 58 59 dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) { 60 cfg := dt.findConfig(name) 61 if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 { 62 t.Skip("difficulty below minimum") 63 return 64 } 65 if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil { 66 t.Error(err) 67 } 68 }) 69 }