Skip to content

Commit e1e326e

Browse files
authored
core/tracing: stringer for gas and nonce change reasons (#31234)
1 parent 6c286be commit e1e326e

5 files changed

+91
-6
lines changed

core/state/statedb_hooked_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func TestHooks(t *testing.T) {
8383
inner.SetTxContext(common.Hash{0x11}, 100) // For the log
8484
var result []string
8585
var wants = []string{
86-
"0xaa00000000000000000000000000000000000000.balance: 0->100 (BalanceChangeUnspecified)",
87-
"0xaa00000000000000000000000000000000000000.balance: 100->50 (BalanceChangeTransfer)",
86+
"0xaa00000000000000000000000000000000000000.balance: 0->100 (Unspecified)",
87+
"0xaa00000000000000000000000000000000000000.balance: 100->50 (Transfer)",
8888
"0xaa00000000000000000000000000000000000000.nonce: 0->1337",
8989
"0xaa00000000000000000000000000000000000000.code: (0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470) ->0x1325 (0xa12ae05590de0c93a00bc7ac773c2fdb621e44f814985e72194f921c0050f728)",
9090
"0xaa00000000000000000000000000000000000000.storage slot 0x0000000000000000000000000000000000000000000000000000000000000001: 0x0000000000000000000000000000000000000000000000000000000000000000 ->0x0000000000000000000000000000000000000000000000000000000000000011",

core/tracing/gen_balance_change_reason_stringer.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tracing/gen_gas_change_reason_stringer.go

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tracing/gen_nonce_change_reason_stringer.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tracing/hooks.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ type Hooks struct {
221221
// for tracing and reporting.
222222
type BalanceChangeReason byte
223223

224-
//go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go
224+
//go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -trimprefix=BalanceChange -output gen_balance_change_reason_stringer.go
225225

226226
const (
227227
BalanceChangeUnspecified BalanceChangeReason = 0
@@ -282,6 +282,8 @@ const (
282282
// once per transaction, while those that start with `GasChangeCall` are emitted on a call basis.
283283
type GasChangeReason byte
284284

285+
//go:generate go run golang.org/x/tools/cmd/stringer -type=GasChangeReason -trimprefix=GasChange -output gen_gas_change_reason_stringer.go
286+
285287
const (
286288
GasChangeUnspecified GasChangeReason = 0
287289

@@ -346,6 +348,8 @@ const (
346348
// NonceChangeReason is used to indicate the reason for a nonce change.
347349
type NonceChangeReason byte
348350

351+
//go:generate go run golang.org/x/tools/cmd/stringer -type=NonceChangeReason -trimprefix NonceChange -output gen_nonce_change_reason_stringer.go
352+
349353
const (
350354
NonceChangeUnspecified NonceChangeReason = 0
351355

0 commit comments

Comments
 (0)