| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5b5a03 commit 64d0c74
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -237,9 +237,9 @@ void UDPWrap::BufferSize(const FunctionCallbackInfo<Value>& args) { | |||
| 237 | 237 | ||
| 238 | 238 | if (!args[0]->IsInt32()) { | |
| 239 | 239 | if (args[1].As<Uint32>()->Value() == 0) | |
| 240 | - return env->ThrowUVException(EINVAL, "uv_recv_buffer_size"); | ||
| 240 | + return env->ThrowUVException(UV_EINVAL, "uv_recv_buffer_size"); | ||
| 241 | 241 | else | |
| 242 | - return env->ThrowUVException(EINVAL, "uv_send_buffer_size"); | ||
| 242 | + return env->ThrowUVException(UV_EINVAL, "uv_send_buffer_size"); | ||
| 243 | 243 | } | |
| 244 | 244 | ||
| 245 | 245 | int err; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,3 +72,24 @@ const dgram = require('dgram'); | |||
| 72 | 72 | socket.close(); | |
| 73 | 73 | })); | |
| 74 | 74 | } | |
| 75 | + | ||
| 76 | + function checkBufferSizeError(type, size) { | ||
| 77 | + const errorObj = { | ||
| 78 | + code: 'ERR_SOCKET_BUFFER_SIZE', | ||
| 79 | + type: Error, | ||
| 80 | + message: 'Could not get or set buffer size: Error: EINVAL: ' + | ||
| 81 | + `invalid argument, uv_${type}_buffer_size` | ||
| 82 | + }; | ||
| 83 | + const functionName = `set${type.charAt(0).toUpperCase()}${type.slice(1)}` + | ||
| 84 | + 'BufferSize'; | ||
| 85 | + const socket = dgram.createSocket('udp4'); | ||
| 86 | + socket.bind(common.mustCall(() => { | ||
| 87 | + assert.throws(() => { | ||
| 88 | + socket[functionName](size); | ||
| 89 | + }, common.expectsError(errorObj)); | ||
| 90 | + socket.close(); | ||
| 91 | + })); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + checkBufferSizeError('recv', 2147483648); | ||
| 95 | + checkBufferSizeError('send', 2147483648); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments