test for options

This commit is contained in:
DieMyst
2021-06-02 20:56:44 +03:00
parent f886650fb4
commit c2b84112b8
19 changed files with 58 additions and 19 deletions

View File

@ -0,0 +1,8 @@
service SomeS("test2"):
getStr: ?string -> ?string
getStr2: string -> string
func useOptional(opt: ?string, ackEm: string -> (), ack: string, ?string -> (), ack2: string, string -> ()) -> string:
ackEm("before")
ack("first", opt)
<- opt!

View File

@ -19,11 +19,12 @@
"build": "tsc",
"examples": "node -r ts-node/register src/run-examples.ts",
"exec": "npm run compile-aqua && node -r ts-node/register src/index.ts",
"run": "node -r ts-node/register src/index.ts",
"compile-aqua": "aqua-cli -i ./aqua/ -o ./src/compiled",
"compile-aqua:air": "aqua-cli -i ./aqua/ -o ./compiled-air -a"
},
"devDependencies": {
"@fluencelabs/aqua-cli": "^0.1.2-129",
"@fluencelabs/aqua-cli": "^0.1.4-133",
"@fluencelabs/aqua-lib": "^0.1.3",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.1.3-SNAPSHOT
* Aqua version: 0.1.4-SNAPSHOT
*
*/
import { FluenceClient, PeerIdB58 } from '@fluencelabs/fluence';

View File

@ -0,0 +1,21 @@
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
import {getTwoResults} from "../compiled/examples/foldJoin";
import {useOptional} from "../compiled/examples/option";
export async function useOptionalCall(client: FluenceClient): Promise<string> {
registerServiceFunction(client, "test2", "getStr", (args: any[], _) => {
console.log("getStr:")
console.log(args)
return args[0]
})
registerServiceFunction(client, "test2", "getStr2", (args: any[], _) => {
console.log("getStr2:")
console.log(args)
return args[0]
})
let cbEm = (str: string) => console.log(str)
let cb = (str: string, arg: any) => console.log(str, arg)
return await useOptional(client, "hello", cbEm, cb, cb)
}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env node
import {createClient, registerServiceFunction} from "@fluencelabs/fluence";
import {createClient, registerServiceFunction, setLogLevel} from "@fluencelabs/fluence";
import {testNet} from "@fluencelabs/fluence-network-environment";
import {callArrowCall} from "./examples/callArrowCall";
import {dataAliasCall} from "./examples/dataAliasCall";
@ -15,13 +15,16 @@ import {constantsCall} from "./examples/constantsCall";
import {streamCall} from "./examples/streamCall";
import {topologyCall} from "./examples/topologyCall";
import {foldJoinCall} from "./examples/foldJoinCall";
import {useOptionalCall} from "./examples/useOptionalCall";
let deepEqual = require('deep-equal')
function checkCall(name: string, expected: any, actual: any, callBackOnError: () => void) {
if (!deepEqual(actual, expected)) {
console.error(`${name} call has the wrong result`)
console.error("expected: " + expected)
console.error("actual: " + actual)
console.error("expected: ")
console.dir(expected)
console.error("actual: ")
console.dir(actual)
callBackOnError()
}
}
@ -35,6 +38,7 @@ function checkCallBy(name: string, actual: any, by: (res: any) => boolean, callB
}
const main = async () => {
// setLogLevel("trace")
const client = await createClient(testNet[0]);
const client2 = await createClient(testNet[1]);
@ -89,6 +93,9 @@ const main = async () => {
// foldJoin.aqua
let foldJoinResult = await foldJoinCall(client)
// option.aqua
let optionResult = await useOptionalCall(client)
await client.disconnect();
let success = true;
@ -120,6 +127,8 @@ const main = async () => {
checkCallBy("foldJoinCall", foldJoinResult, (res) => res.length == 3, cb)
checkCall("useOptional", optionResult, "hello", cb)
if (success) {
process.exit(0)
} else {