11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { AsyncLocalStorage } = require('async_hooks'); 51cb0ef41Sopenharmony_ciconst dc = require('diagnostics_channel'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst channel = dc.tracingChannel('test'); 91cb0ef41Sopenharmony_ciconst store = new AsyncLocalStorage(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst firstContext = { foo: 'bar' }; 121cb0ef41Sopenharmony_ciconst secondContext = { baz: 'buz' }; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cichannel.start.bindStore(store, common.mustCall(() => { 151cb0ef41Sopenharmony_ci return firstContext; 161cb0ef41Sopenharmony_ci})); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cichannel.asyncStart.bindStore(store, common.mustCall(() => { 191cb0ef41Sopenharmony_ci return secondContext; 201cb0ef41Sopenharmony_ci})); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciassert.strictEqual(store.getStore(), undefined); 231cb0ef41Sopenharmony_cichannel.traceCallback(common.mustCall((cb) => { 241cb0ef41Sopenharmony_ci assert.deepStrictEqual(store.getStore(), firstContext); 251cb0ef41Sopenharmony_ci setImmediate(cb); 261cb0ef41Sopenharmony_ci}), 0, {}, null, common.mustCall(() => { 271cb0ef41Sopenharmony_ci assert.deepStrictEqual(store.getStore(), secondContext); 281cb0ef41Sopenharmony_ci})); 291cb0ef41Sopenharmony_ciassert.strictEqual(store.getStore(), undefined); 30