Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 109 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,37 @@ on:
description: "git ref to checkout to"
type: string
default: "main"
nox-image:
description: "nox image tag"
type: string
default: "null"
fcli-version:
description: "fcli version to use"
type: string
# default: "unstable"
default: "main"
js-client-version:
description: "@fluencelabs/js-client version"
type: string
default: "null"
fluence-env:
description: "env to run tests against"
type: string
default: "local"

jobs:
tests:
name: "build"
runs-on: ubuntu-latest
name: "Run tests"
runs-on: builder

env:
FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence"
CI: true
# FORCE_COLOR: true

permissions:
contents: read
id-token: write

steps:
- name: Checkout repository
Expand All @@ -20,11 +46,86 @@ jobs:
repository: fluencelabs/frpc
ref: ${{ inputs.ref }}

- name: Install fluence-cli@unstable
run: npm i -g @fluencelabs/cli@0.11.1
- name: Import secrets
uses: hashicorp/vault-action@v2.5.0
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
secrets: |
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ;
kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN ;
kv/ci/frpc chain_urls | RPC_PROVIDERS ;
kv/ci/frpc private_key | FLUENCE_CHAIN_PRIVATE_KEY

- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: docker.fluence.dev
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Setup Rust toolchain
uses: dsherret/rust-toolchain-file@v1

- name: Setup fcli
uses: fluencelabs/setup-fluence@v1
with:
artifact: fcli
version: ${{ inputs.fcli-version }}

- name: Init local env with fcli
run: fluence local init --no-input

- name: Replace nox image in docker-compose
if: inputs.nox-image != 'null'
working-directory: .fluence
run: |
sed -i'' -e '/nox-/!b;n;s|image: fluencelabs/nox:.*$|image: ${{ inputs.nox-image }}|' docker-compose.yaml

- name: Run local env
run: fluence local up

- name: Setup node with self-hosted registry
uses: actions/setup-node@v3
with:
node-version: "18"
registry-url: "https://npm.fluence.dev"
cache: "npm"

- name: Run npm i
run: npm i

- name: Run npm i in gateway
working-directory: gateway
run: npm i

- name: Set js-client version
if: inputs.js-client-version != 'null'
uses: fluencelabs/github-actions/npm-set-dependency@main
with:
package: "@fluencelabs/js-client"
version: "${{ inputs.js-client-version }}"
working-directory: gateway

- name: Run npm run build
run: npm run build

- name: Run tests
env:
FLUENCE_ENV: ${{ inputs.fluence-env }}
run: npm run test -- -t deploy

- name: Check if main.aqua compiles
run: fluence aqua --dry
- name: Dump container logs
if: always()
uses: jwalton/gh-docker-logs@v2

- name: Check if services builds
run: fluence build
- name: Cleanup
if: always()
run: |
fluence local down
rm -rf tmp ${{ env.FLUENCE_USER_DIR }}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ src/js/src/aqua
aqua-compiled

# recommended by Fluence Labs:
/.fluence/project-secrets.yaml
/.fluence/schemas
/.fluence/tmp
.fluence/project-secrets.yaml
.fluence/docker-compose.yaml
.fluence/schemas
.fluence/secrets
.fluence/tmp

# to avoid accidental publish of RPC URLs
gateway/configs/quickstart_config.json
7 changes: 6 additions & 1 deletion fluence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@

# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md

version: 2
version: 4

aquaInputPath: src/aqua/main.aqua

workers:
defaultWorker:
services: [ eth_rpc ]

deals:
defaultWorker:
minWorkers: 3
targetWorkers: 3

relays: stage

services:
eth_rpc:
get: wasm-modules
82 changes: 63 additions & 19 deletions gateway/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@fluencelabs/js-client": "0.3.0",
"@fluencelabs/js-client": "0.4.2",
"@fluencelabs/marine-worker": "0.3.3",
"body-parser": "1.20.2",
"express": "4.18.2",
Expand Down
10 changes: 5 additions & 5 deletions gateway/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function findSameResults(results, minNum) {
if (getMaxRepeated >= minNum) {
console.log(resultCounts);
const max = Object.entries(resultCounts).find(
(kv) => kv[1] === getMaxRepeated
(kv) => kv[1] === getMaxRepeated,
);
return {
value: max[0],
Expand Down Expand Up @@ -132,7 +132,7 @@ async function methodHandler(reqRaw, method) {
req,
counterServiceId,
counterPeerId,
config.serviceId
config.serviceId,
);
} else if (mode === "quorum") {
const quorumResult = await quorumEth(
Expand All @@ -143,14 +143,14 @@ async function methodHandler(reqRaw, method) {
req,
quorumServiceId,
quorumPeerId,
{ ttl: 20000 }
{ ttl: 20000 },
);

if (quorumResult.error) {
console.error(
`quorum failed: ${quorumResult.error}\n${JSON.stringify(
quorumResult.results
)}`
quorumResult.results,
)}`,
);
result = { success: false, error: quorumResult.error };
} else {
Expand Down
39 changes: 39 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2023 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
testEnvironment: "node",
testTimeout: 1000 * 60 * 10, // 10 minutes in milliseconds
projects: [
{
// Uses the serial runner for integration test files
displayName: "INTEGRATION",
runner: "jest-serial-runner",
testMatch: ["<rootDir>/test/**/*.integration-test.ts"],
extensionsToTreatAsEsm: [".ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
tsconfig: "test/tsconfig.json",
},
],
},
},
],
};
Loading