github.com/ylsGit/go-ethereum@v1.6.5/tests/block_test.go (about)

     1  // Copyright 2015 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  	"math/big"
    21  	"path/filepath"
    22  	"testing"
    23  )
    24  
    25  func TestBcValidBlockTests(t *testing.T) {
    26  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
    27  	if err != nil {
    28  		t.Fatal(err)
    29  	}
    30  }
    31  
    32  func TestBcUncleHeaderValidityTests(t *testing.T) {
    33  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
    34  	if err != nil {
    35  		t.Fatal(err)
    36  	}
    37  }
    38  
    39  func TestBcUncleTests(t *testing.T) {
    40  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
    41  	if err != nil {
    42  		t.Fatal(err)
    43  	}
    44  }
    45  
    46  func TestBcForkUncleTests(t *testing.T) {
    47  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
    48  	if err != nil {
    49  		t.Fatal(err)
    50  	}
    51  }
    52  
    53  func TestBcInvalidHeaderTests(t *testing.T) {
    54  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
    55  	if err != nil {
    56  		t.Fatal(err)
    57  	}
    58  }
    59  
    60  func TestBcInvalidRLPTests(t *testing.T) {
    61  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
    62  	if err != nil {
    63  		t.Fatal(err)
    64  	}
    65  }
    66  
    67  func TestBcRPCAPITests(t *testing.T) {
    68  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
    69  	if err != nil {
    70  		t.Fatal(err)
    71  	}
    72  }
    73  
    74  func TestBcForkBlockTests(t *testing.T) {
    75  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
    76  	if err != nil {
    77  		t.Fatal(err)
    78  	}
    79  }
    80  
    81  func TestBcForkStress(t *testing.T) {
    82  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
    83  	if err != nil {
    84  		t.Fatal(err)
    85  	}
    86  }
    87  
    88  func TestBcTotalDifficulty(t *testing.T) {
    89  	// skip because these will fail due to selfish mining fix
    90  	t.Skip()
    91  
    92  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
    93  	if err != nil {
    94  		t.Fatal(err)
    95  	}
    96  }
    97  
    98  func TestBcWallet(t *testing.T) {
    99  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
   100  	if err != nil {
   101  		t.Fatal(err)
   102  	}
   103  }
   104  
   105  func TestBcGasPricer(t *testing.T) {
   106  	err := RunBlockTest(big.NewInt(1000000), nil, nil, filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests)
   107  	if err != nil {
   108  		t.Fatal(err)
   109  	}
   110  }
   111  
   112  // TODO: iterate over files once we got more than a few
   113  func TestBcRandom(t *testing.T) {
   114  	err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests)
   115  	if err != nil {
   116  		t.Fatal(err)
   117  	}
   118  }
   119  
   120  func TestBcMultiChain(t *testing.T) {
   121  	// skip due to selfish mining
   122  	t.Skip()
   123  
   124  	err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
   125  	if err != nil {
   126  		t.Fatal(err)
   127  	}
   128  }
   129  
   130  func TestBcState(t *testing.T) {
   131  	err := RunBlockTest(big.NewInt(1000000), nil, big.NewInt(10), filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
   132  	if err != nil {
   133  		t.Fatal(err)
   134  	}
   135  }
   136  
   137  // Homestead tests
   138  func TestHomesteadBcValidBlockTests(t *testing.T) {
   139  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
   140  	if err != nil {
   141  		t.Fatal(err)
   142  	}
   143  }
   144  
   145  func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) {
   146  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
   147  	if err != nil {
   148  		t.Fatal(err)
   149  	}
   150  }
   151  
   152  func TestHomesteadBcUncleTests(t *testing.T) {
   153  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
   154  	if err != nil {
   155  		t.Fatal(err)
   156  	}
   157  }
   158  
   159  func TestHomesteadBcInvalidHeaderTests(t *testing.T) {
   160  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
   161  	if err != nil {
   162  		t.Fatal(err)
   163  	}
   164  }
   165  
   166  func TestHomesteadBcRPCAPITests(t *testing.T) {
   167  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
   168  	if err != nil {
   169  		t.Fatal(err)
   170  	}
   171  }
   172  
   173  func TestHomesteadBcForkStress(t *testing.T) {
   174  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
   175  	if err != nil {
   176  		t.Fatal(err)
   177  	}
   178  }
   179  
   180  func TestHomesteadBcTotalDifficulty(t *testing.T) {
   181  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
   182  	if err != nil {
   183  		t.Fatal(err)
   184  	}
   185  }
   186  
   187  func TestHomesteadBcWallet(t *testing.T) {
   188  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
   189  	if err != nil {
   190  		t.Fatal(err)
   191  	}
   192  }
   193  
   194  func TestHomesteadBcGasPricer(t *testing.T) {
   195  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
   196  	if err != nil {
   197  		t.Fatal(err)
   198  	}
   199  }
   200  
   201  func TestHomesteadBcMultiChain(t *testing.T) {
   202  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
   203  	if err != nil {
   204  		t.Fatal(err)
   205  	}
   206  }
   207  
   208  func TestHomesteadBcState(t *testing.T) {
   209  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
   210  	if err != nil {
   211  		t.Fatal(err)
   212  	}
   213  }
   214  
   215  // DAO hard-fork tests
   216  func TestDAOBcTheDao(t *testing.T) {
   217  	err := RunBlockTest(big.NewInt(5), big.NewInt(8), nil, filepath.Join(blockTestDir, "TestNetwork", "bcTheDaoTest.json"), BlockSkipTests)
   218  	if err != nil {
   219  		t.Fatal(err)
   220  	}
   221  }
   222  
   223  func TestEIP150Bc(t *testing.T) {
   224  	err := RunBlockTest(big.NewInt(0), big.NewInt(8), big.NewInt(10), filepath.Join(blockTestDir, "TestNetwork", "bcEIP150Test.json"), BlockSkipTests)
   225  	if err != nil {
   226  		t.Fatal(err)
   227  	}
   228  }
   229  
   230  func TestHomesteadBcExploit(t *testing.T) {
   231  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcExploitTest.json"), BlockSkipTests)
   232  	if err != nil {
   233  		t.Fatal(err)
   234  	}
   235  }
   236  func TestHomesteadBcShanghaiLove(t *testing.T) {
   237  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcShanghaiLove.json"), BlockSkipTests)
   238  	if err != nil {
   239  		t.Fatal(err)
   240  	}
   241  }
   242  func TestHomesteadBcSuicideIssue(t *testing.T) {
   243  	err := RunBlockTest(big.NewInt(0), nil, nil, filepath.Join(blockTestDir, "Homestead", "bcSuicideIssue.json"), BlockSkipTests)
   244  	if err != nil {
   245  		t.Fatal(err)
   246  	}
   247  }