go-libp2p-core/canonicallog/canonicallog_test.go
Marco Munizaga 31262b0447
Add canonical log for misbehaving peers (#258)
* Add canonical logging for misbehaving peers

* Add component and use manet.FromNetAddr

* Fix log test
2022-06-17 09:09:23 -07:00

20 lines
563 B
Go

package canonicallog
import (
"fmt"
"testing"
"github.com/libp2p/go-libp2p-core/test"
"github.com/multiformats/go-multiaddr"
)
func TestLogs(t *testing.T) {
LogMisbehavingPeer(test.RandPeerIDFatal(t), multiaddr.StringCast("/ip4/1.2.3.4"), "somecomponent", fmt.Errorf("something"), "hi")
LogMisbehavingPeerNetAddr(test.RandPeerIDFatal(t), dummyNetAddr{}, "somecomponent", fmt.Errorf("something"), "hi")
}
type dummyNetAddr struct{}
func (d dummyNetAddr) Network() string { return "tcp" }
func (d dummyNetAddr) String() string { return "127.0.0.1:80" }