diff --git a/src/utils/wait.ts b/src/utils/wait.ts index ed5445f..7a11320 100644 --- a/src/utils/wait.ts +++ b/src/utils/wait.ts @@ -6,11 +6,11 @@ import { AllStatus } from './docker.js' import { TimeoutError } from './error.js' import { sleep } from './index.js' -const AWAIT_SLEEP = 3000 +const AWAIT_SLEEP = 1000 const BLOCKCHAIN_BODY_REQUEST = JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'eth_chainId' }) const EXPECTED_CHAIN_ID = '0x7a69' -const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET'] +const ALLOWED_ERRORS = ['ECONNREFUSED', 'ECONNRESET', 'UND_ERR_SOCKET', 502] as string[] function isAllowedError(e: FetchError): boolean { if (e.cause) { @@ -22,8 +22,6 @@ function isAllowedError(e: FetchError): boolean { return true } - // Errors from Bee-js does not have the `FetchError` structure (eq. `code` property) - // so we assert message itself. if (e.message.includes('socket hang up')) { return true } @@ -42,7 +40,7 @@ function extractIpFromMultiaddr(multiaddr: string): string { } -export async function waitForBlockchain(waitingIterations = 30): Promise { +export async function waitForBlockchain(waitingIterations = 90): Promise { for (let i = 0; i < waitingIterations; i++) { try { const request = await fetch('http://127.0.0.1:8545', { @@ -69,7 +67,7 @@ export async function waitForBlockchain(waitingIterations = 30): Promise { export async function waitForClient( verifyClientIsUp: () => Promise, - waitingIterations = 120, + waitingIterations = 300, ): Promise { const codex = new Codex('http://127.0.0.1:8080') @@ -107,7 +105,7 @@ export async function waitForClient( export async function waitForHosts( hostCount: number, getStatus: () => Promise, - waitingIterations = 120, + waitingIterations = 300, ): Promise { const codex = new Codex('http://127.0.0.1:8080') diff --git a/test/commands/start.test.ts b/test/commands/start.test.ts index 3d18ffc..3ad097e 100644 --- a/test/commands/start.test.ts +++ b/test/commands/start.test.ts @@ -12,12 +12,13 @@ import { deleteNetwork, findContainer } from '../utils/docker' chaiUse(chaiAsPromised) let testFailed = false -async function runCommand(args: string): Promise> { +async function runCommand (args: string): Promise> { const result = await runCommandRaw(args) if (result.error) { - console.log(result.stdout) - console.error(result.stderr) + console.log('============\n=> ERROR:', result.error) + console.log('============\n=> STDOUT:', result.stdout) + console.error('============\n=> STDERR:', result.stderr) } return result @@ -72,7 +73,9 @@ describe('start command', () => { const containers = await docker.listContainers() for (const c of containers) console.log(` - ${c.Names.join(', ')}`) - await runCommand('logs client') + const { stdout } = await runCommand('logs client') + console.log('Client logs:\n', stdout) + } await runCommand('stop') diff --git a/test/commands/stop.test.ts b/test/commands/stop.test.ts index e35b8be..92c2c62 100644 --- a/test/commands/stop.test.ts +++ b/test/commands/stop.test.ts @@ -13,8 +13,9 @@ async function runCommand(args: string): Promise ERROR:', result.error) + console.log('============\n=> STDOUT:', result.stdout) + console.error('============\n=> STDERR:', result.stderr) } return result