Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
quic: fix linting and tests
Browse files Browse the repository at this point in the history
Once again, linter and tests have been failing because of recent
changes. :)

PR-URL: #179
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
addaleax committed Dec 11, 2019
1 parent b42e28f commit 065c327
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 38 deletions.
10 changes: 5 additions & 5 deletions lib/internal/quic/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,11 @@ class QuicSocket extends EventEmitter {
session.on('ready', callback);

this[kMaybeBind](connectAfterBind.bind(
this,
session,
this.#lookup,
address,
getSocketType(type)));
this,
session,
this.#lookup,
address,
getSocketType(type)));

return session;
}
Expand Down
6 changes: 5 additions & 1 deletion src/node_http_common-inl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef SRC_NODE_HTTP_COMMON_INL_H_
#define SRC_NODE_HTTP_COMMON_INL_H_

#include "node_http_common.h"
#include "node.h"
#include "env-inl.h"
#include "v8.h"

namespace node {

Expand Down Expand Up @@ -67,3 +69,5 @@ NgHeaders<T>::NgHeaders(Environment* env, Local<Array> headers) {
}

} // namespace node

#endif // SRC_NODE_HTTP_COMMON_INL_H_
17 changes: 8 additions & 9 deletions src/node_http_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ class NgRcBufPointer : public MemoryRetainer {
static v8::MaybeLocal<v8::String> New(
Environment* env,
NgRcBufPointer<T> ptr) {

// TODO(@jasnell): Reconcile with http2 logic so we don't duplicate
// if (ptr->IsStatic()) {
// auto& static_str_map = env->isolate_data()->http2_static_strs;
Expand All @@ -394,14 +393,14 @@ class NgRcBufPointer : public MemoryRetainer {
return ret;
}

External* h_str = new External(std::move(ptr));
v8::MaybeLocal<v8::String> str =
v8::String::NewExternalOneByte(env->isolate(), h_str);
if (str.IsEmpty())
delete h_str;
External* h_str = new External(std::move(ptr));
v8::MaybeLocal<v8::String> str =
v8::String::NewExternalOneByte(env->isolate(), h_str);
if (str.IsEmpty())
delete h_str;

return str;
}
return str;
}

private:
NgRcBufPointer<T> ptr_;
Expand All @@ -416,4 +415,4 @@ class NgRcBufPointer : public MemoryRetainer {

#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#endif // SRC_NODE_HTTP2_H_
#endif // SRC_NODE_HTTP_COMMON_H_
17 changes: 6 additions & 11 deletions src/node_quic_default_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include <ngtcp2/ngtcp2.h>

namespace node {

using v8::Context;
using v8::HandleScope;
using v8::Number;

namespace quic {

DefaultApplication::DefaultApplication(
Expand Down Expand Up @@ -61,12 +56,12 @@ void DefaultApplication::AcknowledgeStreamData(
int64_t stream_id,
uint64_t offset,
size_t datalen) {
QuicStream* stream = Session()->FindStream(stream_id);
Debug(Session(), "Default QUIC Application acknowledging stream data");
// It's possible that the stream has already been destroyed and
// removed. If so, just silently ignore the ack
if (stream)
stream->AckedDataOffset(offset, datalen);
QuicStream* stream = Session()->FindStream(stream_id);
Debug(Session(), "Default QUIC Application acknowledging stream data");
// It's possible that the stream has already been destroyed and
// removed. If so, just silently ignore the ack
if (stream)
stream->AckedDataOffset(offset, datalen);
}

bool DefaultApplication::SendPendingData() {
Expand Down
10 changes: 5 additions & 5 deletions src/node_quic_http3_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,9 @@ const nghttp3_conn_callbacks Http3Application::callbacks_[2] = {
OnBeginHeaders,
OnReceiveHeader,
OnEndHeaders,
OnBeginTrailers, // Begin Trailers
OnReceiveHeader, // Receive Trailer
OnEndHeaders, // End Trailers
OnBeginTrailers, // Begin Trailers
OnReceiveHeader, // Receive Trailer
OnEndHeaders, // End Trailers
OnBeginPushPromise,
OnReceivePushPromise,
OnEndPushPromise,
Expand All @@ -578,8 +578,8 @@ const nghttp3_conn_callbacks Http3Application::callbacks_[2] = {
OnReceiveHeader,
OnEndHeaders,
OnBeginTrailers, // Begin Trailers
OnReceiveHeader, // Receive Trailer
OnEndHeaders, // End Trailers
OnReceiveHeader, // Receive Trailer
OnEndHeaders, // End Trailers
OnBeginPushPromise,
OnReceivePushPromise,
OnEndPushPromise,
Expand Down
4 changes: 2 additions & 2 deletions src/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2120,8 +2120,8 @@ void QuicSession::StreamReset(
app_error_code,
final_size);

if (HasStream(stream_id))
application_->StreamReset(stream_id, final_size, app_error_code);
if (HasStream(stream_id))
application_->StreamReset(stream_id, final_size, app_error_code);
}

void QuicSession::UpdateIdleTimer() {
Expand Down
11 changes: 10 additions & 1 deletion test/parallel/test-http2-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ const expectedHeaderNames = {
HTTP2_HEADER_CONTENT_MD5: 'content-md5',
HTTP2_HEADER_TE: 'te',
HTTP2_HEADER_UPGRADE: 'upgrade',
HTTP2_HEADER_HTTP2_SETTINGS: 'http2-settings'
HTTP2_HEADER_HTTP2_SETTINGS: 'http2-settings',
HTTP2_HEADER_X_XSS_PROTECTION: 'x-xss-protection',
HTTP2_HEADER_ALT_SVC: 'alt-svc',
HTTP2_HEADER_CONTENT_SECURITY_POLICY: 'content-security-policy',
HTTP2_HEADER_EARLY_DATA: 'early-data',
HTTP2_HEADER_EXPECT_CT: 'expect-ct',
HTTP2_HEADER_ORIGIN: 'origin',
HTTP2_HEADER_PURPOSE: 'purpose',
HTTP2_HEADER_TIMING_ALLOW_ORIGIN: 'timing-allow-origin',
HTTP2_HEADER_X_FORWARDED_FOR: 'x-forwarded-for',
};

const expectedNGConstants = {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-quic-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ assert(quic);

// Version numbers used to identify IETF drafts are created by adding the draft
// number to 0xff0000, in this case 13 (19).
assert.strictEqual(quic.constants.NGTCP2_PROTO_VER.toString(16), 'ff000016');
assert.strictEqual(quic.constants.NGTCP2_ALPN_H3, '\u0005h3-22');
assert.strictEqual(quic.constants.NGTCP2_PROTO_VER.toString(16), 'ff000017');
assert.strictEqual(quic.constants.NGTCP2_ALPN_H3, '\u0005h3-23');
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const { once } = require('events');
}
});

let done = 0;
for (const server of servers) {
const req = client.connect({
address: 'localhost',
Expand All @@ -61,7 +60,7 @@ const { once } = require('events');

const [ stream ] = await once(req, 'stream');
stream.resume();
await(stream, 'end');
await once(stream, 'end');

server.close();
req.close();
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-quic-with-fake-udp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
if (!common.hasQuic)
common.skip('missing quic');

const { makeUDPPair } = require('../common/udppair');
const assert = require('assert');
const quic = require('quic');
Expand Down
2 changes: 2 additions & 0 deletions test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ const { getSystemErrorName } = require('util');
// TODO(danbev): Test for these
delete providers.QUICCLIENTSESSION;
delete providers.QUICSERVERSESSION;
delete providers.QUICSENDWRAP;
delete providers.QUICSOCKET;
delete providers.QUICSTREAM;
delete providers.JSUDPWRAP;
if (!common.isMainThread)
delete providers.INSPECTORJSBINDING;
delete providers.KEYPAIRGENREQUEST;
Expand Down

0 comments on commit 065c327

Please sign in to comment.