@@ -27,7 +27,6 @@ import (
27
27
"github.com/ethereum/go-ethereum/core/vm"
28
28
"github.com/ethereum/go-ethereum/ethdb"
29
29
"github.com/ethereum/go-ethereum/event"
30
- "github.com/ethereum/go-ethereum/params"
31
30
"github.com/ethereum/go-ethereum/pow/ezp"
32
31
)
33
32
@@ -93,107 +92,3 @@ func TestPutReceipt(t *testing.T) {
93
92
t .Error ("expected to get 1 receipt, got none." )
94
93
}
95
94
}
96
-
97
- // Tests that DAO-fork enabled clients can properly filter out fork-commencing
98
- // blocks based on their extradata fields.
99
- func TestDAOForkRangeExtradata (t * testing.T ) {
100
- forkBlock := big .NewInt (32 )
101
-
102
- // Generate a common prefix for both pro-forkers and non-forkers
103
- db , _ := ethdb .NewMemDatabase ()
104
- genesis := WriteGenesisBlockForTesting (db )
105
- prefix , _ := GenerateChain (genesis , db , int (forkBlock .Int64 ()- 1 ), func (i int , gen * BlockGen ) {})
106
-
107
- // Create the concurrent, conflicting two nodes
108
- proDb , _ := ethdb .NewMemDatabase ()
109
- WriteGenesisBlockForTesting (proDb )
110
- proBc , _ := NewBlockChain (proDb , & ChainConfig {HomesteadBlock : big .NewInt (0 ), DAOForkBlock : forkBlock , DAOForkSupport : true }, new (FakePow ), new (event.TypeMux ))
111
-
112
- conDb , _ := ethdb .NewMemDatabase ()
113
- WriteGenesisBlockForTesting (conDb )
114
- conBc , _ := NewBlockChain (conDb , & ChainConfig {HomesteadBlock : big .NewInt (0 ), DAOForkBlock : forkBlock , DAOForkSupport : false }, new (FakePow ), new (event.TypeMux ))
115
-
116
- if _ , err := proBc .InsertChain (prefix ); err != nil {
117
- t .Fatalf ("pro-fork: failed to import chain prefix: %v" , err )
118
- }
119
- if _ , err := conBc .InsertChain (prefix ); err != nil {
120
- t .Fatalf ("con-fork: failed to import chain prefix: %v" , err )
121
- }
122
- // Try to expand both pro-fork and non-fork chains iteratively with other camp's blocks
123
- for i := int64 (0 ); i < params .DAOForkExtraRange .Int64 (); i ++ {
124
- // Create a pro-fork block, and try to feed into the no-fork chain
125
- db , _ = ethdb .NewMemDatabase ()
126
- WriteGenesisBlockForTesting (db )
127
- bc , _ := NewBlockChain (db , & ChainConfig {HomesteadBlock : big .NewInt (0 )}, new (FakePow ), new (event.TypeMux ))
128
-
129
- blocks := conBc .GetBlocksFromHash (conBc .CurrentBlock ().Hash (), int (conBc .CurrentBlock ().NumberU64 ()+ 1 ))
130
- for j := 0 ; j < len (blocks )/ 2 ; j ++ {
131
- blocks [j ], blocks [len (blocks )- 1 - j ] = blocks [len (blocks )- 1 - j ], blocks [j ]
132
- }
133
- if _ , err := bc .InsertChain (blocks ); err != nil {
134
- t .Fatalf ("failed to import contra-fork chain for expansion: %v" , err )
135
- }
136
- blocks , _ = GenerateChain (conBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) { gen .SetExtra (params .DAOForkBlockExtra ) })
137
- if _ , err := conBc .InsertChain (blocks ); err == nil {
138
- t .Fatalf ("contra-fork chain accepted pro-fork block: %v" , blocks [0 ])
139
- }
140
- // Create a proper no-fork block for the contra-forker
141
- blocks , _ = GenerateChain (conBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) {})
142
- if _ , err := conBc .InsertChain (blocks ); err != nil {
143
- t .Fatalf ("contra-fork chain didn't accepted no-fork block: %v" , err )
144
- }
145
- // Create a no-fork block, and try to feed into the pro-fork chain
146
- db , _ = ethdb .NewMemDatabase ()
147
- WriteGenesisBlockForTesting (db )
148
- bc , _ = NewBlockChain (db , & ChainConfig {HomesteadBlock : big .NewInt (0 )}, new (FakePow ), new (event.TypeMux ))
149
-
150
- blocks = proBc .GetBlocksFromHash (proBc .CurrentBlock ().Hash (), int (proBc .CurrentBlock ().NumberU64 ()+ 1 ))
151
- for j := 0 ; j < len (blocks )/ 2 ; j ++ {
152
- blocks [j ], blocks [len (blocks )- 1 - j ] = blocks [len (blocks )- 1 - j ], blocks [j ]
153
- }
154
- if _ , err := bc .InsertChain (blocks ); err != nil {
155
- t .Fatalf ("failed to import pro-fork chain for expansion: %v" , err )
156
- }
157
- blocks , _ = GenerateChain (proBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) {})
158
- if _ , err := proBc .InsertChain (blocks ); err == nil {
159
- t .Fatalf ("pro-fork chain accepted contra-fork block: %v" , blocks [0 ])
160
- }
161
- // Create a proper pro-fork block for the pro-forker
162
- blocks , _ = GenerateChain (proBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) { gen .SetExtra (params .DAOForkBlockExtra ) })
163
- if _ , err := proBc .InsertChain (blocks ); err != nil {
164
- t .Fatalf ("pro-fork chain didn't accepted pro-fork block: %v" , err )
165
- }
166
- }
167
- // Verify that contra-forkers accept pro-fork extra-datas after forking finishes
168
- db , _ = ethdb .NewMemDatabase ()
169
- WriteGenesisBlockForTesting (db )
170
- bc , _ := NewBlockChain (db , & ChainConfig {HomesteadBlock : big .NewInt (0 )}, new (FakePow ), new (event.TypeMux ))
171
-
172
- blocks := conBc .GetBlocksFromHash (conBc .CurrentBlock ().Hash (), int (conBc .CurrentBlock ().NumberU64 ()+ 1 ))
173
- for j := 0 ; j < len (blocks )/ 2 ; j ++ {
174
- blocks [j ], blocks [len (blocks )- 1 - j ] = blocks [len (blocks )- 1 - j ], blocks [j ]
175
- }
176
- if _ , err := bc .InsertChain (blocks ); err != nil {
177
- t .Fatalf ("failed to import contra-fork chain for expansion: %v" , err )
178
- }
179
- blocks , _ = GenerateChain (conBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) { gen .SetExtra (params .DAOForkBlockExtra ) })
180
- if _ , err := conBc .InsertChain (blocks ); err != nil {
181
- t .Fatalf ("contra-fork chain didn't accept pro-fork block post-fork: %v" , err )
182
- }
183
- // Verify that pro-forkers accept contra-fork extra-datas after forking finishes
184
- db , _ = ethdb .NewMemDatabase ()
185
- WriteGenesisBlockForTesting (db )
186
- bc , _ = NewBlockChain (db , & ChainConfig {HomesteadBlock : big .NewInt (0 )}, new (FakePow ), new (event.TypeMux ))
187
-
188
- blocks = proBc .GetBlocksFromHash (proBc .CurrentBlock ().Hash (), int (proBc .CurrentBlock ().NumberU64 ()+ 1 ))
189
- for j := 0 ; j < len (blocks )/ 2 ; j ++ {
190
- blocks [j ], blocks [len (blocks )- 1 - j ] = blocks [len (blocks )- 1 - j ], blocks [j ]
191
- }
192
- if _ , err := bc .InsertChain (blocks ); err != nil {
193
- t .Fatalf ("failed to import pro-fork chain for expansion: %v" , err )
194
- }
195
- blocks , _ = GenerateChain (proBc .CurrentBlock (), db , 1 , func (i int , gen * BlockGen ) {})
196
- if _ , err := proBc .InsertChain (blocks ); err != nil {
197
- t .Fatalf ("pro-fork chain didn't accept contra-fork block post-fork: %v" , err )
198
- }
199
- }
0 commit comments