Skip to content

Commit 7bb496f

Browse files
committed
[release/1.3.4] tests: updated homestead tests
1 parent 6140497 commit 7bb496f

File tree

800 files changed

+181776
-11238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

800 files changed

+181776
-11238
lines changed

tests/block_test.go

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,88 +17,106 @@
1717
package tests
1818

1919
import (
20+
"math/big"
2021
"path/filepath"
2122
"testing"
23+
24+
"github.com/ethereum/go-ethereum/params"
2225
)
2326

2427
func TestBcValidBlockTests(t *testing.T) {
28+
params.HomesteadBlock = big.NewInt(1000000)
2529
err := RunBlockTest(filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
2630
if err != nil {
2731
t.Fatal(err)
2832
}
2933
}
3034

3135
func TestBcUncleHeaderValidityTests(t *testing.T) {
36+
params.HomesteadBlock = big.NewInt(1000000)
3237
err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
3338
if err != nil {
3439
t.Fatal(err)
3540
}
3641
}
3742

3843
func TestBcUncleTests(t *testing.T) {
44+
params.HomesteadBlock = big.NewInt(1000000)
3945
err := RunBlockTest(filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
4046
if err != nil {
4147
t.Fatal(err)
4248
}
4349
}
4450

4551
func TestBcForkUncleTests(t *testing.T) {
52+
params.HomesteadBlock = big.NewInt(1000000)
4653
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
4754
if err != nil {
4855
t.Fatal(err)
4956
}
5057
}
5158

5259
func TestBcInvalidHeaderTests(t *testing.T) {
60+
params.HomesteadBlock = big.NewInt(1000000)
5361
err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
5462
if err != nil {
5563
t.Fatal(err)
5664
}
5765
}
5866

5967
func TestBcInvalidRLPTests(t *testing.T) {
68+
params.HomesteadBlock = big.NewInt(1000000)
6069
err := RunBlockTest(filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
6170
if err != nil {
6271
t.Fatal(err)
6372
}
6473
}
6574

6675
func TestBcRPCAPITests(t *testing.T) {
76+
params.HomesteadBlock = big.NewInt(1000000)
6777
err := RunBlockTest(filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
6878
if err != nil {
6979
t.Fatal(err)
7080
}
7181
}
7282

7383
func TestBcForkBlockTests(t *testing.T) {
84+
params.HomesteadBlock = big.NewInt(1000000)
7485
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
7586
if err != nil {
7687
t.Fatal(err)
7788
}
7889
}
7990

8091
func TestBcForkStress(t *testing.T) {
92+
params.HomesteadBlock = big.NewInt(1000000)
8193
err := RunBlockTest(filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
8294
if err != nil {
8395
t.Fatal(err)
8496
}
8597
}
8698

8799
func TestBcTotalDifficulty(t *testing.T) {
100+
// skip because these will fail due to selfish mining fix
101+
t.Skip()
102+
103+
params.HomesteadBlock = big.NewInt(1000000)
88104
err := RunBlockTest(filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
89105
if err != nil {
90106
t.Fatal(err)
91107
}
92108
}
93109

94110
func TestBcWallet(t *testing.T) {
111+
params.HomesteadBlock = big.NewInt(1000000)
95112
err := RunBlockTest(filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
96113
if err != nil {
97114
t.Fatal(err)
98115
}
99116
}
100117

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

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

116135
func TestBcMultiChain(t *testing.T) {
136+
// skip due to selfish mining
137+
t.Skip()
138+
139+
params.HomesteadBlock = big.NewInt(1000000)
117140
err := RunBlockTest(filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
118141
if err != nil {
119142
t.Fatal(err)
120143
}
121144
}
122145

123146
func TestBcState(t *testing.T) {
147+
params.HomesteadBlock = big.NewInt(1000000)
124148
err := RunBlockTest(filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
125149
if err != nil {
126150
t.Fatal(err)
127151
}
128152
}
153+
154+
// Homestead tests
155+
func TestHomesteadBcValidBlockTests(t *testing.T) {
156+
params.HomesteadBlock = big.NewInt(0)
157+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
158+
if err != nil {
159+
t.Fatal(err)
160+
}
161+
}
162+
163+
func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) {
164+
params.HomesteadBlock = big.NewInt(0)
165+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
166+
if err != nil {
167+
t.Fatal(err)
168+
}
169+
}
170+
171+
func TestHomesteadBcUncleTests(t *testing.T) {
172+
params.HomesteadBlock = big.NewInt(0)
173+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
174+
if err != nil {
175+
t.Fatal(err)
176+
}
177+
}
178+
179+
func TestHomesteadBcInvalidHeaderTests(t *testing.T) {
180+
params.HomesteadBlock = big.NewInt(0)
181+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
182+
if err != nil {
183+
t.Fatal(err)
184+
}
185+
}
186+
187+
func TestHomesteadBcRPCAPITests(t *testing.T) {
188+
params.HomesteadBlock = big.NewInt(0)
189+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
190+
if err != nil {
191+
t.Fatal(err)
192+
}
193+
}
194+
195+
func TestHomesteadBcForkStress(t *testing.T) {
196+
params.HomesteadBlock = big.NewInt(0)
197+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
198+
if err != nil {
199+
t.Fatal(err)
200+
}
201+
}
202+
203+
func TestHomesteadBcTotalDifficulty(t *testing.T) {
204+
params.HomesteadBlock = big.NewInt(0)
205+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
206+
if err != nil {
207+
t.Fatal(err)
208+
}
209+
}
210+
211+
func TestHomesteadBcWallet(t *testing.T) {
212+
params.HomesteadBlock = big.NewInt(0)
213+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
214+
if err != nil {
215+
t.Fatal(err)
216+
}
217+
}
218+
219+
func TestHomesteadBcGasPricer(t *testing.T) {
220+
params.HomesteadBlock = big.NewInt(0)
221+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
222+
if err != nil {
223+
t.Fatal(err)
224+
}
225+
}
226+
227+
func TestHomesteadBcMultiChain(t *testing.T) {
228+
params.HomesteadBlock = big.NewInt(0)
229+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
230+
if err != nil {
231+
t.Fatal(err)
232+
}
233+
}
234+
235+
func TestHomesteadBcState(t *testing.T) {
236+
params.HomesteadBlock = big.NewInt(0)
237+
err := RunBlockTest(filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
238+
if err != nil {
239+
t.Fatal(err)
240+
}
241+
}

tests/block_test_util.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ func runBlockTests(bt map[string]*BlockTest, skipTests []string) error {
146146
}
147147

148148
for name, test := range bt {
149-
if skipTest[name] || name != "wallet2outOf3txsRevoke" {
149+
if skipTest[name] {
150150
glog.Infoln("Skipping block test", name)
151151
continue
152152
}
153153
// test the block
154-
//fmt.Println("BlockTest name:", name)
155154
if err := runBlockTest(test); err != nil {
156155
return fmt.Errorf("%s: %v", name, err)
157156
}
@@ -293,12 +292,13 @@ func (t *BlockTest) TryBlocksInsert(blockchain *core.BlockChain) ([]btBlock, err
293292
}
294293
}
295294
// RLP decoding worked, try to insert into chain:
296-
_, err = blockchain.InsertChain(types.Blocks{cb})
295+
blocks := types.Blocks{cb}
296+
i, err := blockchain.InsertChain(blocks)
297297
if err != nil {
298298
if b.BlockHeader == nil {
299299
continue // OK - block is supposed to be invalid, continue with next block
300300
} else {
301-
return nil, fmt.Errorf("Block insertion into chain failed: %v", err)
301+
return nil, fmt.Errorf("Block #%v insertion into chain failed: %v", blocks[i].Number(), err)
302302
}
303303
}
304304
if b.BlockHeader == nil {

tests/files/ABITests/basic_abi_tests.json

100644100755
File mode changed.

tests/files/BasicTests/blockgenesistest.json

100644100755
File mode changed.

tests/files/BasicTests/crypto.json

100644100755
File mode changed.

tests/files/BasicTests/difficulty.json

100644100755
File mode changed.

0 commit comments

Comments
 (0)