github.com/lmittmann/w3@v0.20.0/module/debug/call_trace_test.go (about)

     1  package debug_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmittmann/w3"
     7  	"github.com/lmittmann/w3/module/debug"
     8  	"github.com/lmittmann/w3/rpctest"
     9  	"github.com/lmittmann/w3/w3types"
    10  )
    11  
    12  func TestCallTraceTx(t *testing.T) {
    13  	rpctest.RunTestCases(t, []rpctest.TestCase[*debug.CallTrace]{
    14  		{
    15  			Golden: "traceCall_callTracer",
    16  			Call: debug.CallTraceCall(&w3types.Message{
    17  				From:  w3.A("0x000000000000000000000000000000000000c0Fe"),
    18  				To:    w3.APtr("0x000000000000000000000000000000000000dEaD"),
    19  				Value: w3.I("1 ether"),
    20  			}, nil, w3types.State{
    21  				w3.A("0x000000000000000000000000000000000000c0Fe"): {Balance: w3.I("1 ether")},
    22  			}),
    23  			WantRet: &debug.CallTrace{
    24  				From:  w3.A("0x000000000000000000000000000000000000c0Fe"),
    25  				To:    w3.A("0x000000000000000000000000000000000000dEaD"),
    26  				Type:  "CALL",
    27  				Gas:   49979000,
    28  				Value: w3.I("1 ether"),
    29  			},
    30  		},
    31  		{
    32  			Golden: "traceTx_revertReason",
    33  			Call:   debug.CallTraceTx(w3.H("0x6ea1798a2d0d21db18d6e45ca00f230160b05f172f6022aa138a0b605831d740"), w3types.State{}),
    34  			WantRet: &debug.CallTrace{
    35  				From:         w3.A("0x84abea9c66d30d00549429f5f687e16708aa20c0"),
    36  				To:           w3.A("0xd0a7333587053a5bae772bd37b9aae724e367619"),
    37  				Type:         "CALL",
    38  				Gas:          146604,
    39  				GasUsed:      81510,
    40  				Value:        w3.I("0x0"),
    41  				Error:        "execution reverted",
    42  				RevertReason: "BA: Insufficient gas (ETH) for refund",
    43  			},
    44  		},
    45  	})
    46  }