test for push-stream, comment tests

This commit is contained in:
DieMyst
2021-07-23 16:47:31 +03:00
parent 0bf0ba6d94
commit 18f8bad2bf
3 changed files with 29 additions and 4 deletions

View File

@ -0,0 +1,9 @@
service OpA("pop"):
get_str() -> string
func get_results() -> []string:
results: *string
results <<- "hello"
str <- OpA.get_str()
results <<- str
<- results

View File

@ -0,0 +1,10 @@
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
import {get_results} from "../compiled/examples/pushToStream";
export async function pushToStreamCall(client: FluenceClient) {
registerServiceFunction(client, "pop", "get_str", (args: any[], _) => {
return "get_string"
})
return await get_results(client)
}

View File

@ -25,6 +25,7 @@ import {coCall} from "./examples/coCall";
import {passArgsCall} from "./examples/passArgsCall"; import {passArgsCall} from "./examples/passArgsCall";
import {streamArgsCall} from "./examples/streamArgsCall"; import {streamArgsCall} from "./examples/streamArgsCall";
import {streamResultsCall} from "./examples/streamResultsCall"; import {streamResultsCall} from "./examples/streamResultsCall";
import {pushToStreamCall} from "./examples/pushToStreamCall";
let deepEqual = require('deep-equal') let deepEqual = require('deep-equal')
function checkCall(name: string, expected: any, actual: any, callBackOnError: () => void) { function checkCall(name: string, expected: any, actual: any, callBackOnError: () => void) {
@ -127,10 +128,13 @@ const main = async () => {
let passArgsResult = await passArgsCall(client) let passArgsResult = await passArgsCall(client)
// streamArgs.aqua // streamArgs.aqua
let streamArgsResult = await streamArgsCall(client) // let streamArgsResult = await streamArgsCall(client)
// streamResults.aqua // streamResults.aqua
let streamResultsResult = await streamResultsCall(client) // let streamResultsResult = await streamResultsCall(client)
// pushToStream.aqua
let pushToStreamResult = await pushToStreamCall(client)
await client.disconnect(); await client.disconnect();
@ -177,9 +181,11 @@ const main = async () => {
checkCall("passArgsCall", passArgsResult, "client-utilsid", cb) checkCall("passArgsCall", passArgsResult, "client-utilsid", cb)
checkCall("streamArgsCall", streamArgsResult, [["peer_id", "peer_id"]], cb) // checkCall("streamArgsCall", streamArgsResult, [["peer_id", "peer_id"]], cb)
checkCall("streamResultsCall", streamResultsResult, ["new_name", "new_name", "new_name"], cb) // checkCall("streamResultsCall", streamResultsResult, ["new_name", "new_name", "new_name"], cb)
checkCall("pushToStreamCall", pushToStreamResult, ["hello", "get_string"], cb)
checkCallBy("tryCatchCall", tryCatchResult, (res) => { checkCallBy("tryCatchCall", tryCatchResult, (res) => {
return (res[0] as string).includes("Error: Service with id 'unex' not found") && res[1] === '/ip4/164.90.171.139/tcp/7770' return (res[0] as string).includes("Error: Service with id 'unex' not found") && res[1] === '/ip4/164.90.171.139/tcp/7770'