Skip to content

Commit

Permalink
Merge pull request ethereum#3094 from fjl/tests-update
Browse files Browse the repository at this point in the history
tests: update test files from github.com/ethereum/tests @ 45bc1d21d3c1
  • Loading branch information
fjl authored Oct 6, 2016
2 parents 7335a70 + 1b7b2ba commit eeb2a1a
Show file tree
Hide file tree
Showing 746 changed files with 188,445 additions and 65,642 deletions.
5 changes: 3 additions & 2 deletions core/database_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (d *diffTest) UnmarshalJSON(b []byte) (err error) {
return nil
}

func TestDifficultyFrontier(t *testing.T) {
func TestCalcDifficulty(t *testing.T) {
file, err := os.Open("../tests/files/BasicTests/difficulty.json")
if err != nil {
t.Fatal(err)
Expand All @@ -75,9 +75,10 @@ func TestDifficultyFrontier(t *testing.T) {
t.Fatal(err)
}

config := &ChainConfig{HomesteadBlock: big.NewInt(1150000)}
for name, test := range tests {
number := new(big.Int).Sub(test.CurrentBlocknumber, big.NewInt(1))
diff := calcDifficultyFrontier(test.CurrentTimestamp, test.ParentTimestamp, number, test.ParentDifficulty)
diff := CalcDifficulty(config, test.CurrentTimestamp, test.ParentTimestamp, number, test.ParentDifficulty)
if diff.Cmp(test.CurrentDifficulty) != 0 {
t.Error(name, "failed. Expected", test.CurrentDifficulty, "and calculated", diff)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,22 @@ func TestDAOBcTheDao(t *testing.T) {
t.Fatal(err)
}
}

func TestHomesteadBcExploit(t *testing.T) {
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcExploitTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}
func TestHomesteadBcShanghaiLove(t *testing.T) {
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcShanghaiLove.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}
func TestHomesteadBcSuicideIssue(t *testing.T) {
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcSuicideIssue.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}
Loading

0 comments on commit eeb2a1a

Please sign in to comment.