Skip to content

Commit

Permalink
tests: updated homestead tests
Browse files Browse the repository at this point in the history
  • Loading branch information
obscuren committed Feb 18, 2016
1 parent 371871d commit 4f4d2b6
Show file tree
Hide file tree
Showing 800 changed files with 181,776 additions and 11,238 deletions.
113 changes: 113 additions & 0 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,88 +17,106 @@
package tests

import (
"math/big"
"path/filepath"
"testing"

"github.com/ethereum/go-ethereum/params"
)

func TestBcValidBlockTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcUncleHeaderValidityTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcUncleTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcForkUncleTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcInvalidHeaderTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcInvalidRLPTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcRPCAPITests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcForkBlockTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcForkStress(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcTotalDifficulty(t *testing.T) {
// skip because these will fail due to selfish mining fix
t.Skip()

params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcWallet(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcGasPricer(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
Expand All @@ -107,22 +125,117 @@ func TestBcGasPricer(t *testing.T) {

// TODO: iterate over files once we got more than a few
func TestBcRandom(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcMultiChain(t *testing.T) {
// skip due to selfish mining
t.Skip()

params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestBcState(t *testing.T) {
params.HomesteadBlock = big.NewInt(1000000)
err := RunBlockTest(filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

// Homestead tests
func TestHomesteadBcValidBlockTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcUncleTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcInvalidHeaderTests(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcRPCAPITests(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcForkStress(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcTotalDifficulty(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcWallet(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcGasPricer(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcMultiChain(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}

func TestHomesteadBcState(t *testing.T) {
params.HomesteadBlock = big.NewInt(0)
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}
8 changes: 4 additions & 4 deletions tests/block_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ func runBlockTests(bt map[string]*BlockTest, skipTests []string) error {
}

for name, test := range bt {
if skipTest[name] || name != "wallet2outOf3txsRevoke" {
if skipTest[name] {
glog.Infoln("Skipping block test", name)
continue
}
// test the block
//fmt.Println("BlockTest name:", name)
if err := runBlockTest(test); err != nil {
return fmt.Errorf("%s: %v", name, err)
}
Expand Down Expand Up @@ -286,12 +285,13 @@ func (t *BlockTest) TryBlocksInsert(blockchain *core.BlockChain) ([]btBlock, err
}
}
// RLP decoding worked, try to insert into chain:
_, err = blockchain.InsertChain(types.Blocks{cb})
blocks := types.Blocks{cb}
i, err := blockchain.InsertChain(blocks)
if err != nil {
if b.BlockHeader == nil {
continue // OK - block is supposed to be invalid, continue with next block
} else {
return nil, fmt.Errorf("Block insertion into chain failed: %v", err)
return nil, fmt.Errorf("Block #%v insertion into chain failed: %v", blocks[i].Number(), err)
}
}
if b.BlockHeader == nil {
Expand Down
Empty file modified tests/files/ABITests/basic_abi_tests.json
100644 → 100755
Empty file.
Empty file modified tests/files/BasicTests/blockgenesistest.json
100644 → 100755
Empty file.
Empty file modified tests/files/BasicTests/crypto.json
100644 → 100755
Empty file.
Empty file modified tests/files/BasicTests/difficulty.json
100644 → 100755
Empty file.
Loading

0 comments on commit 4f4d2b6

Please sign in to comment.