4 "github.com/stretchr/testify/assert"
6 "go.uber.org/zap/zapcore"
11 func NewTestLogger() *zap.SugaredLogger {
12 encoderCfg := zap.NewProductionEncoderConfig()
13 encoderCfg.TimeKey = "timestamp"
14 encoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder
16 core := zapcore.NewCore(
17 zapcore.NewConsoleEncoder(encoderCfg),
18 zapcore.Lock(os.Stdout),
22 cores := []zapcore.Core{core}
23 l := zap.New(zapcore.NewTee(cores...))
24 defer func() { _ = l.Sync() }()
28 // tranAssertEqual compares equality of transactions slices after stripping out the random ID
29 func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool {
30 var newT1 []Transaction
31 var newT2 []Transaction
32 for _, trans := range tran1 {
33 trans.ID = []byte{0, 0, 0, 0}
34 newT1 = append(newT1, trans)
37 for _, trans := range tran2 {
38 trans.ID = []byte{0, 0, 0, 0}
39 newT2 = append(newT2, trans)
43 return assert.Equal(t, newT1, newT2)