Add verification and value stripping

This commit is contained in:
K35
2022-01-02 22:02:47 +00:00
parent db21c1c42e
commit cf49fca928
9 changed files with 272 additions and 125 deletions

View File

@ -4,6 +4,7 @@ import { AddValueRequest, AddValueResponse, Logging } from "./out/index";
import * as Client from "./out/index_client";
import * as Server from "./out/index_server";
import { VerificationError } from "./out/ts_base";
const client = new Client.ServiceProvider((msg) => {
session.onMessage(msg);
@ -41,7 +42,7 @@ class TestService extends Server.TestService<undefined> {
}
async FunctionWithArrayAsParamAndReturn(vals1, vals2) {
return [...vals1, ...vals2];
return [...vals1, ...vals2];
}
}
@ -72,23 +73,49 @@ async function run() {
console.log("!!!!This should have failed!!!!");
})
.catch((err) => {
console.log("Found expected error!", err.message);
if (err instanceof VerificationError)
console.log(
"Found expected error!",
{
type: err.type,
field: err.field,
value: err.value
}
);
else {
console.error(err);
throw new Error("Unexpected Error");
}
});
console.log("Test with arrays:");
console.log(await test
//@ts-ignore
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,5,6]));
console.log(
await test
//@ts-ignore
.FunctionWithArrayAsParamAndReturn([1, 2, 3], [4, 5, 6])
);
console.log("Let with Array fail!");
await test
//@ts-ignore
.FunctionWithArrayAsParamAndReturn([1,2,3], [4,"asd",6])
.FunctionWithArrayAsParamAndReturn([1, 2, 3], [4, "asd", 6])
.then(() => {
console.log("!!!!This should have failed!!!!");
})
.catch((err) => {
console.log("Found expected error!", err.message);
if (err instanceof VerificationError)
console.log(
"Found expected error!",
{
type: err.type,
field: err.field,
value: err.value
}
);
else {
console.error(err);
throw new Error("Unexpected Error");
}
});
}