Skip to content

Commit

Permalink
fix: move sleep to have all code in src (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau authored May 26, 2022
1 parent 2c8b9d1 commit 19171cc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/bee-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import * as tag from './modules/debug/tag'
import * as stamps from './modules/debug/stamps'
import type { Options as KyOptions } from 'ky-universal'
import { makeDefaultKy, wrapRequestClosure, wrapResponseClosure } from './utils/http'
import { sleep } from '../test/utils'
import { sleep } from './utils/sleep'

export class BeeDebug {
/**
Expand Down
8 changes: 8 additions & 0 deletions src/utils/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Sleep for N miliseconds
*
* @param ms Number of miliseconds to sleep
*/
export async function sleep(ms: number): Promise<void> {
return new Promise<void>(resolve => setTimeout(() => resolve(), ms))
}
2 changes: 1 addition & 1 deletion test/integration/bee-class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
makeTestTarget,
PSS_TIMEOUT,
randomByteArray,
sleep,
testChunkPayload,
testIdentity,
testJsonHash,
Expand All @@ -30,6 +29,7 @@ import {
} from '../utils'
import { Readable } from 'stream'
import { TextEncoder } from 'util'
import { sleep } from '../../src/utils/sleep'

commonMatchers()

Expand Down
2 changes: 1 addition & 1 deletion test/integration/bee-debug-class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
commonMatchers,
getOrCreatePostageBatch,
BLOCKCHAIN_TRANSACTION_TIMEOUT,
sleep,
WAITING_USABLE_STAMP_TIMEOUT,
} from '../utils'
import { sleep } from '../../src/utils/sleep'

commonMatchers()

Expand Down
3 changes: 2 additions & 1 deletion test/integration/modules/debug/chequebook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
} from '../../../../src/modules/debug/chequebook'
import { NumberString } from '../../../../src/types'
import { isPrefixedHexString } from '../../../../src/utils/hex'
import { beeDebugKy, commonMatchers, sleep } from '../../../utils'
import { beeDebugKy, commonMatchers } from '../../../utils'
import { sleep } from '../../../../src/utils/sleep'

if (process.env.BEE_TEST_CHEQUEBOOK) {
commonMatchers()
Expand Down
18 changes: 5 additions & 13 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import { ReadableStream as ReadableStreamPolyfill } from 'web-streams-polyfill'
import ky from 'ky-universal'

import type {
Ky,
BeeGenericResponse,
Reference,
Address,
BatchId,
PostageBatch,
BeeGenericResponse,
Ky,
PlainBytesReference,
PostageBatch,
Reference,
} from '../src/types'
import { bytesToHex, HexString } from '../src/utils/hex'
import { deleteChunkFromLocalStorage } from '../src/modules/debug/chunk'
import { BeeResponseError } from '../src'
import { assertBytes } from '../src/utils/bytes'
import * as stamps from '../src/modules/debug/stamps'
import { sleep } from '../src/utils/sleep'

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand Down Expand Up @@ -118,15 +119,6 @@ export function commonMatchers(): void {
})
}

/**
* Sleep for N miliseconds
*
* @param ms Number of miliseconds to sleep
*/
export async function sleep(ms: number): Promise<void> {
return new Promise<void>(resolve => setTimeout(() => resolve(), ms))
}

/**
* Helper function that reads whole content of ReadableStream
* @param stream
Expand Down

0 comments on commit 19171cc

Please sign in to comment.