From 1a4e45685407d90acec73e4bc1a0198f6388ed12 Mon Sep 17 00:00:00 2001 From: Sergey Kambalin Date: Mon, 7 Oct 2024 17:54:36 +0600 Subject: [PATCH] Add more test to cover RPC error responses --- tests/specs/Errors.spec.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/specs/Errors.spec.ts b/tests/specs/Errors.spec.ts index d76d3c61..21b607b6 100644 --- a/tests/specs/Errors.spec.ts +++ b/tests/specs/Errors.spec.ts @@ -1,6 +1,6 @@ import { RouterNode } from '@cere-ddc-sdk/ddc'; import { DdcClient, StorageNodeMode, File, NodeError } from '@cere-ddc-sdk/ddc-client'; -import { getClientConfig, ROOT_USER_SEED } from '../helpers'; +import { getClientConfig, getStorageNodes, ROOT_USER_SEED } from '../helpers'; describe('Errors', () => { let smallFile: File; @@ -32,7 +32,33 @@ describe('Errors', () => { }); }); - describe('Unreachable node', () => { + describe('Static nodes client', () => { + let client: DdcClient; + + beforeAll(async () => { + client = await DdcClient.create(ROOT_USER_SEED, getClientConfig({ nodes: getStorageNodes() })); + }); + + afterAll(async () => { + await client.disconnect(); + }); + + it('should throw an RPC bucket error', async () => { + const error = await client.store(99n, smallFile).catch((error) => error); + console.log('err', error.message); + + expect(error).toBeInstanceOf(NodeError); + expect(error).toEqual( + expect.objectContaining({ + code: 'NOT_FOUND', + correlationId: expect.any(String), + nodeId: expect.any(String), + }), + ); + }); + }); + + describe('Unreachable node client', () => { let client: DdcClient; const bucketId = 1n; const unreachableNode: RouterNode = { @@ -59,7 +85,6 @@ describe('Errors', () => { serviceName: 'file.FileApi', methodName: 'putRawPiece', nodeId: unreachableNode.grpcUrl, - message: expect.any(String), correlationId: expect.any(String), }), );