11cb0ef41Sopenharmony_ci// Test async-hooks fired on right 21cb0ef41Sopenharmony_ci// asyncIds & triggerAsyncId for async-await 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cirequire('../common'); 61cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks'); 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst asyncIds = []; 101cb0ef41Sopenharmony_ciasync_hooks.createHook({ 111cb0ef41Sopenharmony_ci init: (asyncId, type, triggerAsyncId) => { 121cb0ef41Sopenharmony_ci asyncIds.push([triggerAsyncId, asyncId]); 131cb0ef41Sopenharmony_ci } 141cb0ef41Sopenharmony_ci}).enable(); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciasync function main() { 171cb0ef41Sopenharmony_ci await null; 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cimain().then(() => { 211cb0ef41Sopenharmony_ci // Verify the relationships between async ids 221cb0ef41Sopenharmony_ci // 1 => 2, 2 => 3 etc 231cb0ef41Sopenharmony_ci assert.strictEqual(asyncIds[0][1], asyncIds[1][0]); 241cb0ef41Sopenharmony_ci assert.strictEqual(asyncIds[0][1], asyncIds[3][0]); 251cb0ef41Sopenharmony_ci assert.strictEqual(asyncIds[1][1], asyncIds[2][0]); 261cb0ef41Sopenharmony_ci}); 27