ceremonyclient/go-libp2p/core/canonicallog/canonicallog_test.go

28 lines
694 B
Go
Raw Permalink Normal View History

2023-08-21 03:50:38 +00:00
package canonicallog
import (
"fmt"
"net"
"testing"
"github.com/libp2p/go-libp2p/core/test"
logging "github.com/ipfs/go-log/v2"
"github.com/multiformats/go-multiaddr"
)
func TestLogs(t *testing.T) {
err := logging.SetLogLevel("canonical-log", "info")
if err != nil {
t.Fatal(err)
}
m, _ := multiaddr.StringCast("/ip4/1.2.3.4")
LogMisbehavingPeer(test.RandPeerIDFatal(t), m, "somecomponent", fmt.Errorf("something"), "hi")
2023-08-21 03:50:38 +00:00
netAddr := &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 80}
LogMisbehavingPeerNetAddr(test.RandPeerIDFatal(t), netAddr, "somecomponent", fmt.Errorf("something"), "hello \"world\"")
LogPeerStatus(1, test.RandPeerIDFatal(t), m, "extra", "info")
2023-08-21 03:50:38 +00:00
}