dcrd/rpctest/debug.go
Marco Peereboom c441b41d7d Add debug and trace facility to rpctest.
The rpctest suite is useful however it is impossible to debug in its
current state. This diff adds debug and tracing facilities to the test
that are worth keeping.

It adds two global flags debug and trace that can be enabled when
additional output is required. In addition it sends the test object
around so that segregated parts of the code use the same logging
facility. And lastly, it will always print dcrd panics to the console.
2020-05-11 12:28:03 -05:00

41 lines
828 B
Go

// Copyright (c) 2020 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package rpctest
import (
"testing"
)
// This package is very hard to debug so we add a couple of variables that
// enable debug and tracing output. Leave them false before committing to
// master.
var (
debug bool // Set to true to enable additional verbosity.
trace bool // Set to true to enable tracing.
)
func init() {
debug = false
trace = false
}
func logf(t *testing.T, format string, args ...interface{}) {
t.Logf(format, args...)
}
func tracef(t *testing.T, format string, args ...interface{}) {
if !trace {
return
}
t.Logf(format, args...)
}
func debugf(t *testing.T, format string, args ...interface{}) {
if !debug {
return
}
t.Logf(format, args...)
}