mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-07-03 09:11:55 +00:00
improve config to test different environments easily
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import { Fluence, FluencePeer, setLogLevel } from '@fluencelabs/fluence';
|
||||
import { krasnodar, testNet } from '@fluencelabs/fluence-network-environment';
|
||||
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
import { registerPrintln } from '../compiled/examples/println';
|
||||
import { callArrowCall } from '../examples/callArrowCall';
|
||||
import { dataAliasCall } from '../examples/dataAliasCall';
|
||||
@ -29,7 +28,7 @@ import { literalCall } from '../examples/returnLiteralCall';
|
||||
import { multiReturnCall } from '../examples/multiReturnCall';
|
||||
import { declareCall } from '../examples/declareCall';
|
||||
import { genOptions } from '../examples/optionsCall';
|
||||
import { relays } from '../config';
|
||||
import { config } from '../config';
|
||||
import {closuresCall} from "../examples/closures";
|
||||
import {streamCanCall} from "../examples/streamCan";
|
||||
import {streamCallbackCall} from "../examples/streamCallback";
|
||||
@ -37,6 +36,9 @@ import {streamCallbackCall} from "../examples/streamCallback";
|
||||
var selfPeerId: string;
|
||||
var peer2: FluencePeer;
|
||||
|
||||
|
||||
const relays = config.relays
|
||||
|
||||
// setLogLevel('trace');
|
||||
|
||||
describe('Testing examples', () => {
|
||||
@ -70,7 +72,7 @@ describe('Testing examples', () => {
|
||||
|
||||
it('fold.aqua', async () => {
|
||||
let foldCallResult = await foldCall();
|
||||
expect(foldCallResult).toStrictEqual(['/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws']);
|
||||
expect(foldCallResult).toStrictEqual(config.externalAddressesRelay1);
|
||||
});
|
||||
|
||||
it('if.aqua', async () => {
|
||||
@ -94,7 +96,7 @@ describe('Testing examples', () => {
|
||||
|
||||
it('on.aqua', async () => {
|
||||
let onCallResult = await onCall();
|
||||
expect(onCallResult).toStrictEqual(['/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws']);
|
||||
expect(onCallResult).toStrictEqual(config.externalAddressesRelay1);
|
||||
});
|
||||
|
||||
it('dataAlias.aqua', async () => {
|
||||
@ -185,8 +187,8 @@ describe('Testing examples', () => {
|
||||
|
||||
it('closures.aqua', async () => {
|
||||
let closuresResult = await closuresCall();
|
||||
let res1 = ["/ip4/164.90.164.229/tcp/7001", "/ip4/164.90.164.229/tcp/9001/ws"]
|
||||
let res2 = ["in", "/ip4/164.90.164.229/tcp/7001"]
|
||||
let res1 = config.externalAddressesRelay2
|
||||
let res2 = ["in", config.externalAddressesRelay2[0]]
|
||||
expect(closuresResult).toStrictEqual(["in", res1, res2]);
|
||||
});
|
||||
|
||||
@ -203,13 +205,13 @@ describe('Testing examples', () => {
|
||||
it('tryCatch.aqua', async () => {
|
||||
let tryCatchResult = await tryCatchCall();
|
||||
expect(tryCatchResult).toHaveLength(2);
|
||||
expect(tryCatchResult[0]).toMatch("Error: Service with id 'unex' not found");
|
||||
expect(tryCatchResult[1]).toBe('/ip4/164.90.171.139/tcp/7770');
|
||||
expect(tryCatchResult[0]).toMatch(config.tryCatchError);
|
||||
expect(tryCatchResult[1]).toBe(config.externalAddressesRelay1[0]);
|
||||
});
|
||||
|
||||
it('coCall.aqua', async () => {
|
||||
let coCallResult = await coCall();
|
||||
expect(coCallResult).toStrictEqual(['/ip4/164.90.171.139/tcp/7770', '/ip4/164.90.171.139/tcp/9990/ws']);
|
||||
expect(coCallResult).toStrictEqual(config.externalAddressesRelay1);
|
||||
});
|
||||
|
||||
it('passArgsCall.aqua', async () => {
|
||||
|
@ -1,4 +1,25 @@
|
||||
import { krasnodar, testNet } from '@fluencelabs/fluence-network-environment';
|
||||
import {krasnodar, stage, testNet} from '@fluencelabs/fluence-network-environment';
|
||||
|
||||
export const relays = krasnodar;
|
||||
// export const relays = testNet;
|
||||
|
||||
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: "Error: Service with id 'unex' not found"
|
||||
}
|
||||
|
||||
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: "Error: Service with id 'unex' not found"
|
||||
}
|
||||
|
||||
export const testNetConfig = {
|
||||
relays: testNet,
|
||||
externalAddressesRelay1: ["/ip4/165.227.164.206/tcp/7001", "/ip4/165.227.164.206/tcp/9001/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 config = krasnodarConfig
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Fluence } from '@fluencelabs/fluence';
|
||||
import { closureIn, closureOut, closureBig, registerLocalSrv } from '../compiled/examples/closures';
|
||||
import { relays } from '../config'
|
||||
import { config } from '../config'
|
||||
|
||||
const relays = config.relays
|
||||
|
||||
export async function closuresCall(): Promise<[string, string[], [string, string]]> {
|
||||
const relayPeerId = Fluence.getPeer().getStatus().relayPeerId;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Fluence } from '@fluencelabs/fluence';
|
||||
import { viaArr, viaOpt, viaStream, registerCustomId } from '../compiled/examples/via';
|
||||
import { relays } from '../config';
|
||||
import { config } from '../config';
|
||||
|
||||
const relays = config.relays
|
||||
|
||||
export async function viaCall(): Promise<string[][]> {
|
||||
const relayPeerId = Fluence.getPeer().getStatus().relayPeerId;
|
||||
|
Reference in New Issue
Block a user