Skip to content

Commit 3a9c447

Browse files
committed
fix remaingin tests
1 parent 30c5647 commit 3a9c447

File tree

1 file changed

+16
-147
lines changed

1 file changed

+16
-147
lines changed

eth/tracers/api_test.go

+16-147
Original file line numberDiff line numberDiff line change
@@ -321,150 +321,6 @@ func TestTraceCall(t *testing.T) {
321321
}
322322
}
323323

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: \nhave %+v\nwant %+v", ret, testspec.expect)
461-
}
462-
}
463-
}
464-
}
465-
466-
=======
467-
>>>>>>> 6b9c77f06 (eth/tracers: package restructuring (#23857))
468324
func TestTraceTransaction(t *testing.T) {
469325
t.Parallel()
470326

@@ -589,7 +445,20 @@ func TestTracingWithOverrides(t *testing.T) {
589445
// Transfer from account[0] to account[1]
590446
// value: 1000 wei
591447
// fee: 0 wei
592-
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
448+
tx, _ := types.SignTx(
449+
types.NewTransaction(
450+
uint64(i),
451+
accounts[1].addr,
452+
big.NewInt(1000),
453+
params.TxGas,
454+
common.Big0,
455+
nil,
456+
nil,
457+
nil,
458+
nil),
459+
signer,
460+
accounts[0].key,
461+
)
593462
b.AddTx(tx)
594463
}))
595464
randomAccounts := newAccounts(3)
@@ -629,7 +498,7 @@ func TestTracingWithOverrides(t *testing.T) {
629498
Value: (*hexutil.Big)(big.NewInt(1000)),
630499
},
631500
config: &TraceCallConfig{},
632-
expectErr: core.ErrInsufficientFunds,
501+
expectErr: core.ErrInsufficientFundsForTransfer,
633502
},
634503
// Successful simple contract call
635504
//
@@ -663,7 +532,7 @@ func TestTracingWithOverrides(t *testing.T) {
663532
},
664533
},
665534
},
666-
want: `{"gas":23347,"failed":false,"returnValue":"000000000000000000000000000000000000000000000000000000000000007b"}`,
535+
want: `{"gas":21447,"failed":false,"returnValue":"000000000000000000000000000000000000000000000000000000000000007b"}`,
667536
},
668537
}
669538
for i, tc := range testSuite {

0 commit comments

Comments
 (0)