From fc850b11e5ef760278363b7a35c5a48102d919c3 Mon Sep 17 00:00:00 2001 From: Peter Evers Date: Mon, 15 Jun 2020 18:20:45 +0200 Subject: [PATCH] unixpacket should also return byte length on send (#6291) --- cli/ops/net.rs | 4 ++-- cli/tests/unit/net_test.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/ops/net.rs b/cli/ops/net.rs index 57dcecab79..76abcb6c30 100644 --- a/cli/ops/net.rs +++ b/cli/ops/net.rs @@ -244,11 +244,11 @@ fn op_datagram_send( })?; let socket = &mut resource.socket; - socket + let byte_length = socket .send_to(&zero_copy, &resource.local_addr.as_pathname().unwrap()) .await?; - Ok(json!({})) + Ok(json!(byte_length)) }; Ok(JsonOp::Async(op.boxed_local())) diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts index 9228315d8a..bd0e489b50 100644 --- a/cli/tests/unit/net_test.ts +++ b/cli/tests/unit/net_test.ts @@ -290,7 +290,8 @@ unitTest( assertEquals(bob.addr.path, filePath); const sent = new Uint8Array([1, 2, 3]); - await alice.send(sent, bob.addr); + const byteLength = await alice.send(sent, bob.addr); + assertEquals(byteLength, 3); const [recvd, remote] = await bob.receive(); assert(remote.transport === "unixpacket");