Skip to content

Commit

Permalink
quic: fixup constant exports, export all protocol error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Jun 30, 2020
1 parent e6f6ff1 commit b1c13b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit b1c13b8

Please sign in to comment.