Skip to content

Commit

Permalink
fix: command interface tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-KumarH committed Nov 17, 2024
1 parent 4c3536a commit 80a2fb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/command-interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ export class CommandInterface implements CommandInterfaceServiceImplementation {
* @returns Arbitrary JSON
*/
decodeMsg(msg: any): any {
return JSON.parse(Buffer.from(msg.value, 'base64').toString());
return JSON.parse(Buffer.from(msg.value).toString());
}

/**
Expand All @@ -748,7 +748,7 @@ export class CommandInterface implements CommandInterfaceServiceImplementation {
if (msg) {
return {
type_url: 'payload',
value: Buffer.from(JSON.stringify(msg)).toString('base64')
value: Buffer.from(JSON.stringify(msg))
};
}
}
Expand Down
11 changes: 4 additions & 7 deletions test/command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { createServiceConfig } from '@restorecommerce/service-config';
import { createLogger } from '@restorecommerce/logger';
import { createClient } from 'redis';
import {
CommandInterfaceServiceDefinition
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface';
import {
CommandInterfaceServiceDefinition as CISServiceDefinition,
CommandInterfaceServiceDefinition,
CommandInterfaceServiceClient
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface';
import {
Expand All @@ -26,7 +23,7 @@ import { Channel, createChannel } from 'nice-grpc';
* @returns Arbitrary JSON
*/
const decodeMsg = (msg: any): any => {
const decoded = Buffer.from(msg.value, 'base64').toString();
const decoded = Buffer.from(msg.value).toString();
return JSON.parse(decoded);
};

Expand All @@ -38,7 +35,7 @@ const decodeMsg = (msg: any): any => {
const encodeMsg = (msg: any): any => {

const stringified = JSON.stringify(msg);
const encoded = Buffer.from(stringified).toString('base64');
const encoded = Buffer.from(stringified);
const ret = {
type_url: 'payload',
value: encoded
Expand Down Expand Up @@ -110,7 +107,7 @@ describe('CommandInterfaceService', () => {
grpcClient = createGrpcClient({
...cfg.get('client:commandinterface'),
logger
}, CISServiceDefinition, channel);
}, CommandInterfaceServiceDefinition, channel);
});
after(async function teardown() {
this.timeout(30000);
Expand Down

0 comments on commit 80a2fb9

Please sign in to comment.