add new test for streams

This commit is contained in:
DieMyst
2022-10-20 18:51:13 +03:00
parent 7f3ce497de
commit b6109fc22f
3 changed files with 29 additions and 10 deletions

View File

@ -1,3 +1,5 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
service Stringer("stringer-id"):
returnString: string -> string
@ -9,18 +11,26 @@ func checkStreams(ch: []string) -> []string:
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
valueNil: *string
<- valueNil
func returnNil() -> *string:
relayNil <- stringNil()
<- relayNil
relayNil <- stringNil()
<- relayNil
func stringNone() -> ?string:
valueNone: ?string
<- valueNone
valueNone: ?string
<- valueNone
func returnNone() -> ?string:
relayNone <- stringNone()
<- relayNone
relayNone <- stringNone()
<- relayNone

View File

@ -13,7 +13,7 @@ import { bugNG69Call, ifCall, ifWrapCall } from '../examples/ifCall';
import { parCall, testTimeoutCall } from '../examples/parCall';
import { complexCall } from '../examples/complex';
import { constantsCall, particleTtlAndTimestampCall } from '../examples/constantsCall';
import { returnNilCall, returnNoneCall, streamCall } from '../examples/streamCall';
import {returnNilCall, returnNoneCall, streamCall, streamReturnFromInnerFunc} from '../examples/streamCall';
import { topologyBug205Call, topologyBug394Call, topologyBug427Call, topologyCall } from '../examples/topologyCall';
import { foldJoinCall } from '../examples/foldJoinCall';
import { registerHandlers, returnNull, returnOptionalCall, useOptionalCall } from '../examples/useOptionalCall';
@ -231,6 +231,11 @@ describe('Testing examples', () => {
expect(returnNoneResult).toBe(null);
});
it('stream.aqua return stream from inner func', async () => {
let streamResult = await streamReturnFromInnerFunc()
expect(streamResult).toEqual([1, 2, 3, 4]);
})
it('streamCan.aqua', async () => {
let streamCanResult = await streamCanCall();
expect(streamCanResult).toEqual(['a', 'b', null]);

View File

@ -1,5 +1,5 @@
import { FluencePeer } from '@fluencelabs/fluence';
import {checkStreams, registerStringer, stringNil, stringNone} from '../compiled/examples/stream';
import {checkStreams, registerStringer, returnStreamFromFunc, stringNil, stringNone} from '../compiled/examples/stream';
export async function streamCall() {
registerStringer({
@ -18,3 +18,7 @@ export async function returnNilCall() {
export async function returnNoneCall() {
return stringNone()
}
export async function streamReturnFromInnerFunc() {
return await returnStreamFromFunc();
}