p2p/enode: mock DNS resolver in URL parsing test (#20252)

This commit is contained in:
Felix Lange
2019-11-07 16:40:37 +01:00
committed by GitHub
parent 4b8f56cf98
commit adf007dadc
2 changed files with 21 additions and 6 deletions

View File

@ -18,6 +18,7 @@ package enode
import (
"crypto/ecdsa"
"errors"
"net"
"reflect"
"strings"
@ -27,6 +28,15 @@ import (
"github.com/ethereum/go-ethereum/p2p/enr"
)
func init() {
lookupIPFunc = func(name string) ([]net.IP, error) {
if name == "node.example.org" {
return []net.IP{{33, 44, 55, 66}}, nil
}
return nil, errors.New("no such host")
}
}
var parseNodeTests = []struct {
input string
wantError string