@@ -208,10 +208,22 @@ func (t *BlockTest) InsertPreState(ethereum *eth.Ethereum) (*state.StateDB, erro
208
208
db := ethereum .StateDb ()
209
209
statedb := state .New (common.Hash {}, db )
210
210
for addrString , acct := range t .preAccounts {
211
- addr , _ := hex .DecodeString (addrString )
212
- code , _ := hex .DecodeString (strings .TrimPrefix (acct .Code , "0x" ))
213
- balance , _ := new (big.Int ).SetString (acct .Balance , 0 )
214
- nonce , _ := strconv .ParseUint (acct .Nonce , 16 , 64 )
211
+ addr , err := hex .DecodeString (addrString )
212
+ if err != nil {
213
+ return nil , err
214
+ }
215
+ code , err := hex .DecodeString (strings .TrimPrefix (acct .Code , "0x" ))
216
+ if err != nil {
217
+ return nil , err
218
+ }
219
+ balance , ok := new (big.Int ).SetString (acct .Balance , 0 )
220
+ if ! ok {
221
+ return nil , err
222
+ }
223
+ nonce , err := strconv .ParseUint (prepInt (16 , acct .Nonce ), 16 , 64 )
224
+ if err != nil {
225
+ return nil , err
226
+ }
215
227
216
228
if acct .PrivateKey != "" {
217
229
privkey , err := hex .DecodeString (strings .TrimPrefix (acct .PrivateKey , "0x" ))
@@ -365,10 +377,22 @@ func (s *BlockTest) validateBlockHeader(h *btHeader, h2 *types.Header) error {
365
377
func (t * BlockTest ) ValidatePostState (statedb * state.StateDB ) error {
366
378
for addrString , acct := range t .preAccounts {
367
379
// XXX: is is worth it checking for errors here?
368
- addr , _ := hex .DecodeString (addrString )
369
- code , _ := hex .DecodeString (strings .TrimPrefix (acct .Code , "0x" ))
370
- balance , _ := new (big.Int ).SetString (acct .Balance , 0 )
371
- nonce , _ := strconv .ParseUint (acct .Nonce , 16 , 64 )
380
+ addr , err := hex .DecodeString (addrString )
381
+ if err != nil {
382
+ return err
383
+ }
384
+ code , err := hex .DecodeString (strings .TrimPrefix (acct .Code , "0x" ))
385
+ if err != nil {
386
+ return err
387
+ }
388
+ balance , ok := new (big.Int ).SetString (acct .Balance , 0 )
389
+ if ! ok {
390
+ return err
391
+ }
392
+ nonce , err := strconv .ParseUint (prepInt (16 , acct .Nonce ), 16 , 64 )
393
+ if err != nil {
394
+ return err
395
+ }
372
396
373
397
// address is indirectly verified by the other fields, as it's the db key
374
398
code2 := statedb .GetCode (common .BytesToAddress (addr ))
0 commit comments