Skip to content

Commit

Permalink
fix(js): change references to internal fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Dec 2, 2024
1 parent 189796c commit 1ec4d39
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gateways/js/examples/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ShellExecReq = MessageClass('org.arl.fjage.shell.ShellExecReq');
});
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'a=2; a+2;';
req.command = 'a=2; a+2;';
req.ans = true;
let rsp = await gw.request(req);
console.log(rsp);
Expand Down
2 changes: 1 addition & 1 deletion gateways/js/examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ShellExecReq = MessageClass('org.arl.fjage.shell.ShellExecReq');
});
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'a=2; a+2;';
req.command = 'a=2; a+2;';
req.ans = true;
let rsp = await gw.request(req);
console.log(rsp);
Expand Down
32 changes: 16 additions & 16 deletions gateways/js/test/spec/fjage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('A Gateway', function () {
gw.connector.sock.send.calls.reset();
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'boo';
req.command = 'boo';
gw.request(req);
await delay(300);
expect(gw.connector.sock.send).toHaveBeenCalled();
Expand All @@ -176,7 +176,7 @@ describe('A Gateway', function () {
gw.connector.sock.send.calls.reset();
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'boo';
req.command = 'boo';
gw.request(req);
await delay(300);
expect(gw.connector.sock.send).toHaveBeenCalledWith(fjageMessageChecker());
Expand All @@ -190,7 +190,7 @@ describe('A Gateway', function () {
gw.connector.sock.send.calls.reset();
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'boo';
req.command = 'boo';
gw.request(req);
await delay(300);
expect(gw.connector.sock.send).toHaveBeenCalledWith(ShellExecReqChecker());
Expand Down Expand Up @@ -557,7 +557,7 @@ describe('Shell GetFile/PutFile', function () {
it('should be able to send a ShellExecReq', async function () {
const req = new ShellExecReq();
req.recipient = shell;
req.cmd = 'boo';
req.command = 'boo';
const rsp = await gw.request(req);
expect(rsp).toBeDefined();
expect(rsp.perf).toBeDefined();
Expand All @@ -579,38 +579,38 @@ describe('Shell GetFile/PutFile', function () {
var gfr = new GetFileReq();
gfr.recipient = shell;
gfr.filename = DIRNAME + '/' + FILENAME;
gfr.ofs = 5;
gfr.len = 4;
gfr.offset = 5;
gfr.length = 4;
const rsp = await gw.request(gfr);
expect(rsp).toBeTruthy();
expect(rsp instanceof GetFileRsp).toBeTruthy();
expect(rsp.contents).not.toBeUndefined();
expect(rsp.contents.length).toBe(4);
expect(rsp.ofs).toBe(5);
expect(rsp.offset).toBe(5);
expect(new TextDecoder('utf-8').decode(new Uint8Array(rsp.contents))).toEqual(TEST_STRING.substr(5, rsp.contents.length));
});

it('should be able get a section of a file using GetFileReq using offset and 0 length', async function () {
var gfr = new GetFileReq();
gfr.recipient = shell;
gfr.filename = DIRNAME + '/' + FILENAME;
gfr.ofs = 9;
gfr.len = 0;
gfr.offset = 9;
gfr.length = 0;
const rsp = await gw.request(gfr, 3000);
expect(rsp).toBeTruthy();
expect(rsp instanceof GetFileRsp).toBeTruthy();
expect(rsp.contents).not.toBeUndefined();
expect(rsp.contents.length).toBe(TEST_STRING.length-9);
expect(rsp.ofs).toBe(9);
expect(rsp.offset).toBe(9);
expect(new TextDecoder('utf-8').decode(new Uint8Array(rsp.contents))).toEqual(TEST_STRING.substr(9));
});

it('should refuse to return the contents of the file if offset is beyond file length using GetFileReq', async function () {
var gfr = new GetFileReq();
gfr.recipient = shell;
gfr.filename = DIRNAME + '/' + FILENAME;
gfr.ofs = 27;
gfr.len = 1;
gfr.offset = 27;
gfr.length = 1;
const rsp = await gw.request(gfr, 3000);
expect(rsp).toBeTruthy();
expect(rsp.perf).toEqual(Performative.REFUSE);
Expand Down Expand Up @@ -680,7 +680,7 @@ describe('Shell GetFile/PutFile', function () {
const pfr = new PutFileReq();
pfr.recipient = shell;
pfr.filename = DIRNAME + '/' + FILENAME;
pfr.ofs = 10;
pfr.offset = 10;
pfr.contents = Array.from((new TextEncoder('utf-8').encode(TEST_STRING)));
const rsp = await gw.request(pfr, 3000);
expect(rsp).toBeTruthy();
Expand All @@ -698,7 +698,7 @@ describe('Shell GetFile/PutFile', function () {
const pfr = new PutFileReq();
pfr.recipient = shell;
pfr.filename = DIRNAME + '/' + FILENAME;
pfr.ofs = -4;
pfr.offset = -4;
pfr.contents = Array.from((new TextEncoder('utf-8').encode(NEW_STRING)));
const rsp = await gw.request(pfr, 3000);
expect(rsp).toBeTruthy();
Expand Down Expand Up @@ -751,7 +751,7 @@ describe('Shell GetFile/PutFile', function () {
const pfr = new PutFileReq();
pfr.recipient = shell;
pfr.filename = DIRNAME + '/' + FILENAME;
pfr.ofs = 10;
pfr.offset = 10;
pfr.contents = Array.from((new TextEncoder('utf-8').encode(TEST_STRING)));
const rsp = await gw.request(pfr, 3000);
expect(rsp).toBeTruthy();
Expand All @@ -769,7 +769,7 @@ describe('Shell GetFile/PutFile', function () {
const pfr = new PutFileReq();
pfr.recipient = shell;
pfr.filename = DIRNAME + '/' + FILENAME;
pfr.ofs = -4;
pfr.offset = -4;
pfr.contents = Array.from((new TextEncoder('utf-8').encode(NEW_STRING)));
const rsp = await gw.request(pfr, 3000);
expect(rsp).toBeTruthy();
Expand Down

0 comments on commit 1ec4d39

Please sign in to comment.