11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst common = require('../common'); 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci// Test coverage for the updateOptionsBuffer method used internally 91cb0ef41Sopenharmony_ci// by the http2 implementation. 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst { updateOptionsBuffer } = require('internal/http2/util'); 121cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding'); 131cb0ef41Sopenharmony_ciconst { optionsBuffer } = internalBinding('http2'); 141cb0ef41Sopenharmony_ciconst { ok, strictEqual } = require('assert'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 0; 171cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS = 1; 181cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH = 2; 191cb0ef41Sopenharmony_ciconst IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS = 3; 201cb0ef41Sopenharmony_ciconst IDX_OPTIONS_PADDING_STRATEGY = 4; 211cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_HEADER_LIST_PAIRS = 5; 221cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6; 231cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7; 241cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_SESSION_MEMORY = 8; 251cb0ef41Sopenharmony_ciconst IDX_OPTIONS_MAX_SETTINGS = 9; 261cb0ef41Sopenharmony_ciconst IDX_OPTIONS_FLAGS = 10; 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci{ 291cb0ef41Sopenharmony_ci updateOptionsBuffer({ 301cb0ef41Sopenharmony_ci maxDeflateDynamicTableSize: 1, 311cb0ef41Sopenharmony_ci maxReservedRemoteStreams: 2, 321cb0ef41Sopenharmony_ci maxSendHeaderBlockLength: 3, 331cb0ef41Sopenharmony_ci peerMaxConcurrentStreams: 4, 341cb0ef41Sopenharmony_ci paddingStrategy: 5, 351cb0ef41Sopenharmony_ci maxHeaderListPairs: 6, 361cb0ef41Sopenharmony_ci maxOutstandingPings: 7, 371cb0ef41Sopenharmony_ci maxOutstandingSettings: 8, 381cb0ef41Sopenharmony_ci maxSessionMemory: 9, 391cb0ef41Sopenharmony_ci maxSettings: 10, 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); 431cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS], 2); 441cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH], 3); 451cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS], 4); 461cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_PADDING_STRATEGY], 5); 471cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_HEADER_LIST_PAIRS], 6); 481cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS], 7); 491cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS], 8); 501cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY], 9); 511cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10); 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)); 561cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)); 571cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)); 581cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)); 591cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)); 601cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_HEADER_LIST_PAIRS)); 611cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS)); 621cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS)); 631cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS)); 641cb0ef41Sopenharmony_ci} 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci{ 671cb0ef41Sopenharmony_ci optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH] = 0; 681cb0ef41Sopenharmony_ci optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS] = 0; 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci updateOptionsBuffer({ 711cb0ef41Sopenharmony_ci maxDeflateDynamicTableSize: 1, 721cb0ef41Sopenharmony_ci maxReservedRemoteStreams: 2, 731cb0ef41Sopenharmony_ci peerMaxConcurrentStreams: 4, 741cb0ef41Sopenharmony_ci paddingStrategy: 5, 751cb0ef41Sopenharmony_ci maxHeaderListPairs: 6 761cb0ef41Sopenharmony_ci }); 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); 791cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS], 2); 801cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS], 4); 811cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_PADDING_STRATEGY], 5); 821cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_HEADER_LIST_PAIRS], 6); 831cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH], 0); 841cb0ef41Sopenharmony_ci strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_PINGS], 0); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)); 891cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)); 901cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)); 911cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)); 921cb0ef41Sopenharmony_ci ok(flags & (1 << IDX_OPTIONS_MAX_HEADER_LIST_PAIRS)); 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ci ok(!(flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH))); 951cb0ef41Sopenharmony_ci ok(!(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS))); 961cb0ef41Sopenharmony_ci} 97