mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
tmp
This commit is contained in:
parent
fb1fc409ff
commit
6948fe11b6
10
packages/fluence-js/aqua/tests/shit.aqua
Normal file
10
packages/fluence-js/aqua/tests/shit.aqua
Normal file
@ -0,0 +1,10 @@
|
||||
service Peer("peer"):
|
||||
-- Blocks for the given number of milliseconds. Meant to be used within `par` blocks.
|
||||
-- message is returned after duration has passed
|
||||
timeout(duration_ms: u64, message: string) -> string
|
||||
|
||||
|
||||
func test(time: u8) -> string:
|
||||
on HOST_PEER_ID:
|
||||
Peer.timeout(time, "")
|
||||
<- "success"
|
139
packages/fluence-js/src/__test__/_aqua/shit.ts
Normal file
139
packages/fluence-js/src/__test__/_aqua/shit.ts
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
*
|
||||
* 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.7.2-314
|
||||
*
|
||||
*/
|
||||
import { Fluence, FluencePeer } from '../../index';
|
||||
import { CallParams, callFunction, registerService } from '../../internal/compilerSupport/v3';
|
||||
|
||||
|
||||
// Services
|
||||
|
||||
export interface PeerDef {
|
||||
timeout: (duration_ms: number, message: string, callParams: CallParams<'duration_ms' | 'message'>) => string | Promise<string>;
|
||||
}
|
||||
export function registerPeer(service: PeerDef): void;
|
||||
export function registerPeer(serviceId: string, service: PeerDef): void;
|
||||
export function registerPeer(peer: FluencePeer, service: PeerDef): void;
|
||||
export function registerPeer(peer: FluencePeer, serviceId: string, service: PeerDef): void;
|
||||
|
||||
|
||||
export function registerPeer(...args: any) {
|
||||
registerService(
|
||||
args,
|
||||
{
|
||||
"defaultServiceId" : "peer",
|
||||
"functions" : {
|
||||
"tag" : "labeledProduct",
|
||||
"fields" : {
|
||||
"timeout" : {
|
||||
"tag" : "arrow",
|
||||
"domain" : {
|
||||
"tag" : "labeledProduct",
|
||||
"fields" : {
|
||||
"duration_ms" : {
|
||||
"tag" : "scalar",
|
||||
"name" : "u64"
|
||||
},
|
||||
"message" : {
|
||||
"tag" : "scalar",
|
||||
"name" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codomain" : {
|
||||
"tag" : "unlabeledProduct",
|
||||
"items" : [
|
||||
{
|
||||
"tag" : "scalar",
|
||||
"name" : "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
|
||||
export function test(
|
||||
time: number,
|
||||
config?: {ttl?: number}
|
||||
): Promise<string>;
|
||||
|
||||
export function test(
|
||||
peer: FluencePeer,
|
||||
time: number,
|
||||
config?: {ttl?: number}
|
||||
): Promise<string>;
|
||||
|
||||
export function test(...args: any) {
|
||||
|
||||
let script = `
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "time") [] time)
|
||||
)
|
||||
(xor
|
||||
|
||||
(call -relay- ("peer" "timeout") [time ""])
|
||||
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
(xor
|
||||
(call %init_peer_id% ("callbackSrv" "response") ["success"])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
`
|
||||
return callFunction(
|
||||
args,
|
||||
{
|
||||
"functionName" : "test",
|
||||
"arrow" : {
|
||||
"tag" : "arrow",
|
||||
"domain" : {
|
||||
"tag" : "labeledProduct",
|
||||
"fields" : {
|
||||
"time" : {
|
||||
"tag" : "scalar",
|
||||
"name" : "u8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codomain" : {
|
||||
"tag" : "unlabeledProduct",
|
||||
"items" : [
|
||||
{
|
||||
"tag" : "scalar",
|
||||
"name" : "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"names" : {
|
||||
"relay" : "-relay-",
|
||||
"getDataSrv" : "getDataSrv",
|
||||
"callbackSrv" : "callbackSrv",
|
||||
"responseSrv" : "callbackSrv",
|
||||
"responseFnName" : "response",
|
||||
"errorHandlingSrv" : "errorHandlingSrv",
|
||||
"errorFnName" : "error"
|
||||
}
|
||||
},
|
||||
script
|
||||
)
|
||||
}
|
28
packages/fluence-js/src/__test__/integration/temp.spec.ts
Normal file
28
packages/fluence-js/src/__test__/integration/temp.spec.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { FluencePeer } from '../../index';
|
||||
import { test } from '../_aqua/shit';
|
||||
|
||||
let peer: FluencePeer;
|
||||
|
||||
describe('Test test', () => {
|
||||
afterEach(async () => {
|
||||
if (peer) {
|
||||
await peer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
peer = new FluencePeer();
|
||||
await peer.start({
|
||||
connectTo: '/dns4/stage.fluence.dev/tcp/19002/wss/p2p/12D3KooWMigkP4jkVyufq5JnDJL6nXvyjeaDNpRfEZqQhsG3sYCU'
|
||||
});
|
||||
});
|
||||
|
||||
it('shit', async () => {
|
||||
const res = await test(peer, 1, {ttl: 5000})
|
||||
|
||||
expect(res).toBe(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user