11cb0ef41Sopenharmony_ciimport * as common from '../common/index.mjs';
21cb0ef41Sopenharmony_ciimport assert from 'node:assert';
31cb0ef41Sopenharmony_ciimport dgram from 'node:dgram';
41cb0ef41Sopenharmony_ciimport { describe, it } from 'node:test';
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_cidescribe('dgram.Socket[Symbol.asyncDispose]()', () => {
71cb0ef41Sopenharmony_ci  it('should close the socket', async () => {
81cb0ef41Sopenharmony_ci    const server = dgram.createSocket({ type: 'udp4' });
91cb0ef41Sopenharmony_ci    server.on('close', common.mustCall());
101cb0ef41Sopenharmony_ci    await server[Symbol.asyncDispose]().then(common.mustCall());
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci    assert.throws(() => server.address(), { code: 'ERR_SOCKET_DGRAM_NOT_RUNNING' });
131cb0ef41Sopenharmony_ci  });
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci  it('should resolve even if the socket is already closed', async () => {
161cb0ef41Sopenharmony_ci    const server = dgram.createSocket({ type: 'udp4' });
171cb0ef41Sopenharmony_ci    await server[Symbol.asyncDispose]().then(common.mustCall());
181cb0ef41Sopenharmony_ci    await server[Symbol.asyncDispose]().then(common.mustCall(), common.mustNotCall());
191cb0ef41Sopenharmony_ci  });
201cb0ef41Sopenharmony_ci});
21