@@ -321,150 +321,6 @@ func TestTraceCall(t *testing.T) {
321
321
}
322
322
}
323
323
324
- << << << < HEAD
325
- func TestOverriddenTraceCall (t * testing.T ) {
326
- t .Parallel ()
327
-
328
- // Initialize test accounts
329
- accounts := newAccounts (3 )
330
- genesis := & core.Genesis {Alloc : core.GenesisAlloc {
331
- accounts [0 ].addr : {Balance : big .NewInt (params .Ether )},
332
- accounts [1 ].addr : {Balance : big .NewInt (params .Ether )},
333
- accounts [2 ].addr : {Balance : big .NewInt (params .Ether )},
334
- }}
335
- genBlocks := 10
336
- signer := types.HomesteadSigner {}
337
- api := NewAPI (newTestBackend (t , genBlocks , genesis , func (i int , b * core.BlockGen ) {
338
- // Transfer from account[0] to account[1]
339
- // value: 1000 wei
340
- // fee: 0 wei
341
- tx , _ := types .SignTx (types .NewTransaction (uint64 (i ), accounts [1 ].addr , big .NewInt (1000 ), params .TxGas , nil , nil , nil , nil , nil ), signer , accounts [0 ].key )
342
- b .AddTx (tx )
343
- }))
344
- randomAccounts , tracer := newAccounts (3 ), "callTracerJs"
345
-
346
- var testSuite = []struct {
347
- blockNumber rpc.BlockNumber
348
- call ethapi.TransactionArgs
349
- config * TraceCallConfig
350
- expectErr error
351
- expect * callTrace
352
- }{
353
- // Succcessful call with state overriding
354
- {
355
- blockNumber : rpc .PendingBlockNumber ,
356
- call : ethapi.TransactionArgs {
357
- From : & randomAccounts [0 ].addr ,
358
- To : & randomAccounts [1 ].addr ,
359
- Value : (* hexutil .Big )(big .NewInt (1000 )),
360
- },
361
- config : & TraceCallConfig {
362
- Tracer : & tracer ,
363
- StateOverrides : & ethapi.StateOverride {
364
- randomAccounts [0 ].addr : ethapi.OverrideAccount {Balance : newRPCBalance (new (big.Int ).Mul (big .NewInt (1 ), big .NewInt (params .Ether )))},
365
- },
366
- },
367
- expectErr : nil ,
368
- expect : & callTrace {
369
- Type : "CALL" ,
370
- From : randomAccounts [0 ].addr ,
371
- To : randomAccounts [1 ].addr ,
372
- Gas : newRPCUint64 (24979000 ),
373
- GasUsed : newRPCUint64 (0 ),
374
- Value : (* hexutil .Big )(big .NewInt (1000 )),
375
- },
376
- },
377
- // Invalid call without state overriding
378
- {
379
- blockNumber : rpc .PendingBlockNumber ,
380
- call : ethapi.TransactionArgs {
381
- From : & randomAccounts [0 ].addr ,
382
- To : & randomAccounts [1 ].addr ,
383
- Value : (* hexutil .Big )(big .NewInt (1000 )),
384
- },
385
- config : & TraceCallConfig {
386
- Tracer : & tracer ,
387
- },
388
- expectErr : core .ErrInsufficientFundsForTransfer ,
389
- expect : nil ,
390
- },
391
- // Successful simple contract call
392
- //
393
- // // SPDX-License-Identifier: GPL-3.0
394
- //
395
- // pragma solidity >=0.7.0 <0.8.0;
396
- //
397
- // /**
398
- // * @title Storage
399
- // * @dev Store & retrieve value in a variable
400
- // */
401
- // contract Storage {
402
- // uint256 public number;
403
- // constructor() {
404
- // number = block.number;
405
- // }
406
- // }
407
- {
408
- blockNumber : rpc .PendingBlockNumber ,
409
- call : ethapi.TransactionArgs {
410
- From : & randomAccounts [0 ].addr ,
411
- To : & randomAccounts [2 ].addr ,
412
- Data : newRPCBytes (common .Hex2Bytes ("8381f58a" )), // call number()
413
- },
414
- config : & TraceCallConfig {
415
- Tracer : & tracer ,
416
- StateOverrides : & ethapi.StateOverride {
417
- randomAccounts [2 ].addr : ethapi.OverrideAccount {
418
- Code : newRPCBytes (common .Hex2Bytes ("6080604052348015600f57600080fd5b506004361060285760003560e01c80638381f58a14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000548156fea2646970667358221220eab35ffa6ab2adfe380772a48b8ba78e82a1b820a18fcb6f59aa4efb20a5f60064736f6c63430007040033" )),
419
- StateDiff : newStates ([]common.Hash {{}}, []common.Hash {common .BigToHash (big .NewInt (123 ))}),
420
- },
421
- },
422
- },
423
- expectErr : nil ,
424
- expect : & callTrace {
425
- Type : "CALL" ,
426
- From : randomAccounts [0 ].addr ,
427
- To : randomAccounts [2 ].addr ,
428
- Input : hexutil .Bytes (common .Hex2Bytes ("8381f58a" )),
429
- Output : hexutil .Bytes (common .BigToHash (big .NewInt (123 )).Bytes ()),
430
- Gas : newRPCUint64 (24978936 ),
431
- GasUsed : newRPCUint64 (383 ), // TODO ethereum cost 2283, check if this is right
432
- Value : (* hexutil .Big )(big .NewInt (0 )),
433
- },
434
- },
435
- }
436
- for i , testspec := range testSuite {
437
- result , err := api .TraceCall (context .Background (), testspec .call , rpc.BlockNumberOrHash {BlockNumber : & testspec .blockNumber }, testspec .config )
438
- if testspec .expectErr != nil {
439
- if err == nil {
440
- t .Errorf ("test %d: want error %v, have nothing" , i , testspec .expectErr )
441
- continue
442
- }
443
- if ! errors .Is (err , testspec .expectErr ) {
444
- t .Errorf ("test %d: error mismatch, want %v, have %v" , i , testspec .expectErr , err )
445
- }
446
- } else {
447
- if err != nil {
448
- t .Errorf ("test %d: want no error, have %v" , i , err )
449
- continue
450
- }
451
- ret := new (callTrace )
452
- if err := json .Unmarshal (result .(json.RawMessage ), ret ); err != nil {
453
- t .Fatalf ("test %d: failed to unmarshal trace result: %v" , i , err )
454
- }
455
- if ! jsonEqual (ret , testspec .expect ) {
456
- // uncomment this for easier debugging
457
- //have, _ := json.MarshalIndent(ret, "", " ")
458
- //want, _ := json.MarshalIndent(testspec.expect, "", " ")
459
- //t.Fatalf("trace mismatch: \nhave %+v\nwant %+v", string(have), string(want))
460
- t .Fatalf ("trace mismatch: \n have %+v\n want %+v" , ret , testspec .expect )
461
- }
462
- }
463
- }
464
- }
465
-
466
- == == == =
467
- >> >> >> > 6 b9c77f06 (eth / tracers : package restructuring (#23857 ))
468
324
func TestTraceTransaction (t * testing.T ) {
469
325
t .Parallel ()
470
326
@@ -638,7 +494,20 @@ func TestTracingWithOverrides(t *testing.T) {
638
494
// Transfer from account[0] to account[1]
639
495
// value: 1000 wei
640
496
// fee: 0 wei
641
- tx , _ := types .SignTx (types .NewTransaction (uint64 (i ), accounts [1 ].addr , big .NewInt (1000 ), params .TxGas , b .BaseFee (), nil ), signer , accounts [0 ].key )
497
+ tx , _ := types .SignTx (
498
+ types .NewTransaction (
499
+ uint64 (i ),
500
+ accounts [1 ].addr ,
501
+ big .NewInt (1000 ),
502
+ params .TxGas ,
503
+ common .Big0 ,
504
+ nil ,
505
+ nil ,
506
+ nil ,
507
+ nil ),
508
+ signer ,
509
+ accounts [0 ].key ,
510
+ )
642
511
b .AddTx (tx )
643
512
}))
644
513
randomAccounts := newAccounts (3 )
@@ -678,7 +547,7 @@ func TestTracingWithOverrides(t *testing.T) {
678
547
Value : (* hexutil .Big )(big .NewInt (1000 )),
679
548
},
680
549
config : & TraceCallConfig {},
681
- expectErr : core .ErrInsufficientFunds ,
550
+ expectErr : core .ErrInsufficientFundsForTransfer ,
682
551
},
683
552
// Successful simple contract call
684
553
//
@@ -712,7 +581,7 @@ func TestTracingWithOverrides(t *testing.T) {
712
581
},
713
582
},
714
583
},
715
- want : `{"gas":23347 ,"failed":false,"returnValue":"000000000000000000000000000000000000000000000000000000000000007b"}` ,
584
+ want : `{"gas":21447 ,"failed":false,"returnValue":"000000000000000000000000000000000000000000000000000000000000007b"}` ,
716
585
},
717
586
}
718
587
for i , tc := range testSuite {
0 commit comments