From 2afc1abd05cc8f4a21ffb2c892949b7e30de2d00 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 30 Jun 2020 10:41:30 -0700 Subject: [PATCH] quic: fixup constant exports, export all protocol error codes PR-URL: https://github.com/nodejs/node/pull/34137 Reviewed-By: Anna Henningsen Reviewed-By: David Carlier --- src/quic/node_quic.cc | 19 ++++++++++++++++++- test/parallel/test-quic-binding.js | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/quic/node_quic.cc b/src/quic/node_quic.cc index a879e31d8706c3..ed147eb92b649f 100644 --- a/src/quic/node_quic.cc +++ b/src/quic/node_quic.cc @@ -189,7 +189,6 @@ void Initialize(Local 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) \ @@ -232,11 +231,29 @@ void Initialize(Local 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, diff --git a/test/parallel/test-quic-binding.js b/test/parallel/test-quic-binding.js index 6f28944664ffc9..2044ed43b48e53 100644 --- a/test/parallel/test-quic-binding.js +++ b/test/parallel/test-quic-binding.js @@ -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.