Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chains/txmgr/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ type TxAttempt[
IsPurgeAttempt bool
}

func (a *TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) String() string {
return fmt.Sprintf("TxAttempt(ID:%d,TxID:%d,Fee:%s,TxType:%d", a.ID, a.TxID, a.TxFee, a.TxType)
func (a TxAttempt[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) String() string {
return fmt.Sprintf("TxAttempt(ID:%d,TxID:%d,Fee:%s,TxType:%d,CreatedAt:%s)", a.ID, a.TxID, a.TxFee, a.TxType, a.CreatedAt.Format(time.RFC3339))
}

type Tx[
Expand Down
19 changes: 19 additions & 0 deletions chains/txmgr/types/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"math/big"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -48,3 +49,21 @@ func TestTxAttemptState(t *testing.T) {
}
})
}

func TestTxLogging(t *testing.T) {
tx := Tx[*big.Int, *big.Int, *big.Int, *big.Int, *big.Int, *big.Int]{
ID: 1,
TxAttempts: []TxAttempt[*big.Int, *big.Int, *big.Int, *big.Int, *big.Int, *big.Int]{
{
ID: 2,
},
},
}

attempt := &tx.TxAttempts[0]
// set recursive reference
attempt.Tx = tx
// ensure that in both cases we prevent fmt from stacking in a loop attempt->tx->attempt by defining String method on attempt.
println(fmt.Sprintf("%+v", *attempt))
println(fmt.Sprintf("%+v", attempt))
}
Loading