Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
quic: fixup constant exports, export all protocol error codes
  • Loading branch information
jasnell committed Jun 30, 2020
commit b1c13b8100180b502caf705581727e2dc7dacebb
19 changes: 18 additions & 1 deletion src/quic/node_quic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ void Initialize(Local<Object> target,
V(NGTCP2_APP_NOERROR) \
V(NGTCP2_PATH_VALIDATION_RESULT_FAILURE) \
V(NGTCP2_PATH_VALIDATION_RESULT_SUCCESS) \
V(NGTCP2_DEFAULT_MAX_PKTLEN) \
V(NGTCP2_CC_ALGO_CUBIC) \
V(NGTCP2_CC_ALGO_RENO) \
V(QUIC_ERROR_APPLICATION) \
Expand Down Expand Up @@ -232,11 +231,29 @@ void Initialize(Local<Object> target,
QUIC_CONSTANTS(V)
#undef V

NODE_DEFINE_CONSTANT(constants, NGTCP2_DEFAULT_MAX_PKTLEN);
NODE_DEFINE_CONSTANT(constants, NGTCP2_PROTO_VER);
NODE_DEFINE_CONSTANT(constants, NGTCP2_DEFAULT_MAX_ACK_DELAY);
NODE_DEFINE_CONSTANT(constants, NGTCP2_MAX_CIDLEN);
NODE_DEFINE_CONSTANT(constants, NGTCP2_MIN_CIDLEN);

NODE_DEFINE_CONSTANT(constants, NGTCP2_NO_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_INTERNAL_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_CONNECTION_REFUSED);
NODE_DEFINE_CONSTANT(constants, NGTCP2_FLOW_CONTROL_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_STREAM_LIMIT_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_STREAM_STATE_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_FINAL_SIZE_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_FRAME_ENCODING_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_TRANSPORT_PARAMETER_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_CONNECTION_ID_LIMIT_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_PROTOCOL_VIOLATION);
NODE_DEFINE_CONSTANT(constants, NGTCP2_INVALID_TOKEN);
NODE_DEFINE_CONSTANT(constants, NGTCP2_APPLICATION_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_CRYPTO_BUFFER_EXCEEDED);
NODE_DEFINE_CONSTANT(constants, NGTCP2_KEY_UPDATE_ERROR);
NODE_DEFINE_CONSTANT(constants, NGTCP2_CRYPTO_ERROR);

NODE_DEFINE_CONSTANT(constants, AF_INET);
NODE_DEFINE_CONSTANT(constants, AF_INET6);
NODE_DEFINE_STRING_CONSTANT(constants,
Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-quic-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ assert(quic.constants);
assert.strictEqual(quic.constants.NGTCP2_PROTO_VER.toString(16), 'ff00001d');
assert.strictEqual(quic.constants.NGHTTP3_ALPN_H3, '\u0005h3-29');

assert.strictEqual(quic.constants.NGTCP2_NO_ERROR, 0);
assert.strictEqual(quic.constants.NGTCP2_INTERNAL_ERROR, 1);
assert.strictEqual(quic.constants.NGTCP2_CONNECTION_REFUSED, 2);
assert.strictEqual(quic.constants.NGTCP2_FLOW_CONTROL_ERROR, 3);
assert.strictEqual(quic.constants.NGTCP2_STREAM_LIMIT_ERROR, 4);
assert.strictEqual(quic.constants.NGTCP2_STREAM_STATE_ERROR, 5);
assert.strictEqual(quic.constants.NGTCP2_FINAL_SIZE_ERROR, 6);
assert.strictEqual(quic.constants.NGTCP2_FRAME_ENCODING_ERROR, 7);
assert.strictEqual(quic.constants.NGTCP2_TRANSPORT_PARAMETER_ERROR, 8);
assert.strictEqual(quic.constants.NGTCP2_CONNECTION_ID_LIMIT_ERROR, 9);
assert.strictEqual(quic.constants.NGTCP2_PROTOCOL_VIOLATION, 0xa);
assert.strictEqual(quic.constants.NGTCP2_INVALID_TOKEN, 0xb);
assert.strictEqual(quic.constants.NGTCP2_APPLICATION_ERROR, 0xc);
assert.strictEqual(quic.constants.NGTCP2_CRYPTO_BUFFER_EXCEEDED, 0xd);
assert.strictEqual(quic.constants.NGTCP2_KEY_UPDATE_ERROR, 0xe);
assert.strictEqual(quic.constants.NGTCP2_CRYPTO_ERROR, 0x100);

// The following just tests for the presence of things we absolutely need.
// They don't test the functionality of those things.

Expand Down