Skip to content

Commit 864671b

Browse files
committed
Add regression test
1 parent 5d618c5 commit 864671b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

eth/tracers/api_test.go

+49
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,55 @@ func TestTraceTransaction(t *testing.T) {
495495
}
496496
}
497497

498+
// Regression test for debug get/set logic in the EVM & Interpreter.
499+
// Include registry to ensure that Celo-specific EVM Call's within
500+
// Tobin Tax and fee distribution logic are triggered.
501+
func TestTraceTransactionWithRegistryDeployed(t *testing.T) {
502+
t.Parallel()
503+
504+
// Initialize test accounts
505+
accounts := newAccounts(2)
506+
genesis := &core.Genesis{Alloc: core.GenesisAlloc{
507+
accounts[0].addr: {Balance: big.NewInt(params.Ether)},
508+
accounts[1].addr: {Balance: big.NewInt(params.Ether)},
509+
common.HexToAddress("0xce10"): { // Registry Proxy
510+
Code: testutil.RegistryProxyOpcodes,
511+
Storage: map[common.Hash]common.Hash{
512+
common.HexToHash("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"): common.HexToHash("0xce11"), // Registry Implementation
513+
common.HexToHash("0x91646b8507bf2e54d7c3de9155442ba111546b81af1cbdd1f68eeb6926b98d58"): common.HexToHash("0xd023"), // Governance Proxy
514+
},
515+
Balance: big.NewInt(0),
516+
},
517+
common.HexToAddress("0xce11"): { // Registry Implementation
518+
Code: testutil.RegistryOpcodes,
519+
Balance: big.NewInt(0),
520+
},
521+
}}
522+
523+
target := common.Hash{}
524+
signer := types.HomesteadSigner{}
525+
api := NewAPI(newTestBackend(t, 1, genesis, func(i int, b *core.BlockGen) {
526+
// Transfer from account[0] to account[1]
527+
// value: 1000 wei
528+
// fee: 0 wei
529+
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, nil, nil, nil, nil, nil), signer, accounts[0].key)
530+
b.AddTx(tx)
531+
target = tx.Hash()
532+
}))
533+
result, err := api.TraceTransaction(context.Background(), target, nil)
534+
if err != nil {
535+
t.Errorf("Failed to trace transaction %v", err)
536+
}
537+
if !reflect.DeepEqual(result, &ethapi.ExecutionResult{
538+
Gas: params.TxGas,
539+
Failed: false,
540+
ReturnValue: "",
541+
StructLogs: []ethapi.StructLogRes{},
542+
}) {
543+
t.Error("Transaction tracing result is different")
544+
}
545+
}
546+
498547
func TestTraceBlock(t *testing.T) {
499548
t.Parallel()
500549

0 commit comments

Comments
 (0)