smoke test (WIP)

This commit is contained in:
Pavel Murygin 2023-02-07 22:30:07 +04:00
parent ae546ce328
commit e33112271c
11 changed files with 6789 additions and 34 deletions

View File

@ -14,6 +14,8 @@
"dependencies": {},
"devDependencies": {
"ts-node": "10.9.1",
"typescript": "4.7"
"typescript": "4.7",
"@fluencelabs/aqua-lib": "0.6.0",
"@fluencelabs/aqua": "0.9.1-374"
}
}

View File

@ -0,0 +1,11 @@
service Peer("peer"):
-- Get information about the peer
identify() -> Info
-- Get Unix timestamp in milliseconds
timestamp_ms() -> u64
func getRelayTime(relayPeerId: PeerId) -> u64:
on relayPeerId:
ts <- Peer.timestamp_ms()
<- ts

21
packages/@tests/smoke_web/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
dist
# Dependency directories
node_modules/
jspm_packages/
.idea
public/js-client.min.js

View File

@ -0,0 +1,29 @@
{
"name": "@tests/smoke_web",
"version": "0.1.0",
"description": "Smoke test web",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
"node": ">=10",
"pnpm": ">=3"
},
"scripts": {
"build": "tsc",
"compile-aqua": "aqua -i ../aqua/ -o ./src/_aqua",
"serve": "http-server public",
"copy-script": "cp ../../client/js-client.web.standalone/dist/js-client.min.js ./public"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client.api": "workspace:*",
"@fluencelabs/fluence-network-environment": "1.0.13"
},
"devDependencies": {
"@fluencelabs/js-peer": "workspace:*",
"@fluencelabs/aqua": "0.9.1-374",
"http-server": "14.1.1"
}
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Smoke test for web</title>
<script src="./js-client.min.js" async></script>
</head>
<body>
<main>
<h1>Open console f12</h1>
</main>
<script src="../src/index.ts" type="module"></script>
</body>
</html>

View File

@ -0,0 +1,16 @@
import { Fluence } from '@fluencelabs/js-client.api';
const relay = {
multiaddr: '/ip4/127.0.0.1/tcp/4310/ws/p2p/12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3',
peerId: '12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3',
};
const main = async () => {
await Fluence.start({
connectTo: relay,
});
};
main()
.then(() => console.log('done!'))
.catch((err) => console.error('error: ', err));

View File

@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"moduleResolution": "node"
},
"exclude": ["node_modules", "dist"]
}

View File

@ -1,7 +1,7 @@
{
"name": "@fluencelabs/js-client.web.standalone",
"name": "@fluencelabs/js-client.api",
"version": "0.1.0",
"description": "TypeScript implementation of Fluence Peer",
"description": "JS Client API",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"engines": {
@ -9,14 +9,20 @@
"pnpm": ">=3"
},
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"build": "node --loader ts-node/esm ./build.ts"
"build": "tsc"
},
"repository": "https://github.com/fluencelabs/fluence-js",
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"dependencies": {},
"devDependencies": {
"@fluencelabs/js-peer": "workspace:*"
},
"devDependencies": {}
}
}

View File

@ -10,12 +10,10 @@ const REJECT_MESSAGE = "Couldn't load the peer. Please try this and this or refe
/**
* Wait until the js client script it loaded and return the default peer from globalThis
* @returns
*/
const getDefaultPeer = (): Promise<IFluencePeer> => {
// @ts-ignore
export const getDefaultPeer = (): Promise<IFluencePeer> => {
return new Promise((resolve, reject) => {
let interval: any;
let interval: NodeJS.Timer | undefined;
let hits = 20;
interval = setInterval(() => {
if (hits === 0) {

View File

@ -32,8 +32,5 @@
"vite-plugin-replace": "0.1.1",
"vite": "4.0.4",
"vite-tsconfig-paths": "4.0.3"
},
"peerDependencies": {
"esbuild": "0.16.7"
}
}

6687
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff