chore: move integration tests to repo [LNG-167] (#756)

This commit is contained in:
Dima 2023-06-19 19:28:34 +03:00 committed by GitHub
parent b9d03cbcf0
commit 6cc3a969d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
115 changed files with 27047 additions and 0 deletions

110
integration-tests/.gitignore vendored Normal file
View File

@ -0,0 +1,110 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.idea/
lib/
.jar

View File

@ -0,0 +1,15 @@
.idea
.gitignore
node_modules
types
src/
tsconfig.json
webpack.config.js
bundle
pkg
.eslintignore
.eslintrc.js

View File

@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 4,
useTabs: false,
};

View File

@ -0,0 +1,7 @@
Copyright 2021 Fluence Labs
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,46 @@
# Aqua playground
Repository demonstrating the how to start writing aqua and integrate it into a typescript application
## Getting started
Install dependencies
```
npm install
```
To compile the aqua files execute
```
npm run compile-aqua
```
To start the `index.ts` execute
```
npm run run
```
To run all examples in `example` directory
```
npm run exec
```
If everything works correctly logs without errors will be printed on a screen:
Then you can add or modify `aqua` files in `aqua` directory, these files will be compiled into `/src/compiled` and you can use it in a TypeScript in your preferable way.
## Project structure
Aqua source files are located in `src/aqua`directory.
Aqua files are compiled into .ts located in `/src/compiled` directory.
Entry point to use aqua compiled files from TypeScript: `/src/index.ts`
Code that call all examples and check results: `/src/run-examples.ts`
## References
Documentation for the compiler can be found in the official repo: https://github.com/fluencelabs/aqua

View File

@ -0,0 +1,16 @@
import "@fluencelabs/aqua-dht/pubsub.aqua"
import "@fluencelabs/aqua-dht/dht.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
export getNeighbours, initTopicAndSubscribe, findSubscribers
func put_value(initial_peer: string, value: string) -> string:
initTopicAndSubscribe(initial_peer, value, nil, nil)
<- "OK"
func registerKeyPutValue(node_id: string, key: string, value: string, relay_id: ?string, service_id: ?string) -> []string:
nodes <- getNeighbours(key)
for n <- nodes par:
on n:
t <- Peer.timestamp_sec()
<- nodes

View File

@ -0,0 +1,24 @@
data SomeData:
value: string
otherValue: u64
data SubData:
someStr: string
someNum: i32
data SecondData:
value: string
complex: SubData
data ThirdData:
value: string
complex: SomeData
service ComplexService("op-ha"):
call(d: SomeData, sd: SecondData) -> SubData
identity() -> SecondData
func doSmth(d: SomeData, d2: SomeData, sd: SecondData, c: SubData, SecondData -> ThirdData) -> ThirdData:
res <- ComplexService.call(d, sd)
res2 <- c(res, sd)
<- res2

View File

@ -0,0 +1,13 @@
data Prod:
value: string
service OpHa("op"):
array(a: string, b: string) -> []string
identity(a: string) -> string
func doSmth(arg: Prod) -> []string:
v = arg.value
a <- OpHa.identity(v)
b = "hello"
res <- OpHa.array(a, b)
<- res

View File

@ -0,0 +1,16 @@
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
-- functions like `c` are called an 'arrow function' in Aqua
-- `c` passed to a function from a client, so, it could be called only on a client
func passFunctionAsArg(node: string, str: string, c: string -> string):
on node:
Peer.identify()
-- we go here back on a client
res <- c(str)
-- then return on a node
Peer.identify()
print(res)
func reproArgsBug426(log: string -> (), arg: string):
log(arg)

View File

@ -0,0 +1,14 @@
data Record:
relay_id: []string
peer_id: string
service Ser("ser"):
getRecord: -> Record
func bugLng79(log: string -> ()) -> u32:
stream: *Record
stream <- Ser.getRecord()
someone = stream[0]
on someone.peer_id via someone.relay_id:
a = 1 + 1
<- a

View File

@ -0,0 +1,16 @@
export lng193Bug
func getClosure(arg: u16, peer: string) -> u16 -> u16:
on peer:
closure = (x: u16) -> u16:
<- arg + x
<- closure
func lng193Bug(peer: string, closurePeer: string) -> u16:
on peer:
c = getClosure(42, closurePeer)
b = c
a = b
res1 = a(1) + a(2) -- Call two times for
res2 = b(3) + b(4) -- bug to appear
<- res1 + res2

View File

@ -0,0 +1,73 @@
module Closure declares *
import "@fluencelabs/aqua-lib/builtin.aqua"
export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug
service MyOp("op"):
identity(s: string) -> string
service LocalSrv("local_srv"):
inside: -> ()
func closureIn(peer1: string) -> string:
variable = "const"
co on peer1:
p1Id <- MyOp.identity("co on")
closure = (s: string) -> string:
if s == "in":
LocalSrv.inside()
p2Id <- MyOp.identity(s)
<- p2Id
p <- closure("in")
<- p
func closureOut(peer2: string) -> Info:
on peer2:
closure = (s: string) -> Info:
if s == "in":
LocalSrv.inside()
p2Id <- Peer.identify()
<- p2Id
p2Id <- closure("on")
<- p2Id
func closureOut2(peer2: string) -> Info:
closure = func (s: string) -> Info:
if s == "in":
LocalSrv.inside()
p2Id <- Peer.identify()
<- p2Id
on peer2:
p2Id <- closure("on")
<- p2Id
func closureBig(peer1: string, peer2: string) -> string, string:
variable = "const"
co on peer1:
p1Id <- MyOp.identity("co on")
closure = func (s: string) -> string:
p2Id: *string
if s == "in":
p2 <- MyOp.identity(s)
p2Id <<- p2
else:
p2Info <- Peer.identify()
p2Id <<- p2Info.external_addresses!0
<- p2Id!
p <- closure("in")
on peer2:
p2Id <- closure("on")
<- p, p2Id
func lng58Bug() -> string:
status: *string
waiting = ():
avava: *string
avava <<- "frerf"
status <<- "ok"
waiting()
<- status!

View File

@ -0,0 +1,13 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service CoService("coservice-id"):
call: -> string
-- here we go to another node and not waiting for execution there
-- all `ParService.call()` will be executed instantly
func coFunc( node: string, c: Info -> () ):
y <- CoService.call()
on node:
t <- Peer.identify()
co c(t)
x <- CoService.call()

View File

@ -0,0 +1,43 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
func arraySugar(n: u32, m: u32) -> []u32, []u32:
arr = [1,2,n]
str: *u32
for i <- [4,5,m]:
str <<- i
<- arr, str
func streamSugar(n: u32, m: u32) -> []u32, []u32:
arr = *[1,2,n]
str: *u32
for i <- *[4,5,m]:
str <<- i
<- arr, str
func optionSugar(numSome: ?u32, strSome: ?string, numNone: ?u32, strNone: ?string) -> []u32, []string, []string:
arr = ?[numNone!, numSome!]
str: *string
str2 = ?[strNone!, strNone!, strNone!, strNone!, strNone!]
for i <- ?[strSome!,strNone!, "random string"]:
str <<- i
for i <- ?[strNone!,strNone!]:
str <<- i
<- arr, str, str2
service OpO("op"):
identity: string -> string
service GetArr("getArr"):
getArr: -> []string
func getNeighbours() -> []string:
nodes <- GetArr.getArr()
<- nodes
func bugLNG59() -> string:
nodes <- getNeighbours()
n = nodes[1]
on n via [HOST_PEER_ID]:
res <- OpO.identity("some str")
<- res

View File

@ -0,0 +1,40 @@
import "helloWorld.aqua"
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
import "func.aqua"
service TestS("some-id"):
t: string -> string
multiline( -- comments
a: string, -- comments
b: string, -- comments
c: bool -- comments
) -> string -- comments
-- just a lot of imports and calls
func doStuff( -- comments
a: string, -- comments
b: string, -- comments
c: bool,
d: bool, e: []string, g: []string, str: string -- comments
) -> []string: -- comments
stream: *string
stream <- TestS.t(str)
par Println.print(a)
par on a:
Peer.identify()
on a:
on b:
if c:
if d:
for eEl <- e:
for gEl <- g:
stream <- TestS.t(gEl) -- comments
stream <- TestS.t(eEl)
stream <- TestS.t(eEl)
stream <- TestS.multiline( -- comments
a, -- comments
b, -- comments
c -- comments
) -- comments
<- stream

View File

@ -0,0 +1,33 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service Getter("test"):
createStr: u32 -> string
service OpO("op"):
identity: string -> string
service OpN("op"):
identity: i32 -> i32
-- a question mark means that this constant could be rewritten before this definition
const ANOTHER_CONST ?= "default-str"
const UNIQUE_CONST ?= 5
func callConstant() -> []string:
res: *string
res <- Getter.createStr(UNIQUE_CONST)
res <- OpO.identity(ANOTHER_CONST)
<- res
func timestampAndTtl() -> u32, u64:
Op.noop()
<- PARTICLE_TTL, PARTICLE_TIMESTAMP
const A = 2
const B = -3
func compareConstants():
if A == B:
OpN.identity(A)
else:
OpN.identity(B)

View File

@ -0,0 +1,17 @@
-- set `PeerId` name to be a type alias for `string` type
alias PeerId : string
-- define data structure (ADT)
data NodeId:
peerId: PeerId
name: string
-- define service `NodeIdGetter` that will be callable on local client via `somesrv` service id
service NodeIdGetter("somesrv"):
get: -> NodeId
-- showcases a function that gets data structure from a local service,
-- and then retrieves aliased data type from that structure
func getAliasedData() -> PeerId:
res <- NodeIdGetter.get()
<- res.peerId

View File

@ -0,0 +1,20 @@
service Peer("peer"):
is_connected: string -> bool
service Op("op"):
identity: -> ()
data User:
peer_id: string
relay_id: string
name: string
service Test("test"):
getUserList: -> []User
doSomething: -> bool
func betterMessage(relay: string):
on relay:
isOnline <- Peer.is_connected(relay)
if isOnline:
Test.doSomething()

View File

@ -0,0 +1,24 @@
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
-- showcases `for` instruction that compiles to `fold` in AIR
func iterateAndPrint(strings: []string):
for s <- strings:
print(s)
func iterateAndPrintParallel(nodes: []string, c: Info -> ()):
for s <- nodes par:
on s:
ads <- Peer.identify()
c(ads)
func to_i_64(i: u32) -> i64:
<- i
func forBug499() -> []i64:
num = 5
numbers: *i64
for i <- [""]:
ali64 <- to_i_64(num)
numbers <<- ali64
<- numbers

View File

@ -0,0 +1,21 @@
module FoldJoin
import "@fluencelabs/aqua-lib/builtin.aqua"
export getTwoResults
service Op2("op"):
identity(s: u64)
func getTwoResults(node: string) -> []u64:
on node:
nodes <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
res: *u64
for n <- nodes par:
on n:
try:
res <- Peer.timestamp_sec()
Op2.identity(res!)
Op2.identity(res!1)
Op2.identity(res!2)
<- res

View File

@ -0,0 +1,6 @@
service TestSrv("test-service-id"):
str: -> string
func testFunc() -> string:
res <- TestSrv.str()
<- res

View File

@ -0,0 +1,39 @@
module Funcs declares main, A, calc
export main, A, calc, calc2, ifCalc
service A("a"):
getJ(i: u32) -> u32
func main(log: string, []u32 -> ()) -> u32:
closure = (i: []u32, j: u32) -> u32:
some <- A.getJ(i[j])
<- some
closure2 = func (i: []u32, j: u32) -> u32:
some <- A.getJ(i[j])
<- some
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
idx1 <- A.getJ(arr[A.getJ(3) + 2]) -- 5
idx2 <- A.getJ(arr[A.getJ(3) + 3] + arr[A.getJ(1) - 1] - 3) -- 3
<- A.getJ(arr[(idx1 + idx2) + closure(arr, 2) + closure2(arr, 3)]) -- should be 13
func calc(log: string, []u32 -> ()) -> u32:
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
num <- A.getJ((5-2)*3-3) -- 6
log("calc 2", [num])
<- arr[num] -- should be 6
func calc2(log: string, []u32 -> ()) -> u32:
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
num <- A.getJ((5-2) * 3 - 3 ** (A.getJ(5 + 5) - A.getJ(3 ** (3 - 1)))) -- 6
<- arr[num + num - A.getJ(num) - 3] -- should be 3
func ifCalc() -> u64:
arr = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
res: *u64
if A.getJ(8 - 2) + A.getJ(4 % 2) > arr[5 - 3 + A.getJ(3)] - 2:
res <<- 1
else:
res <<- 2
<- res!0

View File

@ -0,0 +1,6 @@
func lng119Bug() -> []u32:
nums = [1,2,3,4,5]
results: *u32
results <<- 1
join results[nums.length-5]
<- results

View File

@ -0,0 +1,6 @@
service StringExtra("service-id"):
addNameToHello: string -> string
func helloWorld(name: string) -> string:
res <- StringExtra.addNameToHello(name)
<- res

View File

@ -0,0 +1,36 @@
import "println.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
service OpR("op"):
identity(s: string) -> string
func ifElseCall(condition: bool):
if condition:
Println.print("it is true")
else:
Println.print("it is false")
func ifElseNumCall(condition: u32):
if condition == 1:
Println.print("it is 1")
else:
Println.print("it is not 1")
func ifCorrectXorWrap(node: string) -> string:
service_id: *string
on node:
res <- OpR.identity("1234")
if res == "":
service_id <<- "0x"
else:
service_id <<- "1x"
<- service_id!
func bugLNG69(other_node: PeerId) -> bool:
on other_node:
Op.noop()
if false:
Op.noop()
<- true

View File

@ -0,0 +1,15 @@
module FooBars declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
export SuperFoo
const DECLARE_CONST = "declare_const"
const DECLARE_CONST2 = "declare_const2"
service SuperFoo("super_foo"):
small_foo() -> string
func decl_foo() -> string:
res1 <- SuperFoo.small_foo()
<- res1
func decl_bar() -> string:
<- "declare all bar"

View File

@ -0,0 +1,16 @@
module Export declares foobar, foo
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
func bar() -> string:
<- " I am MyFooBar bar"
func foo() -> string:
<- "I am MyFooBar foo"
func foobar() -> []string:
Noop.noop()
res: *string
res <- foo()
res <- bar()
<- res

View File

@ -0,0 +1,8 @@
-- exports3.aqua
module Export3 declares *
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
func foo() -> string:
Noop.noop()
<- "I am MyFooBar foo"

View File

@ -0,0 +1,18 @@
module Exports declares some_string, MyExportSrv, EXPORT_CONST, some_random_func
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
export some_string as string_from_lib
export MyExportSrv
const EXPORT_CONST = "export_const"
service MyExportSrv("my_export_srv"):
another_str() -> string
func some_string() -> string:
Noop.noop()
<- "some_string_func"
func some_random_func() -> string:
<- "wow, so random"

View File

@ -0,0 +1,2 @@
service OneMore:
more_call()

View File

@ -0,0 +1,18 @@
module Import
import foobar from "export2.aqua"
use foo as f from "export2.aqua" as Exp
import "gen/OneMore.aqua"
import OneMore as OM from "gen/OneMore.aqua"
export foo_wrapper as wrap, foobar as barfoo
func foo_wrapper() -> string:
z <- Exp.f()
OneMore "hello"
OneMore.more_call()
OM "ohmygod"
OM.more_call()
<- z

View File

@ -0,0 +1,12 @@
-- imports3.aqua
module Import3 declares *
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
export foo_wrapper
use "export3.aqua"
func foo_wrapper() -> string:
Noop.noop()
z <- Export3.foo()
<- z

View File

@ -0,0 +1,6 @@
import decl_foo, decl_bar from "declare.aqua"
use DECLARE_CONST, SuperFoo, DECLARE_CONST2 as DC2 from "declare.aqua" as Declare
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
import some_string, MyExportSrv, EXPORT_CONST, some_random_func from "exports.aqua"
export some_string as some_str, some_random_func, MyExportSrv, EXPORT_CONST

View File

@ -0,0 +1,23 @@
import decl_foo, decl_bar from "declare.aqua"
use DECLARE_CONST, SuperFoo, DECLARE_CONST2 as DC2 from "declare.aqua" as Declare
import Op as Noop from "@fluencelabs/aqua-lib/builtin.aqua"
import some_string, MyExportSrv, EXPORT_CONST from "exports.aqua"
use "export3.aqua"
service StringService("string_service"):
concat(a: string, b: string) -> string
func concat_foobars() -> string:
Noop.noop()
Export3.foo()
res1 <- decl_foo()
res2 <- decl_bar()
res3 <- StringService.concat(res1, res2)
res4 <- Declare.SuperFoo.small_foo()
Noop.noop()
res5 <- StringService.concat(res3, res4)
res6 <- StringService.concat(res5, EXPORT_CONST)
res7 <- StringService.concat(res6, Declare.DECLARE_CONST)
Noop.noop()
res8 <- StringService.concat(res7, Declare.DC2)
<- res8

View File

@ -0,0 +1,13 @@
alias SomeString : string
data SomeResult:
one: SomeString
two: u32
service SubService("sub_service"):
sub(s: SomeString) -> SomeResult
func subImport() -> SomeResult:
res <- SubService.sub("some thing")
<- res

View File

@ -0,0 +1,26 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
func joinIdxLocal(idx: i16, nodes: []string) -> []string:
nodes2: *string
for node <- nodes par:
nodes2 <<- node
join nodes2[idx], nodes
<- nodes2
func joinIdxRelay(idx: i16, nodes: []string) -> []string:
on HOST_PEER_ID:
nodes2: *string
for node <- nodes par:
nodes2 <<- node
join nodes2[idx], nodes
<- nodes2
func joinIdx(idx: i16, nodes: []string) -> []Info:
infos: *Info
nodes2: *string
for node <- nodes par:
on node:
infos <- Peer.identify()
nodes2 <<- node
join infos[idx-1+1], nodes2[idx-1+1]
<- infos

View File

@ -0,0 +1,8 @@
func test1() -> u64:
res = 1 + 2 - 3 * 5 - 2 * 3 / 2 + 5
<- res
func test2() -> u64:
res = 2 ** 2 ** (2 * 2 - 2) + 2 - 3 * 5 - 2 * 3 / 2 + 5 + (4 % 2 - 2)
<- res

View File

@ -0,0 +1,22 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service GetStr("multiret-test"):
retStr: string -> string
service GetNum("multiret-num"):
retNum: -> u8
const SOME_NUM = 5
const SOME_STR = "some-str"
func tupleFunc() -> string, u8:
str <- GetStr.retStr(SOME_STR)
n <- GetNum.retNum()
<- str, n
func multiReturnFunc(somethingToReturn: []u8, smthOption: ?string) -> []string, u8, string, []u8, ?string, u8 :
res: *string
res <- GetStr.retStr(SOME_STR)
res <- GetStr.retStr("random-str")
res, tNum <- tupleFunc()
<- res, SOME_NUM, SOME_STR, somethingToReturn, smthOption, tNum

View File

@ -0,0 +1,18 @@
data NestedType:
val: string
data NestedStruct:
one: NestedType
service Test("service"):
test1() -> NestedStruct
test2(arg1: NestedType, arg2: string) -> NestedStruct
func test3() -> NestedType:
res <- Test.test1()
<- res.one
func test() -> NestedStruct:
struct <- test3()
res <- Test.test2(struct, struct.val)
<- res

View File

@ -0,0 +1,12 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service OpH("opa"):
identity(s: string) -> string
func a(b: string) -> string:
c <- OpH.identity(b)
<- c
func d(e: string) -> string:
f <- a(e)
<- f

View File

@ -0,0 +1,40 @@
aqua StructCreation declares getObj, getObjRelay, getObjAssign
export getObj, getObjRelay, getObjAssign
import "@fluencelabs/aqua-lib/builtin.aqua"
data InnerObj:
arr: []string
num: u32
data SomeObj:
str: string
num: u64
inner: InnerObj
service OpNum("op"):
identity(n: u32) -> u32
service OpStr("op"):
identity(n: string) -> string
service OpArr("op"):
identity(arr: []string) -> []string
func getObj() -> SomeObj:
<- SomeObj(str = OpStr.identity("some str"), num = 5, inner = InnerObj(arr = ["a", "b", "c"], num = 6))
func getObjRelay() -> SomeObj:
on HOST_PEER_ID:
obj = SomeObj(str = "diff str", num = 5, inner = InnerObj(arr = OpArr.identity(["a", "b", "c"]), num = 6))
Op.noop()
<- obj.copy(str = "some str")
func getObjAssign() -> SomeObj, SomeObj, u32:
obj = SomeObj(str = "first str",
num = OpNum.identity(5),
inner = InnerObj(arr = ["d", "e", "f"], num = 7)
)
copiedObj = obj.copy(str = "some str", inner = obj.inner.copy(arr = ["a", "b", "c"])).copy(num = 6)
<- obj, copiedObj, copiedObj.inner.copy(arr = ["g"]).arr.length

View File

@ -0,0 +1,12 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
func getPeerExternalAddresses(otherNodePeerId: string) -> []string:
on otherNodePeerId:
res <- Peer.identify()
<- res.external_addresses
-- it is possible to use `via` to built complex routes
func getDistantAddresses(target: string, viaNode: string) -> []string:
on target via viaNode:
res <- Peer.identify()
<- res.external_addresses

View File

@ -0,0 +1,25 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service SomeS("test2"):
getStr: ?string -> ?string
getStr1: -> ?string
getStr2: string -> string
checkU32(u: ?u32)
func checkU32AndU8(a: ?u8):
SomeS.checkU32(a)
func useOptional(opt: ?string) -> string:
res <- SomeS.getStr(opt)
for i <- opt:
SomeS.getStr2(i)
<- res!
func returnOptional() -> ?string:
res <- SomeS.getStr1()
<- res
func returnNone() -> ?string:
result: *string
Op.noop()
<- result

View File

@ -0,0 +1,21 @@
service OptionString("opt_str"):
checkOption(str: ?string) -> string
func emptyString() -> ?string:
valueEmpty: ?string
<- valueEmpty
func checkEmpty() -> string:
empty <- emptyString()
res <- OptionString.checkOption(empty)
<- res
func stringAsOption(str: string) -> ?string:
valueEmpty: ?string
valueEmpty <<- str
<- valueEmpty
func checkNoneEmpty(str: string) -> string:
nonEmpty <- stringAsOption(str)
res <- OptionString.checkOption(nonEmpty)
<- res

View File

@ -0,0 +1,34 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service ParService("parservice-id"):
call: -> string
-- here we go to another node and not waiting for execution there
-- all `ParService.call()` will be executed instantly
func parFunc( node: string, c: Info -> () ):
y <- ParService.call()
par on node:
t <- Peer.identify()
c(t)
par x <- ParService.call()
func testTimeout(nodes: []string) -> string:
on HOST_PEER_ID:
results: *Info
for node <- nodes par:
on node:
results <- Peer.identify()
timeout: *string
join results[999]
par timeout <- Peer.timeout(400, "timeout")
status: *string
if timeout == nil:
status <<- "ok"
else:
status <<- timeout!
<- status!

View File

@ -0,0 +1,24 @@
import Op from "@fluencelabs/aqua-lib/builtin.aqua"
service AquaDHT("test-dht"):
put_host_value(key: string, value: string, service_id: []string) -> string
func putHostValue(key: string, value: string, service_id: ?string) -> string:
res <- AquaDHT.put_host_value(key, value, service_id)
<- res
func create_client_util(service_id: string) -> string:
res <- putHostValue("client-util", service_id, nil)
<- res
func wait(successful: *bool, n: i16):
join successful[n - 1]
func bugLNG60(node: string) -> bool:
successful: *bool
nodes = [node]
for n <- nodes:
successful <<- true
wait(successful, 1)
<- true

View File

@ -0,0 +1,5 @@
service Println("println-service-id"):
print: string -> ()
func print(str: string):
Println.print(str)

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,13 @@
service YesNoService("yesno"):
get() -> string
func recursiveStream() -> []string, []string:
result: *string
loop: *string
loop <<- "yes"
for l <- loop:
if l == "yes":
loop <- YesNoService.get()
result <<- "success"
<- result, loop

View File

@ -0,0 +1,31 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
export callReturnedArrow, callReturnedChainArrow
func returnCall(arg: string) -> string -> string, string:
str <- Op.concat_strings(arg, " literal")
closure = (s: string) -> string, string:
<- s, Op.concat_strings(s, str)
<- closure
func callReturnedArrow(argForFunc: string, argForClosure: string) -> string, string:
a = returnCall(argForFunc)
b, c <- a(argForClosure)
<- b, c
func secondReturnCall(arg: string) -> (string -> string, string), (string -> string, string), (string -> string, string):
str <- Op.concat_strings(arg, " second literal")
closure = (s: string) -> string, string:
<- s, Op.concat_strings(s, str)
b = closure
a = returnCall(" from second")
<- b, closure, a
func callReturnedChainArrow(argForFirst: string, argForSecond: string) -> string, string, string, string, string, string, string, string:
first = returnCall(argForFirst)
second, third, fourth <- secondReturnCall(argForSecond)
a, b <- first("first")
c, d <- second("second")
e, f <- third("third")
g, h <- fourth("fourth")
<- a, b, c, d, e, f, g, h

View File

@ -0,0 +1,2 @@
func returnLiteral() -> string:
<- "some literal"

View File

@ -0,0 +1,69 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
import "println.aqua"
service Stringer("stringer-id"):
returnString: string -> string
func checkStreams(ch: []string) -> []string:
stream: *string
stream <- Stringer.returnString("first")
stream <- Stringer.returnString("second")
for b <- ch:
stream <- Stringer.returnString(b)
<- stream
func getStream() -> *u32:
nums = *[1,2,3,4]
<- nums
func returnStreamFromFunc() -> *u32:
nums <- getStream()
<- nums
func stringNil() -> *string:
valueNil: *string
<- valueNil
func returnNil() -> *string:
relayNil <- stringNil()
<- relayNil
func returnNilLiteral() -> *string:
<- nil
func returnNilLength() -> u32:
arr = nil
<- arr.length
func stringNone() -> ?string:
valueNone: ?string
<- valueNone
func returnNone() -> ?string:
relayNone <- stringNone()
<- relayNone
func streamFunctor(arr: []string) -> string:
stream: *[]string
stream <<- ["123"]
a = stream[arr.length - 1][0]
<- a
func streamAssignment(arr: []string) -> string:
stream: *[]u32
stream <<- [0]
a = stream[arr.length - 1][0]
b = arr[a]
<- b
func streamIntFunctor(arr: []u32) -> string:
stream: *[]string
stream <<- ["123"]
a = stream[arr[0]][arr[0]]
<- a
func streamJoin(arr: []string) -> string:
streamJ: *[]string
streamJ <<- ["111", "222"]
streamJ <<- ["333", "444"]
<- streamJ[arr.length][1]

View File

@ -0,0 +1,10 @@
service TestService("test-service"):
get_records(key: string) -> []string
func append_records(peer: string, srum: *[]string):
srum <- TestService.get_records(peer)
func retrieve_records(peer: string) -> [][]string:
records: *[]string
append_records(peer, records)
<- records

View File

@ -0,0 +1,7 @@
module Ret declares *
export someFunc
func someFunc(cb: []string -> ()):
ifaces: *string
cb(ifaces)

View File

@ -0,0 +1,46 @@
export accumRes, bugLNG63, bugLNG63_2
func toOpt(s: string) -> ?string:
str: *string
str <<- s
<- str
func accumRes() -> *?string:
res_accum: *?string
a <- toOpt("a")
res_accum <<- a
res_accum <- toOpt("b")
res_accum <<- nil
<- res_accum
func returnCanStream() -> string:
status: *string
status <<- "ok"
stat = status!
<- stat
service Op1("op"):
array_length(array: []string) -> u32
func bugLNG63() -> string:
res <- returnCanStream()
<- res
func returnMultipleStreamResults() -> string, []string, []string, []string:
status: *string
status <<- "ok"
stat = status!
<- stat, status, [status!, stat], [status!, "no", status!]
func bugLNG63_2() -> string, []string, []string:
res, res2, res3, res4 <- returnMultipleStreamResults()
<- res, res2, res4
func bugLNG63_3() -> string, u32, []u32:
status: *string
status <<- "ok"
stat = status!
num: *u32
num <<- 2
res = [Op1.array_length(status), num!]
<- status!, Op1.array_length(status), [Op1.array_length(status), 3, num!]

View File

@ -0,0 +1,10 @@
func streamFold(arr: []string) -> []string:
res: *string
for n <- arr:
res <<- n
<- res
func streamRes(arr: []string) -> []string, []string:
res: *string
res2 <- streamFold(arr)
<- res, res2

View File

@ -0,0 +1,16 @@
data DT:
field: string
service DTGetter("get-dt"):
get_dt(s: string) -> DT
func use_name1(name: string) -> string:
results <- DTGetter.get_dt(name)
<- results.field
func use_name2(name: string) -> []string:
results: *string
results <- use_name1(name)
results <- use_name1(name)
results <- use_name1(name)
<- results

View File

@ -0,0 +1,11 @@
import "imports_exports/subImport.aqua"
service ConcatSubs("concat_subs"):
get_some(s: SomeString, sr: SomeResult) -> SomeResult
func subImportUsage(s: SomeString) -> SomeResult:
sr1 <- SubService.sub(s)
sr2 <- subImport()
result <- ConcatSubs.get_some(sr1.one, sr2)
<- result

View File

@ -0,0 +1,53 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service Testo("testo"):
getString: string -> string
service LocalPrint("lp"):
print: string -> ()
service Opop("op"):
identity(s: string) -> string
func topologyTest(me: string, myRelay: string, friend: string, friendRelay: string) -> string:
on friend via friendRelay:
str2 <- Testo.getString("friends string via")
par LocalPrint.print("my string in par")
LocalPrint.print(str2)
<- "finish"
func topologyBug205(node_id: string, n2: ?string) -> []string:
nodes: *PeerId
on node_id:
a <- Op.identity(n2)
nodes <<- a!
on node_id:
for n <- nodes par:
on n:
Peer.identify()
<- nodes
service IOp("op"):
identity: string -> string
func topologyBug394(peer: string, peer2: string, peer3: string) -> string:
-- execute computation on a Peer in the network
on peer:
comp <- IOp.identity(%init_peer_id%)
-- send the result to target browser in the background
co on peer2 via peer3:
res <- IOp.identity(%init_peer_id%)
-- send the result to the initiator
<- comp
func topologyBug427(peers: []string) -> []string:
results: *string
for peer <- peers par:
on peer:
results <- Opop.identity("some string")
join results[1]
<- results

View File

@ -0,0 +1,25 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service Unexisted("unex"):
getStr() -> string
data LastError:
instruction: string
message: string
peer_id: string
service OpA("op"):
identity(s: string) -> string
func tryCatchTest(node_id: string) -> []string:
on node_id:
f: *string
try:
f <- Unexisted.getStr()
catch err:
c: *string
f <- OpA.identity(err.message)
-- check if the call takes place on the node
i <- Peer.identify()
f <- OpA.identity(i.external_addresses!)
<- f

View File

@ -0,0 +1,19 @@
service Unexisted("unex"):
getStr() -> string
data LastError:
instruction: string
msg: string
peer_id: string
service OpE("op"):
identity(s: string) -> string
func tryOtherwiseTest(node_id: string) -> string:
on node_id:
f: *string
try:
f <- Unexisted.getStr()
otherwise:
f <- OpE.identity("error")
<- f!

View File

@ -0,0 +1,17 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
func viaArr(node_id: string, viaAr: []string) -> Info:
on node_id via viaAr:
p <- Peer.identify()
<- p
func viaStream(node_id: string, viaStr: *string) -> Info:
on node_id via viaStr:
p <- Peer.identify()
<- p
func viaOpt(relay: string, node_id: string, viaOpt: ?string) -> Info:
on node_id via viaOpt:
p <- Peer.identify()
<- p

View File

@ -0,0 +1,18 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
extensionsToTreatAsEsm: ['.ts'],
"preset": "ts-jest/presets/default-esm",
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
"useESM": true
}
]
}
};

24068
integration-tests/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
{
"name": "aquamarine-template",
"version": "0.3.9",
"keywords": [
"typescript",
"template"
],
"type": "module",
"author": "FluenceLabs (https://github.com/fluencelabs)",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/",
"src/"
],
"scripts": {
"build": "tsc",
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --detectOpenHandles",
"examples": "jest",
"pubsub": "node -r ts-node/register src/pubsub.ts",
"exec": "npm run compile-aqua && npm run prettify-compiled && node -r ts-node/register src/index.ts",
"run": "node -r ts-node/register src/index.ts",
"compile-aqua": "aqua -i ./aqua/ -o ./src/compiled",
"compile-aqua:air": "aqua -i ./aqua/ -o ./compiled-air -a",
"prettify-compiled": "prettier --write src/compiled",
"aqua": "aqua",
"do": "aqua dist deploy --addr /dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi --config-path deploy.json --service tsOracle"
},
"devDependencies": {
"@fluencelabs/aqua": "0.11.5",
"@fluencelabs/aqua-dht": "0.2.5",
"@fluencelabs/aqua-lib": "0.6.0",
"@types/jest": "29.5.2",
"jest": "29.5.0",
"ts-jest": "29.1.0",
"@types/node": "18.11.18",
"ts-node": "10.9.1",
"typescript": "5.1.3"
},
"dependencies": {
"@fluencelabs/js-client.node": "0.6.9",
"loglevel": "1.8.1",
"@fluencelabs/js-client.api": "0.11.6",
"@fluencelabs/fluence-network-environment": "1.0.14",
"deep-equal": "2.2.1"
},
"description": "Minimal template for aquamarine project."
}

View File

@ -0,0 +1,571 @@
import {Fluence, IFluenceClient, createClient} from '@fluencelabs/js-client.api';
import "@fluencelabs/js-client.node"
import {getObjAssignCall, getObjCall, getObjRelayCall} from "../examples/objectCall.js";
import {callArrowCall, reproArgsBug426Call} from '../examples/callArrowCall.js';
import {dataAliasCall} from '../examples/dataAliasCall.js';
import {onCall} from '../examples/onCall.js';
import {funcCall} from '../examples/funcCall.js';
import {registerPrintln} from '../compiled/examples/println.js';
import {helloWorldCall} from '../examples/helloWorldCall.js';
import {foldBug499Call, foldCall} from '../examples/foldCall.js';
import {bugNG69Call, ifCall, ifWrapCall} from '../examples/ifCall.js';
import {parCall, testTimeoutCall} from '../examples/parCall.js';
import {complexCall} from '../examples/complex.js';
import {constantsCall, particleTtlAndTimestampCall} from '../examples/constantsCall.js';
import {
nilLengthCall,
nilLiteralCall,
returnNilCall,
returnNoneCall, streamAssignmentCall,
streamCall,
streamFunctorCall, streamIntFunctorCall, streamJoinCall,
streamReturnFromInnerFunc
} from '../examples/streamCall.js';
import {topologyBug205Call, topologyBug394Call, topologyBug427Call, topologyCall} from '../examples/topologyCall.js';
import {foldJoinCall} from '../examples/foldJoinCall.js';
import {registerHandlers, returnNull, returnOptionalCall, useOptionalCall} from '../examples/useOptionalCall.js';
import {viaArrCall, viaOptCall, viaOptNullCall, viaStreamCall} from '../examples/viaCall.js';
import {nestedFuncsCall} from '../examples/nestedFuncsCall.js';
import {assignmentCall} from '../examples/assignment.js';
import {tryCatchCall} from '../examples/tryCatchCall.js';
import {tryOtherwiseCall} from '../examples/tryOtherwiseCall.js';
import {coCall} from '../examples/coCall.js';
import {bugLNG60Call, passArgsCall} from '../examples/passArgsCall.js';
import {streamArgsCall} from '../examples/streamArgsCall.js';
import {streamResultsCall} from '../examples/streamResultsCall.js';
import {pushToStreamCall} from '../examples/pushToStreamCall.js';
import {literalCall} from '../examples/returnLiteralCall.js';
import {multiReturnCall} from '../examples/multiReturnCall.js';
import {declareCall} from '../examples/declareCall.js';
import {genOptions, genOptionsEmptyString} from '../examples/optionsCall.js';
import { lng193BugCall } from '../examples/closureReturnRename.js';
import {closuresCall} from '../examples/closures.js';
import {bugLNG63_2Call, bugLNG63_3Call, bugLNG63Call, streamCanCall} from '../examples/streamCanCall.js';
import {streamCallbackCall} from '../examples/streamCallback.js';
import {streamResCall} from '../examples/streamRestrictionsCall.js';
import {joinIdxCall, joinIdxLocalCall, joinIdxRelayCall} from '../examples/joinCall.js';
import {recursiveStreamsCall} from '../examples/recursiveStreamsCall.js';
import {
arraySugarCall,
bugLNG59Call,
optionSugarCall,
streamSugarCall,
} from '../examples/collectionSugarCall.js';
import {funcsCall} from '../examples/funcsCall.js';
import {nestedDataCall} from '../examples/nestedDataCall.js';
import {mathTest1Call, mathTest2Call} from '../examples/mathCall.js';
import {lng58Bug} from '../compiled/examples/closures.js';
import {config, isEphemeral} from '../config.js';
import {bugLng79Call} from "../examples/canonCall.js";
import {bugLng119Call} from "../examples/functorsCall.js";
import {returnArrowCall, returnArrowChainCall} from "../examples/returnArrowCall.js";
var selfPeerId: string;
var peer1: IFluenceClient;
var peer2: IFluenceClient;
export const relay1 = config.relays[0]
const relayPeerId1 = relay1.peerId
export const relay2 = config.relays[1]
const relayPeerId2 = relay2.peerId
import log from 'loglevel';
// log.setDefaultLevel("debug")
async function start() {
console.log("CONNECTING TO FIRST:")
Fluence.onConnectionStateChange((s) => {
console.log(s)
})
await Fluence.connect(relay1)
const cl = await Fluence.getClient();
peer1 = cl;
selfPeerId = cl.getPeerId()
console.log("CONNECTED")
peer2 = await createClient(relay2)
console.log("CONNECTING TO SECOND:")
peer2.onConnectionStateChange((s) => {
console.log(s)
})
await peer2.connect()
console.log("CONNECTED")
}
async function stop() {
await Fluence.disconnect();
if (peer2) {
await peer2.disconnect();
}
}
describe('Testing examples', () => {
beforeAll(async () => {
await start();
// this could be called from `println.aqua`
registerPrintln({
print: (arg0) => {
console.dir(arg0);
},
});
}, 12000);
afterAll(async () => {
await stop();
});
it('callArrow.aqua args bug 426', async () => {
let argResult = await reproArgsBug426Call();
expect(argResult).toBe('privet');
});
it('returnArrow.aqua', async () => {
let [result1, result2] = await returnArrowCall();
expect(result1).toBe('arg for closure ');
expect(result2).toBe('arg for closure arg for func literal');
});
it('returnArrow.aqua chain', async () => {
let argResult = await returnArrowChainCall();
expect(argResult).toStrictEqual(
["first", "firstarg for func1 literal",
"second", "secondarg for func2 second literal",
"third", "thirdarg for func2 second literal",
"fourth", "fourth from second literal"
]);
});
it('streamRestrictions.aqua', async () => {
let streamResResult = await streamResCall();
expect(streamResResult).toEqual([[], ['a', 'b', 'c']]);
});
it('if.aqua', async () => {
await ifCall();
});
it('if.aqua xor wrap', async () => {
let res = await ifWrapCall(relay2.peerId);
expect(res).toBe('1x');
});
it('if.aqua bug LNG-69', async () => {
let res = await bugNG69Call(relay2.peerId);
expect(res).toBe(true);
});
it('helloWorld.aqua', async () => {
let helloWorldResult = await helloWorldCall();
expect(helloWorldResult).toBe('Hello, NAME!');
});
it('func.aqua', async () => {
let funcCallResult = await funcCall();
expect(funcCallResult).toBe('some str');
});
it('dataAlias.aqua', async () => {
let dataAliasResult = await dataAliasCall();
expect(dataAliasResult).toBe('peer id str');
});
it('constants.aqua', async () => {
let constantCallResult = await constantsCall();
expect(constantCallResult).toEqual(['1', 'ab']);
});
it('PARTICLE_TTL and PARTICLE_TIMESTAMP', async () => {
const ttl = 1234;
let result = await particleTtlAndTimestampCall(ttl);
expect(result[1]).toBeDefined();
expect(result[0]).toEqual(ttl);
});
it('stream.aqua return stream from inner func', async () => {
let streamResult = await streamReturnFromInnerFunc()
expect(streamResult).toEqual([1, 2, 3, 4]);
})
it('stream.aqua functor', async () => {
let streamResult = await streamFunctorCall()
expect(streamResult).toEqual("123");
})
it('stream.aqua assignment', async () => {
let streamResult = await streamAssignmentCall()
expect(streamResult).toEqual("333");
})
it('stream.aqua nil literal', async () => {
let result = await nilLiteralCall()
expect(result).toEqual([]);
})
it('collectionSugar array', async () => {
let result = await arraySugarCall();
expect(result).toEqual([
[1, 2, 3],
[4, 5, 6],
]);
});
it('object creation getObj', async () => {
let result = await getObjCall()
expect(result).toEqual({
str: "some str",
num: 5,
inner: {
arr: ["a", "b", "c"],
num: 6
}
});
});
it('object creation getObjAssign', async () => {
let result = await getObjAssignCall()
expect(result).toEqual([{
str: "first str",
num: 5,
inner: {
arr: ["d", "e", "f"],
num: 7
}
}, {
str: "some str",
num: 6,
inner: {
arr: ["a", "b", "c"],
num: 7
}
},
1]);
});
it('collectionSugar stream', async () => {
let result = await streamSugarCall();
expect(result).toEqual([
[1, 2, 3],
[4, 5, 6],
]);
});
it('update bug collectionSugar option', async () => {
let result = await optionSugarCall();
expect(result).toEqual([[1], ['some'], []]);
});
it('math.aqua test 1', async () => {
let res = await mathTest1Call();
expect(res).toEqual(-10);
});
it('math.aqua test 2', async () => {
let res = await mathTest2Call();
expect(res).toEqual(3);
});
it('multiReturn.aqua', async () => {
let multiReturnResult = await multiReturnCall();
expect(multiReturnResult).toEqual([['some-str', 'random-str', 'some-str'], 5, 'some-str', [1, 2], null, 10]);
});
it('option_gen.aqua', async () => {
let optionGenResult = await genOptions();
expect(optionGenResult).toEqual(['none', 'some']);
});
it('option_gen.aqua emptyString', async () => {
let optionGenResult = await genOptionsEmptyString();
expect(optionGenResult).toEqual(null);
});
it('option.aqua', async () => {
registerHandlers();
let optionResult = await useOptionalCall();
let optionalResult = await returnOptionalCall();
let noneResult = await returnNull();
expect(optionResult).toBe('hello');
expect(optionalResult).toBe('optional');
expect(noneResult).toBe(null);
});
it('nestedFuncs.aqua', async () => {
let nestedFuncsResult = await nestedFuncsCall();
expect(nestedFuncsResult).toBe('some-str');
});
it('nestedData.aqua', async () => {
let nestedDataResult = await nestedDataCall();
expect(nestedDataResult).toEqual({
one: {
val: 'hellohello',
},
});
});
it('functors.aqua LNG-119 bug', async () => {
let result = await bugLng119Call();
expect(result).toEqual([1]);
});
it('passArgsCall.aqua', async () => {
let passArgsResult = await passArgsCall();
expect(passArgsResult).toBe('client-utilsid');
});
it('passArgsCall.aqua bugLNG60', async () => {
let result = await bugLNG60Call(relayPeerId1);
expect(result).toBe(true);
});
it('streamArgs.aqua', async () => {
let streamArgsResult = await streamArgsCall();
expect(streamArgsResult).toEqual([['peer_id', 'peer_id']]);
});
it('streamResults.aqua', async () => {
let streamResultsResult = await streamResultsCall();
expect(streamResultsResult).toEqual(['new_name', 'new_name', 'new_name']);
});
it('assignment.aqua', async () => {
let assignmentResult = await assignmentCall();
expect(assignmentResult).toEqual(['abc', 'hello']);
});
it('join.aqua local', async () => {
let joinLocalCallResult = await joinIdxLocalCall(relayPeerId1);
expect(joinLocalCallResult.length).toBeGreaterThanOrEqual(2);
});
it('stream.aqua', async () => {
let streamResult = await streamCall();
expect(streamResult).toEqual(['first updated', 'second updated', 'third updated', 'fourth updated']);
// bug LNG-84
let returnNilResult = await returnNilCall();
expect(returnNilResult).toEqual([]);
let returnNoneResult = await returnNoneCall();
expect(returnNoneResult).toBe(null);
});
it('stream.aqua nil length', async () => {
let result = await nilLengthCall()
expect(result).toEqual(0);
})
it('stream.aqua int functor', async () => {
let streamResult = await streamIntFunctorCall()
expect(streamResult).toEqual("123");
})
it('streamCan.aqua LNG-63', async () => {
let result = await bugLNG63Call();
expect(result).toEqual('ok');
});
it('streamCan.aqua LNG-63 2', async () => {
let result = await bugLNG63_2Call();
expect(result).toEqual(['ok', ['ok'], ['ok', 'no', 'ok']]);
});
it('streamCan.aqua LNG-63 3', async () => {
let result = await bugLNG63_3Call();
expect(result).toEqual(['ok', 1, [1, 3, 2]]);
});
it('streamCan.aqua', async () => {
let streamCanResult = await streamCanCall();
expect(streamCanResult).toEqual(['a', 'b', null]);
});
it('streamCallback.aqua', async () => {
let streamCallResult = await streamCallbackCall();
expect(streamCallResult).toEqual([]);
});
it('literalCall.aqua', async () => {
let literalCallResult = await literalCall();
expect(literalCallResult).toBe('some literal');
});
it('pushToStream.aqua', async () => {
let pushToStreamResult = await pushToStreamCall();
expect(pushToStreamResult).toEqual(['hello', 'get_string']);
});
it('declare.aqua', async () => {
let declareResult = await declareCall();
expect(declareResult).toBe('small_foodeclare all barsmall_fooexport_constdeclare_constdeclare_const2');
});
it('fold.aqua bug #499', async () => {
let foldCallResult = await foldBug499Call();
expect(foldCallResult).toEqual([5]);
});
it('stream.aqua join', async () => {
let streamResult = await streamJoinCall()
expect(streamResult).toEqual("444");
})
it('funcs.aqua', async () => {
let result = await funcsCall();
expect(result).toEqual([13, 6, 3, 1]);
}, 7000);
// it('closures.aqua LNG-58 bug', async () => {
// let res = await lng58Bug()
// expect(res).toEqual("ok")
// });
// TODO: uncomment
// it('recursiveStreams.aqua', async () => {
// let [sucList, loopList] = await recursiveStreamsCall();
// console.log(sucList);
// console.log(loopList);
// expect(loopList).toEqual(['yes', 'yes', 'yes', 'yes', 'no']);
// expect(sucList.length).toEqual(5);
// });
it('callArrow.aqua', async () => {
let callArrowResult = await callArrowCall(relayPeerId1);
expect(callArrowResult).toBe('Hello, callArrow call!');
}, 10000);
it('fold.aqua', async () => {
let foldCallResult = await foldCall(relayPeerId1);
expect(foldCallResult).toEqual(config.externalAddressesRelay1);
});
it('par.aqua', async () => {
let parCallResult = await parCall(relayPeerId1);
expect(parCallResult).toBe('hello');
});
it('par.aqua testTimeout', async () => {
let testTimeoutResult = await testTimeoutCall();
expect(testTimeoutResult).toBe('timeout');
});
it('canon bug LNG-79', async () => {
let result = await bugLng79Call(selfPeerId, config.relays[0].peerId);
expect(result).toBe(2);
});
it('on.aqua', async () => {
let onCallResult = await onCall(relayPeerId1);
expect(onCallResult).toEqual(config.externalAddressesRelay1);
});
it('complex.aqua', async () => {
let complexCallResult = await complexCall(selfPeerId, relayPeerId1);
expect(complexCallResult).toEqual(['some str', '3', '1', '4', '1', '1', '3', '2', '4', '2', '2', selfPeerId]);
});
it('object creation getObjRelay', async () => {
let result = await getObjRelayCall()
expect(result).toEqual({
str: "some str",
num: 5,
inner: {
arr: ["a", "b", "c"],
num: 6
}
});
});
it('collectionSugar bug LNG-59', async () => {
let result = await bugLNG59Call([config.relays[2].peerId, config.relays[3].peerId]);
expect(result).toEqual('some str');
});
it('topology.aqua', async () => {
let topologyResult = await topologyCall(peer1, relay1.peerId, peer2, relay2.peerId);
expect(topologyResult).toBe('finish');
});
it('topology.aqua bug 205', async () => {
let topologyResult = await topologyBug205Call(relay1.peerId, relay2.peerId);
const peerId2 = relay2.peerId;
const res: string[] = [peerId2];
expect(topologyResult).toEqual(res);
});
it('topology.aqua bug 427', async () => {
let topologyResult = await topologyBug427Call(relay1.peerId, relay2.peerId);
expect(topologyResult).toEqual(['some string', 'some string']);
});
it('topology.aqua bug 394', async () => {
let topologyResult = await topologyBug394Call(peer1.getPeerId(), relay1.peerId, peer2.getPeerId(), relay2.peerId);
expect(topologyResult).toEqual(selfPeerId);
});
it('foldJoin.aqua', async () => {
let foldJoinResult = await foldJoinCall(relayPeerId1);
expect(foldJoinResult.length).toBeGreaterThanOrEqual(3);
}, 16000);
it('via.aqua', async () => {
let res1 = await viaArrCall();
let res2 = await viaOptCall(relayPeerId1);
let res3 = await viaOptNullCall(relayPeerId1);
let res4 = await viaStreamCall(relayPeerId1);
expect(res1).toEqual(res2);
expect(res2).toEqual(res3);
expect(res3).toEqual(res4);
}, 180000);
it('closureReturnRename.aqua bug LNG-193', async () => {
let result = await lng193BugCall();
expect(result).toEqual((1 + 42) + (2 + 42) + (3 + 42) + (4 + 42))
}, 20000)
it('closures.aqua', async () => {
let closuresResult = await closuresCall();
let res1 = config.externalAddressesRelay2;
let res2 = ['in', config.externalAddressesRelay2[0]];
expect(closuresResult).toEqual(['in', res1, res1, res2]);
}, 20000);
it('tryOtherwise.aqua', async () => {
let tryOtherwiseResult = await tryOtherwiseCall(relayPeerId1);
expect(tryOtherwiseResult).toBe('error');
}, 20000);
it('tryCatch.aqua', async () => {
let tryCatchResult = await tryCatchCall(relayPeerId1);
expect(tryCatchResult).toHaveLength(2);
expect(tryCatchResult[0]).toMatch(config.tryCatchError);
expect(tryCatchResult[1]).toBe(config.externalAddressesRelay1[0]);
}, 20000);
it('coCall.aqua', async () => {
let coCallResult = await coCall();
expect(coCallResult).toEqual(config.externalAddressesRelay1);
}, 60000);
it('join.aqua relay', async () => {
let joinRelayCallResult = await joinIdxRelayCall(relayPeerId1);
expect(joinRelayCallResult.length).toBeGreaterThanOrEqual(2);
}, 30000);
it('join.aqua network', async () => {
let joinCallResult = await joinIdxCall(relayPeerId1);
expect(joinCallResult.length).toBeGreaterThanOrEqual(2);
}, 10000);
});

View File

@ -0,0 +1,102 @@
import {
krasnodar,
stage,
testNet,
} from "@fluencelabs/fluence-network-environment";
import { local } from "./local-nodes.js";
declare global {
namespace NodeJS {
interface ProcessEnv {
FLUENCE_ENV?: string;
}
}
}
function setConfig(env) {
switch (env) {
case "krasnodar":
return { config: krasnodarConfig, isEphemeral: false };
case "testnet":
return { config: testNetConfig, isEphemeral: false };
case "ephemeral":
return { config: null, isEphemeral: true };
case "local":
return { config: localConfig, isEphemeral: false };
default:
return { config: stageConfig, isEphemeral: false };
}
}
export const krasnodarConfig = {
relays: krasnodar,
externalAddressesRelay1: [
"/ip4/164.90.171.139/tcp/7770",
"/ip4/164.90.171.139/tcp/9990/ws",
],
externalAddressesRelay2: [
"/ip4/164.90.164.229/tcp/7001",
"/ip4/164.90.164.229/tcp/9001/ws",
],
tryCatchError:
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
};
export const stageConfig = {
relays: stage,
externalAddressesRelay1: [
"/ip4/134.209.186.43/tcp/7001",
"/ip4/134.209.186.43/tcp/9001/ws",
],
externalAddressesRelay2: [
"/ip4/134.209.186.43/tcp/7770",
"/ip4/134.209.186.43/tcp/9990/ws",
],
tryCatchError:
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
};
export const testNetConfig = {
relays: testNet,
externalAddressesRelay1: [
"/ip4/165.227.164.206/tcp/7001",
"/ip4/165.227.164.206/tcp/9001/ws",
],
externalAddressesRelay2: [
"/ip4/142.93.169.49/tcp/7001",
"/ip4/142.93.169.49/tcp/9001/ws",
],
tryCatchError:
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
};
// export const ephemeralConfig = {
// relays: defaultConfig.peers.map((x) => ({
// peerId: x.peerId,
// multiaddr: "dontcare",
// })),
// externalAddressesRelay1: [],
// externalAddressesRelay2: [],
// tryCatchError:
// "Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
// };
export const localConfig = {
relays: local,
externalAddressesRelay1: [
"/ip4/10.50.10.10/tcp/7771",
"/ip4/10.50.10.10/tcp/9991/ws",
"/dns4/fluence-1/tcp/7771",
"/dns4/fluence-1/tcp/9991/ws",
],
externalAddressesRelay2: [
"/ip4/10.50.10.60/tcp/7776",
"/ip4/10.50.10.60/tcp/9996/ws",
"/dns4/fluence-6/tcp/7776",
"/dns4/fluence-6/tcp/9996/ws",
],
tryCatchError:
"Local service error, ret_code is 1, error message is '\"Service with id 'unex' not found (function getStr)\"'",
};
export const { config, isEphemeral } = setConfig("local");

View File

@ -0,0 +1,5 @@
import { doSmth } from '../compiled/examples/assignment.js';
export async function assignmentCall(): Promise<string[]> {
return await doSmth({ value: 'abc' }, { ttl: 6000 });
}

View File

@ -0,0 +1,22 @@
import { Fluence } from '@fluencelabs/fluence';
import {passFunctionAsArg, reproArgsBug426} from '../compiled/examples/callArrow.js';
export async function callArrowCall(relayPeerId: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
passFunctionAsArg(relayPeerId, 'callArrow call', (a: string) => {
let result = 'Hello, ' + a + '!';
console.log(result)
resolve(result);
return result;
}, {ttl: 10000});
});
}
export async function reproArgsBug426Call(): Promise<string> {
const relayPeerId = Fluence.getPeer().getStatus().relayPeerId;
return new Promise<string>((resolve, reject) => {
reproArgsBug426((a: string) => {
resolve(a);
}, "privet");
});
}

View File

@ -0,0 +1,12 @@
import {bugLng79, registerSer} from "../compiled/examples/canon.js";
export async function bugLng79Call(pid: string, relay: string): Promise<number> {
registerSer({
getRecord: () => {
return {peer_id: pid, relay_id: [relay]};
}
})
return await bugLng79((s) => {
console.log(s)
});
}

View File

@ -0,0 +1,11 @@
import { Fluence } from '@fluencelabs/fluence';
import {
lng193Bug
} from '../compiled/examples/closureReturnRename.js';
import { config } from '../config.js'
const relays = config.relays
export async function lng193BugCall(): Promise<number> {
return lng193Bug(relays[4].peerId, relays[5].peerId)
}

View File

@ -0,0 +1,32 @@
import { Fluence } from '@fluencelabs/fluence';
import {
closureIn,
closureOut,
closureBig,
registerLocalSrv,
closureOut2,
lng58Bug
} from '../compiled/examples/closures.js';
import { config } from '../config.js'
const relays = config.relays
export async function closuresCall(): Promise<[string, string[], string[], [string, string]]> {
registerLocalSrv({inside: () => console.log("call inside")})
console.log("closurein")
const resIn = await closureIn(relays[4].peerId, {ttl: 25000})
console.log("closureout")
const resOut = await closureOut(relays[5].peerId, {ttl: 25000})
console.log("closureout2")
const resOut2 = await closureOut2(relays[5].peerId, {ttl: 25000})
console.log("closurebig")
const resBig = await closureBig(relays[4].peerId, relays[5].peerId, {ttl: 25000})
return [resIn, resOut.external_addresses, resOut2.external_addresses, resBig]
}
export async function lng58CBugCall(): Promise<string> {
return lng58Bug()
}

View File

@ -0,0 +1,18 @@
import { Fluence } from '@fluencelabs/fluence';
import { parFunc } from '../compiled/examples/par.js';
import { registerCoService } from '../compiled/examples/co.js';
import {relay1} from "../__test__/examples.spec.js";
export async function coCall(): Promise<string[]> {
registerCoService({
call: () => {
return 'hello';
},
});
return new Promise<string[]>((resolve, reject) => {
parFunc(relay1.peerId, (c) => {
resolve(c.external_addresses);
}, {ttl: 60000});
});
}

View File

@ -0,0 +1,31 @@
import {
arraySugar,
bugLNG59,
optionSugar,
registerGetArr,
streamSugar
} from "../compiled/examples/collectionSugar.js";
export async function arraySugarCall(): Promise<[number[], number[]]> {
return await arraySugar(3, 6)
}
export async function streamSugarCall(): Promise<[number[], number[]]> {
return await streamSugar(3, 6)
}
export async function optionSugarCall(): Promise<[number[], string[], string[]]> {
return await optionSugar(1, "some", null, null)
}
export async function bugLNG59Call(nodes: string[]): Promise<string> {
registerGetArr({
getArr: () => {
return nodes
}
})
const a = await bugLNG59()
return a
}

View File

@ -0,0 +1,16 @@
import { Fluence } from '@fluencelabs/fluence';
import { doStuff, registerTestS } from '../compiled/examples/complex.js';
export async function complexCall(selfPeerId: string, relayPeerId: string) {
registerTestS({
t: (arg0) => {
return arg0;
},
multiline: (a, b, c) => {
return b;
},
});
return await doStuff(relayPeerId, selfPeerId, true, true, ['1', '2'], ['3', '4'], 'some str');
}

View File

@ -0,0 +1,16 @@
import {callConstant, registerGetter, timestampAndTtl} from '../compiled/examples/constants.js';
export async function constantsCall(): Promise<string[]> {
registerGetter({
createStr: (arg0) => {
return '' + arg0;
},
});
return await callConstant();
}
export async function particleTtlAndTimestampCall(ttl: number): Promise<[number, number]> {
return await timestampAndTtl({ttl: ttl});
}

View File

@ -0,0 +1,15 @@
import { FluencePeer } from '@fluencelabs/fluence';
import { getAliasedData, registerNodeIdGetter } from '../compiled/examples/dataAlias.js';
export async function dataAliasCall() {
registerNodeIdGetter({
get: () => {
return {
peerId: 'peer id str',
name: 'name str',
};
},
});
return await getAliasedData();
}

View File

@ -0,0 +1,23 @@
import { concat_foobars, registerStringService } from '../compiled/examples/imports_exports/imports.js';
import { registerMyExportSrv } from '../compiled/examples/imports_exports/exports.js';
import { registerSuperFoo } from '../compiled/examples/imports_exports/declare.js';
export async function declareCall() {
registerSuperFoo({
small_foo: () => {
return 'small_foo';
},
});
registerStringService({
concat: (a, b) => {
return a + b;
},
});
registerMyExportSrv({
another_str: () => {
return 'str_from_my_export_srv';
},
});
return await concat_foobars();
}

View File

@ -0,0 +1,17 @@
import { Fluence } from '@fluencelabs/fluence';
import {forBug499, iterateAndPrint, iterateAndPrintParallel} from '../compiled/examples/fold.js';
export async function foldCall(relayPeerId: string) {
await iterateAndPrint([relayPeerId], {ttl: 10000});
return new Promise<string[]>((resolve, reject) => {
iterateAndPrintParallel([relayPeerId], (c) => {
console.log('iterateAndPrintParallel. external addresses: ' + c.external_addresses);
resolve(c.external_addresses);
}, {ttl: 10000});
});
}
export async function foldBug499Call(): Promise<number[]> {
return forBug499()
}

View File

@ -0,0 +1,6 @@
import { Fluence } from '@fluencelabs/fluence';
import { getTwoResults } from '../compiled/examples/foldJoin.js';
export async function foldJoinCall(relayPeerId: string): Promise<number[]> {
return await getTwoResults(relayPeerId, {ttl: 16000});
}

View File

@ -0,0 +1,11 @@
import { testFunc, registerTestSrv } from '../compiled/examples/func.js';
export async function funcCall() {
registerTestSrv({
str: () => {
return `some str`;
},
});
return await testFunc();
}

View File

@ -0,0 +1,26 @@
import {main, registerA, calc, calc2, ifCalc} from '../compiled/examples/funcs.js';
export async function funcsCall() {
registerA({
getJ: (n) => {
return n
}
})
let res1 = await main((c, arr) => {
console.log(c + ": " + arr)
})
let res2 = await calc((c, arr) => {
console.log(c + ": " + arr)
})
let res3 = await calc2((c, arr) => {
console.log(c + ": " + arr)
})
let res4 = await ifCalc()
return [res1, res2, res3, res4]
}

View File

@ -0,0 +1,5 @@
import {lng119Bug} from "../compiled/examples/functors.js";
export async function bugLng119Call(): Promise<number[]> {
return lng119Bug();
}

View File

@ -0,0 +1,12 @@
import { helloWorld, registerStringExtra } from '../compiled/examples/helloWorld.js';
export async function helloWorldCall() {
// helloWorld.aqua
registerStringExtra({
addNameToHello: (args0) => {
return `Hello, ${args0}!`;
},
});
return await helloWorld('NAME');
}

View File

@ -0,0 +1,17 @@
import {bugLNG69, ifCorrectXorWrap, ifElseCall, ifElseNumCall} from '../compiled/examples/if.js';
export async function ifCall() {
await ifElseCall(false);
await ifElseCall(true);
await ifElseNumCall(1);
await ifElseNumCall(5);
}
export async function ifWrapCall(node: string) {
return ifCorrectXorWrap(node)
}
export async function bugNG69Call(node: string): Promise<boolean> {
return bugLNG69(node)
}

View File

@ -0,0 +1,19 @@
import { registerOneMore } from '../compiled/examples/imports_exports/gen/OneMore.js';
import { barfoo, wrap } from '../compiled/examples/imports_exports/import2.js';
export async function import2Call() {
registerOneMore('hello', {
more_call: () => {
},
});
registerOneMore('ohmygod', {
more_call: () => {
},
});
let first = await wrap();
let second = await barfoo();
return { first, second };
}

View File

@ -0,0 +1,23 @@
import {Fluence} from '@fluencelabs/fluence';
import {joinIdx, joinIdxLocal, joinIdxRelay} from "../compiled/examples/join.js";
import { config } from '../config.js';
const relays = config.relays
export async function joinIdxCall(relayPeerId: string) {
// join.aqua
return await joinIdx(1, [relayPeerId, relays[2].peerId, relays[4].peerId, relays[5].peerId], {ttl: 10000});
}
export async function joinIdxLocalCall(relayPeerId: string) {
// join.aqua
return await joinIdxLocal(2, [relayPeerId, relays[2].peerId, relays[4].peerId]);
}
export async function joinIdxRelayCall(relayPeerId: string) {
// join.aqua
return await joinIdxRelay(2, [relayPeerId, relays[2].peerId, relays[4].peerId], {ttl: 30000});
}

View File

@ -0,0 +1,9 @@
import {test1, test2} from '../compiled/examples/math.js';
export async function mathTest1Call(): Promise<number> {
return await test1();
}
export async function mathTest2Call(): Promise<number> {
return await test2();
}

View File

@ -0,0 +1,17 @@
import { multiReturnFunc, registerGetStr, registerGetNum } from '../compiled/examples/multiReturn.js';
export async function multiReturnCall(): Promise<[string[], number, string, number[], string | null, number]> {
registerGetStr({
retStr: (args0) => {
return args0;
},
});
registerGetNum({
retNum: () => {
return 10;
},
});
return await multiReturnFunc([1, 2], null);
}

View File

@ -0,0 +1,24 @@
import {test, registerTest, TestResult} from '../compiled/examples/nestedData.js';
export async function nestedDataCall(): Promise<TestResult> {
let nested = {
one: {
val: "hello"
}
}
registerTest({
test1: () => {
return nested;
},
test2: (arg1: { val: string; }, arg2: string) => {
let res = {
one: {
val: (arg1.val + arg2)
}
}
return res
}
});
return await test();
}

View File

@ -0,0 +1,11 @@
import { d, registerOpH } from '../compiled/examples/nestedFuncs.js';
export async function nestedFuncsCall(): Promise<string> {
registerOpH({
identity: (args0) => {
return args0;
},
});
return await d('some-str');
}

View File

@ -0,0 +1,13 @@
import {getObj, getObjAssign, getObjRelay} from "../compiled/examples/object.js";
export async function getObjCall() {
return await getObj();
}
export async function getObjRelayCall() {
return await getObjRelay();
}
export async function getObjAssignCall() {
return await getObjAssign();
}

View File

@ -0,0 +1,6 @@
import { Fluence } from '@fluencelabs/fluence';
import { getPeerExternalAddresses } from '../compiled/examples/on.js';
export async function onCall(relayPeerId: string): Promise<string[]> {
return await getPeerExternalAddresses(relayPeerId);
}

View File

@ -0,0 +1,21 @@
import {checkEmpty, checkNoneEmpty, emptyString, registerOptionString} from "../compiled/examples/options/option_gen.js";
export async function genOptions(): Promise<[string, string]> {
registerOptionString({
checkOption: (str: string | null) => {
if (str) {
return "some"
} else {
return "none"
}
}
})
const a = await checkEmpty();
const b = await checkNoneEmpty("some_string");
return [a, b]
}
export async function genOptionsEmptyString(): Promise<string | null> {
return await emptyString();
}

View File

@ -0,0 +1,28 @@
import { Fluence } from '@fluencelabs/fluence';
import {parFunc, registerParService, testTimeout} from '../compiled/examples/par.js';
import {config} from "../config.js";
export async function parCall(relayPeerId: string) {
let promise = new Promise<string>((resolve, reject) => {
registerParService({
call: () => {
console.log('hello from parservice-id');
let result = 'hello';
resolve(result);
return result;
},
});
});
await parFunc(relayPeerId, (c) => {
console.log('parFunc. external addresses par: ' + c.external_addresses);
});
return promise;
}
const relays = config.relays
export async function testTimeoutCall() {
return testTimeout([relays[3].peerId, relays[4].peerId])
}

View File

@ -0,0 +1,16 @@
import { Fluence } from '@fluencelabs/fluence';
import {bugLNG60, create_client_util, registerAquaDHT} from '../compiled/examples/passArgs.js';
export async function passArgsCall() {
registerAquaDHT({
put_host_value: (args0, args1) => {
return args0 + args1;
},
});
return await create_client_util('sid');
}
export async function bugLNG60Call(relayPeerId: string): Promise<boolean> {
return bugLNG60(relayPeerId, {ttl: 10000})
}

View File

@ -0,0 +1,11 @@
import { get_results, registerOpA } from '../compiled/examples/pushToStream.js';
export async function pushToStreamCall() {
registerOpA({
get_str: () => {
return 'get_string';
},
});
return await get_results();
}

View File

@ -0,0 +1,20 @@
import {recursiveStream, registerYesNoService} from "../compiled/examples/recursiveStreams.js";
export async function recursiveStreamsCall(): Promise<[string[], string[]]> {
let i = 0;
registerYesNoService({
get: () => {
i++;
if (i > 3) {
console.log("return no")
return "no"
} else {
console.log("return yes")
return "yes"
}
}
})
return await recursiveStream()
}

View File

@ -0,0 +1,9 @@
import {callReturnedArrow, callReturnedChainArrow} from "../compiled/examples/returnArrow.js";
export async function returnArrowCall(): Promise<[string, string]> {
return await callReturnedArrow("arg for func ", "arg for closure ")
}
export async function returnArrowChainCall(): Promise<[string, string, string, string, string, string, string, string]> {
return await callReturnedChainArrow("arg for func1 ", "arg for func2 ")
}

View File

@ -0,0 +1,5 @@
import { returnLiteral } from '../compiled/examples/returnLiteral.js';
export async function literalCall() {
return returnLiteral();
}

Some files were not shown because too many files have changed in this diff Show More