From 748dbcd9f29dbe4110da8a06f08e3eefa95f5321 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 13 Apr 2021 14:37:16 +0200 Subject: net: add new method Sock::GetSockName() that wraps getsockname() This will help to increase `Sock` usage and make more code mockable. --- src/util/sock.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/util/sock.h') diff --git a/src/util/sock.h b/src/util/sock.h index 3245820995..96d0b3b56b 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -126,6 +126,13 @@ public: const void* opt_val, socklen_t opt_len) const; + /** + * getsockname(2) wrapper. Equivalent to + * `getsockname(this->Get(), name, name_len)`. Code that uses this + * wrapper can be unit tested if this method is overridden by a mock Sock implementation. + */ + [[nodiscard]] virtual int GetSockName(sockaddr* name, socklen_t* name_len) const; + using Event = uint8_t; /** -- cgit v1.2.3