github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/tests/difficulty_test.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:50</date>
    10  //</624342685217460224>
    11  
    12  //
    13  //
    14  //
    15  //
    16  //
    17  //
    18  //
    19  //
    20  //
    21  //
    22  //
    23  //
    24  //
    25  //
    26  //
    27  
    28  package tests
    29  
    30  import (
    31  	"testing"
    32  
    33  	"math/big"
    34  
    35  	"github.com/ethereum/go-ethereum/common"
    36  	"github.com/ethereum/go-ethereum/params"
    37  )
    38  
    39  var (
    40  	mainnetChainConfig = params.ChainConfig{
    41  		ChainID:        big.NewInt(1),
    42  		HomesteadBlock: big.NewInt(1150000),
    43  		DAOForkBlock:   big.NewInt(1920000),
    44  		DAOForkSupport: true,
    45  		EIP150Block:    big.NewInt(2463000),
    46  		EIP150Hash:     common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
    47  		EIP155Block:    big.NewInt(2675000),
    48  		EIP158Block:    big.NewInt(2675000),
    49  		ByzantiumBlock: big.NewInt(4370000),
    50  	}
    51  )
    52  
    53  func TestDifficulty(t *testing.T) {
    54  	t.Parallel()
    55  
    56  	dt := new(testMatcher)
    57  //
    58  	dt.skipLoad("hexencodetest.*")
    59  	dt.skipLoad("crypto.*")
    60  	dt.skipLoad("blockgenesistest\\.json")
    61  	dt.skipLoad("genesishashestest\\.json")
    62  	dt.skipLoad("keyaddrtest\\.json")
    63  	dt.skipLoad("txtest\\.json")
    64  
    65  //
    66  	dt.skipLoad("difficultyCustomHomestead\\.json")
    67  	dt.skipLoad("difficultyMorden\\.json")
    68  	dt.skipLoad("difficultyOlimpic\\.json")
    69  
    70  	dt.config("Ropsten", *params.TestnetChainConfig)
    71  	dt.config("Morden", *params.TestnetChainConfig)
    72  	dt.config("Frontier", params.ChainConfig{})
    73  
    74  	dt.config("Homestead", params.ChainConfig{
    75  		HomesteadBlock: big.NewInt(0),
    76  	})
    77  
    78  	dt.config("Byzantium", params.ChainConfig{
    79  		ByzantiumBlock: big.NewInt(0),
    80  	})
    81  
    82  	dt.config("Frontier", *params.TestnetChainConfig)
    83  	dt.config("MainNetwork", mainnetChainConfig)
    84  	dt.config("CustomMainNetwork", mainnetChainConfig)
    85  	dt.config("difficulty.json", mainnetChainConfig)
    86  
    87  	dt.walk(t, difficultyTestDir, func(t *testing.T, name string, test *DifficultyTest) {
    88  		cfg := dt.findConfig(name)
    89  		if test.ParentDifficulty.Cmp(params.MinimumDifficulty) < 0 {
    90  			t.Skip("difficulty below minimum")
    91  			return
    92  		}
    93  		if err := dt.checkFailure(t, name, test.Run(cfg)); err != nil {
    94  			t.Error(err)
    95  		}
    96  	})
    97  }
    98