Skip to content

Commit

Permalink
Merge branch 'master' into nat_extAddr_race
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo authored Jan 17, 2025
2 parents bdfee17 + 9fe14c2 commit d644751
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion p2p/net/swarm/swarm_dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,23 @@ func TestBlackHoledAddrBlocked(t *testing.T) {
require.ErrorIs(t, err, ErrDialRefusedBlackHole)
}

type mockDNSResolver struct {
ipsToReturn []net.IPAddr
txtsToReturn []string
}

var _ madns.BasicResolver = (*mockDNSResolver)(nil)

func (m *mockDNSResolver) LookupIPAddr(_ context.Context, _ string) ([]net.IPAddr, error) {
return m.ipsToReturn, nil
}

func (m *mockDNSResolver) LookupTXT(_ context.Context, _ string) ([]string, error) {
return m.txtsToReturn, nil
}

func TestSkipDialingManyDNS(t *testing.T) {
resolver, err := madns.NewResolver()
resolver, err := madns.NewResolver(madns.WithDefaultResolver(&mockDNSResolver{ipsToReturn: []net.IPAddr{{IP: net.ParseIP("1.2.3.4")}, {IP: net.ParseIP("1.2.3.5")}}}))
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit d644751

Please sign in to comment.