net: fix TcpConn.peer_ip/0 to only return the ip address, without the port number (#21831)

This commit is contained in:
Swastik Baranwal 2024-07-10 08:42:37 +05:30 committed by GitHub
parent ca07347430
commit 547c056bf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View file

@ -64,6 +64,10 @@ fn test_socket() {
fn test_socket_write_and_read() {
mut server, mut client, mut socket := setup()
addr := socket.peer_addr()!
ip := socket.peer_ip()!
assert ip in ['::1', 'localhost', '127.0.0.1']
println('> ip: ${ip} | addr: ${addr}')
defer {
cleanup(mut server, mut client, mut socket)
}