diff --git a/.changeset/beige-parents-wave.md b/.changeset/beige-parents-wave.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/beige-parents-wave.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/workflows/scaling-test-docker-release.yml b/.github/workflows/scaling-test-docker-release.yml deleted file mode 100644 index 7217f8a..0000000 --- a/.github/workflows/scaling-test-docker-release.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build and Push Scaling Tests Docker Images -on: - push: - paths: - - packages/** - - tests/scaling** - - .github/workflows/scaling-test-docker-release.yml - -jobs: - build: - strategy: - matrix: - role: [node, relay] - test-name: ['', peer-discovery, pubsub, large-messages] - - name: Build and Push Scaling Test Docker Image - permissions: write-all - runs-on: ubuntu-latest - - steps: - - name: Checkout the Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Login to Docker Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: rosen-bridge - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker Metadata action - uses: docker/metadata-action@v5 - id: meta - with: - images: ghcr.io/rosen-bridge/scaling${{matrix.test-name && format('-{0}', matrix.test-name)}}-test-${{matrix.role}} - tags: latest - - - name: Build and push ${{matrix.role}} - uses: docker/build-push-action@v4 - with: - context: . - file: tests/scaling${{matrix.test-name && format('-{0}', matrix.test-name)}}/src/${{matrix.role}}/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} diff --git a/package-lock.json b/package-lock.json index a7345fc..e4503e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2438,36 +2438,8 @@ "resolved": "packages/utils", "link": true }, - "node_modules/@rosenet-tests/basic-messaging": { - "resolved": "tests/basic-messaging", - "link": true - }, - "node_modules/@rosenet-tests/scaling": { - "resolved": "tests/scaling", - "link": true - }, - "node_modules/@rosenet-tests/scaling-large-messages": { - "resolved": "tests/scaling-large-messages", - "link": true - }, - "node_modules/@rosenet-tests/scaling-peer-discovery": { - "resolved": "tests/scaling-peer-discovery", - "link": true - }, - "node_modules/@rosenet-tests/scaling-pubsub": { - "resolved": "tests/scaling-pubsub", - "link": true - }, - "node_modules/@rosenet-tests/simple-star": { - "resolved": "tests/simple-star", - "link": true - }, - "node_modules/@rosenet-tests/whitelist-node": { - "resolved": "tests/whitelist-node", - "link": true - }, - "node_modules/@rosenet-tests/whitelist-relay": { - "resolved": "tests/whitelist-relay", + "node_modules/@rosenet-tests/scale": { + "resolved": "tests/scale", "link": true }, "node_modules/@sinclair/typebox": { @@ -9959,6 +9931,27 @@ }, "tests/basic-messaging": { "name": "@rosenet-tests/basic-messaging", + "version": "0.0.0", + "extraneous": true, + "license": "GPL-3.0", + "dependencies": { + "@rosen-bridge/rosenet-node": "^0.0.0", + "@rosen-bridge/rosenet-relay": "^0.0.0" + }, + "devDependencies": { + "@types/node": "^20.11.9", + "@typescript-eslint/eslint-plugin": "^6.19.1", + "@typescript-eslint/parser": "^6.19.1", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "extensionless": "^1.9.6", + "prettier": "^3.2.4", + "ts-node": "^10.7.0", + "tsconfig-paths": "^4.1.2", + "typescript": "^5.3.3" + } + }, + "tests/scale": { "version": "0.0.0", "license": "GPL-3.0", "dependencies": { @@ -9981,6 +9974,7 @@ "tests/scaling": { "name": "@rosenet-tests/scaling", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10002,6 +9996,7 @@ "tests/scaling-large-messages": { "name": "@rosenet-tests/scaling-large-messages", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10023,6 +10018,7 @@ "tests/scaling-peer-discovery": { "name": "@rosenet-tests/scaling-peer-discovery", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10044,6 +10040,7 @@ "tests/scaling-pubsub": { "name": "@rosenet-tests/scaling-pubsub", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10065,6 +10062,7 @@ "tests/simple-star": { "name": "@rosenet-tests/simple-star", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10086,6 +10084,7 @@ "tests/whitelist-node": { "name": "@rosenet-tests/whitelist-node", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", @@ -10107,6 +10106,7 @@ "tests/whitelist-relay": { "name": "@rosenet-tests/whitelist-relay", "version": "0.0.0", + "extraneous": true, "license": "GPL-3.0", "dependencies": { "@rosen-bridge/rosenet-node": "^0.0.0", diff --git a/tests/basic-messaging/.terraform.lock.hcl b/tests/basic-messaging/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/basic-messaging/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/basic-messaging/README.md b/tests/basic-messaging/README.md deleted file mode 100644 index 643f854..0000000 --- a/tests/basic-messaging/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet basic messaging test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet basic messaging test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/basic-messaging/main.tf b/tests/basic-messaging/main.tf deleted file mode 100644 index 3023eff..0000000 --- a/tests/basic-messaging/main.tf +++ /dev/null @@ -1,126 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "node-machine" - host = var.node-host -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - dialer_node_peer_id = "QmaeANgBs1DTSxWSrPPtobgQuxW8XTfsS4ydbK4rCHzqxG" - dialer_node_private_key = "080012ae123082092a0201000282020100e1beab071d08200bde24eef00d049449b07770ff9910257b2d7d5dda242ce8f0e2f12e1af4b32d9efd2c090f66b0f29986dbb645dae9880089704a94e5066d594162ae6ee8892e6ec70701db0a6c445c04778eb3de1293aa1a23c3825b85c6620a2bc3f82f9b0c309bc0ab3aeb1873282bebd3da03c33e76c21e9beb172fd44c9e43be32e2c99827033cf8d0f0c606f4579326c930eb4e854395ad941256542c793902185153c474bed109d6ff5141ebf9cd256cf58893a37f83729f97e7cb435ec679d2e33901d27bb35aa0d7e20561da08885ef0abbf8e2fb48d6a5487047a9ecb1ad41fa7ed84f6e3e8ecd5d98b3982d2a901b4454991766da295ab78822add5612a2df83bcee814cf50973e80d7ef38111b1bd87da2ae92438a2c8cbcc70b31ee319939a3b9c761dbc13b5c086d6b64bf7ae7dacc14622375d92a8ff9af7eb962162bbddebf90acb32adb5e4e4029f1c96019949ecfbfeffd7ac1e3fbcc6b6168c34be3d5a2e5999fcbb39bba7adbca78eab09b9bc39f7fa4b93411f4cc175e70c0a083e96bfaefb04a9580b4753c1738a6a760ae1afd851a1a4bdad231cf56e9284d832483df215a46c1c21bdf0c6cfe951c18f1ee4078c79c13d63edb6e14feaeffabc90ad317e4875fe648101b0864097e998f0ca3025ef9638cd2b0caecd3770ab54a1d9c6ca959b0f5dcbc90caeefc4135baca6fd475224269bbe1b02030100010282020100a472ffa858efd8588ce59ee264b957452f3673acdf5631d7bfd5ba0ef59779c231b0bc838a8b14cae367b6d9ef572c03c7883b0a3c652f5c24c316b1ccfd979f13d0cd7da20c7d34d9ec32dfdc81ee7292167e706d705efde5b8f3edfcba41409e642f8897357df5d320d21c43b33600a7ae4e505db957c1afbc189d73f0b5d972d9aaaeeb232ca20eebd5de6fe7f29d01470354413cc9a0af1154b7af7c1029adcd67c74b4798afeb69e09f2cb387305e73a1b5f450202d54f0ef096fe1bde340219a1194d1ac9026e90b366cce0c59b239d10e4888f52ca1780824d39ae01a6b9f4dd6059191a7f12b2a3d8db3c2868cd4e5a5862b8b625a4197d52c6ac77710116ebd3ced81c4d91ad5fdfbed68312ebce7eea45c1833ca3acf7da2052820eacf5c6b07d086dabeb893391c71417fd8a4b1829ae2cf60d1749d0e25da19530d889461c21da3492a8dc6ccac7de83ac1c2185262c7473c8cc42f547cc9864b02a8073b6aa54a037d8c0de3914784e6205e83d97918b944f11b877b12084c0dd1d36592f8a4f8b8da5bb404c3d2c079b22b6ceabfbcb637c0dbe0201f0909d533f8bf308ada47aee641a012a494d31b54c974e58b87f140258258bb82f31692659db7aa07e17a5b2a0832c24e122d3a8babcc9ee74cbb07d3058bb85b15f6f6b2674aba9fd34367be9782d444335fbed31e3c4086c652597c27104938b47fa10282010100e9fdf843c1550070ca711cb8ff28411466198f0e212511c3186623890c0071bf6561219682fe7dbdfd81176eba7c4faba21614a20721e0fcd63768e6d925688ecc90992059ac89256e0524de90bf3d8a052ce6a9f6adafa712f3107a016e20c80255c9e37d8206d1bc327e06e66eb24288da866b55904fd8b59e6b2ab31bc5eab47e597093c63fab7872102d57b4c589c66077f534a61f5f65127459a33c91f6db61fc431b1ae90be92b4149a3255291baf94304e3efb77b1107b5a3bda911359c40a53c347ff9100baf8f36dc5cd991066b5bdc28b39ed644f404afe9213f4d31c9d4e40f3a5f5e3c39bebeb244e84137544e1a1839c1c8aaebf0c78a7fad590282010100f6fa1f1e6b803742d5490b7441152f500970f46feb0b73a6e4baba2aaf3c0e245ed852fc31d86a8e46eb48e90fac409989dfee45238f97e8f1f8e83a136488c1b04b8a7fb695f37b8616307ff8a8d63e8cfa0b4fb9b9167ffaebabf111aa5a4344afbabd002ae8961c38c02da76a9149abdde93eb389eb32595c29ba30d8283a7885218a5a9d33f7f01dbdf85f3aad016c071395491338ec318d39220e1c7bd69d3d6b520a13a30d745c102b827ad9984b0dd6aed73916ffa82a06c1c111e7047dcd2668f988a0570a71474992eecf416e068f029ec323d5d635fd24694fc9bf96973c255d26c772a95bf8b7f876547a5beabf86f06cd21b67994f944e7a5493028201010095b02fd30069e547426a8bea58e8a2816f33688dac6c6f6974415af8402244a22133baedf34ce499d7036f3f19b38eb00897c18949b0c5a25953c71aeeccfc8f6594173157cc854bd98f16dffe8f28ca13b77eb43a2730585c49fc3f608cd811bb54b03b84bddaa8ef910988567f783012266199667a546a18fd88271fbf63a45ae4fd4884706da8befb9117c0a4d73de5172f8640b1091ed8a4aea3ed4641463f5ff6a5e3401ad7d0c92811f87956d1fd5f9a1d15c7f3839a08698d9f35f9d966e5000f7cb2655d7b6c4adcd8a9d950ea5f61bb7c9a33c17508f9baa313eecfee4ae493249ebe05a5d7770bbd3551b2eeb752e3649e0636de08e3d672e66cb90282010100ad93e4c31072b063fc5ab5fe22afacece775c795d0efdf7c704cfc027bde0d626a7646fc905bb5a80117e3ca49059af14e0160089f9190065be9bfecf12c3b2145b211c8e89e42dd91c38e9aa23ca73697063564f6f6aa6590088a738722df056004d18d7bccac62b3bafef6172fc2a4b071ea37f31eff7a076bcab7dd144e51a9da8754219352aef2c73478971539fa41de4759285ea626fa3c72e7085be47d554d915bbb5149cb6ef835351f231043049cd941506a034bf2f8767f3e1e42ead92f91cb3d75549b57ef7d56ac39c2d80d67f6a2b4ca192974bfc5060e2dd171217971002193dba12e7e4133ab201f07500a90495a38610279b13a48d54f0c99028201003e3a1ac0c2b67d54ed5c4bbe04a7db99103659d33a4f9d35809e1f60c282e5988dddc964527f3b05e6cc890eab3dcb571d66debf3a5527704c87264b3954d7265f4e8d2c637dd89b491b9cf23f264801f804b90454d65af0c4c830d1aef76f597ef61b26ca857ecce9cb78d4f6c2218c00d2975d46c2b013fbf59b750c3b92d8d3ed9e6d1fd0ef1ec091a5c286a3fe2dead292f40f380065731e2079ebb9f2a7ef2c415ecbb488da98f3a12609ca1b6ec8c734032c8bd513292ff842c375d4acd1b02dfb206b24cd815f8e2f9d4af8e7dea0370b19c1b23cc531d78b40e06e1119ee2e08f6f31c6e2e8444c568d13c5d451a291ae0c9f1d4f27d23b3a00d60ad" - listener_node_peer_id = "12D3KooWBtg3aaRMjxwedh83aGiUkwSxDwUZkzuJcfaqUmo7R3pq" - listener_node_private_key = "080112407e0830617c4a7de83925dfb2694556b12936c477a0e1feb2e148ec9da60fee7d1ed1e8fae2c4a144b8be8fd4b47bf3d3b34b871c3cacf6010f0e42d474fce27e" - messages = [for index in range(1000): "Ping#${index}"] -} - -resource "docker_image" "rosenet-node" { - provider = docker.node-machine - - build { - context = "../.." - dockerfile = "./tests/basic-messaging/src/node/Dockerfile" - } - name = "rosenet-node" - - triggers = { - node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) - node_sha1 = filesha1("./src/node/node.ts") - dockerfile_sha1 = filesha1("./src/node/Dockerfile") - } -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - build { - context = "../.." - dockerfile = "./tests/basic-messaging/src/relay/Dockerfile" - } - name = "rosenet-relay" - - triggers = { - relay_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-relay/lib/**") : filesha1(f)])) - relay_sha1 = filesha1("./src/relay/relay.ts") - dockerfile_sha1 = filesha1("./src/relay/Dockerfile") - } -} - -resource "docker_container" "rosenet-dialer" { - provider = docker.node-machine - - name = "dialer" - image = docker_image.rosenet-node.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.dialer_node_private_key}", "MODE=dialer", "LISTENER_PEER_ID=${local.listener_node_peer_id}"] - - depends_on = [docker_container.rosenet-relay] -} - -resource "docker_container" "rosenet-listener" { - provider = docker.node-machine - - name = "listener" - image = docker_image.rosenet-node.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.listener_node_private_key}", "MODE=listener"] - - depends_on = [docker_container.rosenet-relay] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${local.dialer_node_peer_id},${local.listener_node_peer_id}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } - - depends_on = [docker_image.rosenet-node] -} - -data "docker_logs" "dialer-logs" { - provider = docker.node-machine - - name = docker_container.rosenet-dialer.name - follow = true - - lifecycle { - postcondition { - # Check if messages are sent successfully - condition = alltrue([for message in local.messages : strcontains(join("\n", self.logs_list_string), "message: '${message}'")]) - error_message = "Some of the messages were not sent" - } - } -} - -data "docker_logs" "listener-logs" { - provider = docker.node-machine - - name = docker_container.rosenet-listener.name - follow = true - - lifecycle { - postcondition { - # Check if messages are received successfully - condition = alltrue([for message in local.messages : strcontains(join("\n", self.logs_list_string), "${message}")]) - error_message = "Some of the messages were not received" - } - } -} diff --git a/tests/basic-messaging/package.json b/tests/basic-messaging/package.json deleted file mode 100644 index 9f8ed4a..0000000 --- a/tests/basic-messaging/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/basic-messaging", - "private": true, - "version": "0.0.0", - "description": "RoseNet basic messaging test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/basic-messaging/src/node/node.ts b/tests/basic-messaging/src/node/node.ts deleted file mode 100644 index 885cbfd..0000000 --- a/tests/basic-messaging/src/node/node.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -await node.start(); - -const messages = Array.from({ length: 1000 }).map( - (_, index) => `Ping#${index}`, -); - -if (process.env.MODE === 'dialer') { - setTimeout(async () => { - for (const message of messages) { - await node.sendMessage(process.env.LISTENER_PEER_ID!, message); - } - setTimeout(() => { - process.exit(0); - }, 2000); - }, 10000); -} else { - node.handleIncomingMessage((from, message) => { - if (message === messages.at(-1)) { - setTimeout(() => { - process.exit(0); - }, 2000); - } - }); -} - -// This timeout works like a Promise.race, if above process.exit is not called -// for some reason -setTimeout(() => { - process.exit(0); -}, 20000); diff --git a/tests/basic-messaging/src/relay/Dockerfile b/tests/basic-messaging/src/relay/Dockerfile deleted file mode 100644 index c52b234..0000000 --- a/tests/basic-messaging/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/basic-messaging/package.json ./tests/basic-messaging/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/basic-messaging - -CMD npm run start:relay diff --git a/tests/basic-messaging/src/relay/relay.ts b/tests/basic-messaging/src/relay/relay.ts deleted file mode 100644 index c2eeea5..0000000 --- a/tests/basic-messaging/src/relay/relay.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: process.env.WHITELIST!.split(','), -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 25000); diff --git a/tests/basic-messaging/variables.tf b/tests/basic-messaging/variables.tf deleted file mode 100644 index 46dec1a..0000000 --- a/tests/basic-messaging/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "node-host" { - type = string -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/basic-messaging/.eslintignore b/tests/scale/.eslintignore similarity index 100% rename from tests/basic-messaging/.eslintignore rename to tests/scale/.eslintignore diff --git a/tests/scaling-pubsub/.terraform.lock.hcl b/tests/scale/.terraform.lock.hcl similarity index 96% rename from tests/scaling-pubsub/.terraform.lock.hcl rename to tests/scale/.terraform.lock.hcl index f526901..8740f6f 100644 --- a/tests/scaling-pubsub/.terraform.lock.hcl +++ b/tests/scale/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.opentofu.org/kreuzwerker/docker" { version = "3.0.2" constraints = "~> 3.0.1" hashes = [ + "h1:XjdpVL61KtTsuPE8swok3GY8A+Bu3TZs8T2DOEpyiXo=", "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", diff --git a/tests/scaling-large-messages/README.md b/tests/scale/README.md similarity index 100% rename from tests/scaling-large-messages/README.md rename to tests/scale/README.md diff --git a/tests/scaling-peer-discovery/main.tf b/tests/scale/main.tf similarity index 55% rename from tests/scaling-peer-discovery/main.tf rename to tests/scale/main.tf index e0d0d96..7826680 100644 --- a/tests/scaling-peer-discovery/main.tf +++ b/tests/scale/main.tf @@ -52,19 +52,28 @@ provider "docker" { host = var.machines[8] } -provider "docker" { - alias = "machine-9" - host = var.machines[9] -} - provider "docker" { alias = "relay-machine" host = var.relay-host } locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" + relay_peer_ids = [ + "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY", + "16Uiu2HAmHYAbzRwAhGsVoYQs82QQ592iXrLqeyYw73tm6vn3dRLm", + "16Uiu2HAm1xyDuhk6x34CN2LRx3ko7Ya41CiCbzFB625YbWHw9v7M", + "16Uiu2HAm7BwCassbfvHY2SJnPDFWSwczdKQWTxwZH5vM3QnyiYHL", + "16Uiu2HAmJU4Nn69FCsCTUfobPMLz1DtStGijevSFDf62ogCeg4ov", + "16Uiu2HAmTg7rwJ3sxAuCF3wDKoHQg8rXwLwhHBvcABfcnubk41Wa", + ] + relay_private_keys = [ + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB", + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FC", + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FD", + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FE", + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FA", + "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8F0", + ] node_peer_ids = [ "16Uiu2HAkykduGyaTTrv2sbS5VPiM1opuB8nwrLAFFbkcKJo12Rfp", "16Uiu2HAm3BY2vHeracYytkbcr4uZN3uXq8RfaQtFQoTvbNUrBb2f", @@ -149,101 +158,219 @@ locals { "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED838", "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED839", ] -} - -data "docker_registry_image" "rosenet-node" { - name = "ghcr.io/rosen-bridge/scaling-peer-discovery-test-node" -} - -data "docker_registry_image" "rosenet-relay" { - name = "ghcr.io/rosen-bridge/scaling-peer-discovery-test-relay" + node_ports = [ + "40800", + "40801", + "40802", + "40803", + "40804", + "40805", + "40806", + "40807", + "40808", + "40809", + "40810", + "40811", + "40812", + "40813", + "40814", + "40815", + "40816", + "40817", + "40818", + "40819", + "40820", + "40821", + "40822", + "40823", + "40824", + "40825", + "40826", + "40827", + "40828", + "40829", + "40830", + "40831", + "40832", + "40833", + "40834", + "40835", + "40836", + "40837", + "40838", + "40839", + ] } resource "docker_image" "rosenet-node-0" { provider = docker.machine-0 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-1" { provider = docker.machine-1 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-2" { provider = docker.machine-2 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-3" { provider = docker.machine-3 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-4" { provider = docker.machine-4 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-5" { provider = docker.machine-5 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-6" { provider = docker.machine-6 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-7" { provider = docker.machine-7 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" + + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-node-8" { provider = docker.machine-8 - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-9" { - provider = docker.machine-9 + build { + context = "../.." + dockerfile = "./tests/scale/src/node/Dockerfile" + } + name = "rosenet-node" - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] + triggers = { + node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) + node_sha1 = filesha1("./src/node/node.ts") + dockerfile_sha1 = filesha1("./src/node/Dockerfile") + } } resource "docker_image" "rosenet-relay" { provider = docker.relay-machine - name = data.docker_registry_image.rosenet-relay.name - pull_triggers = [data.docker_registry_image.rosenet-relay.sha256_digest] + build { + context = "../.." + dockerfile = "./tests/scale/src/relay/Dockerfile" + } + name = "rosenet-relay" + + triggers = { + relay_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-relay/lib/**") : filesha1(f)])) + relay_sha1 = filesha1("./src/relay/relay.ts") + dockerfile_sha1 = filesha1("./src/relay/Dockerfile") + } } resource "docker_container" "rosenet-node-0" { provider = docker.machine-0 - count = 4 + count = 4 name = "node-${count.index}" image = docker_image.rosenet-node-0.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index]}", "PORT=${local.node_ports[count.index]}"] + depends_on = [ docker_container.rosenet-relay, @@ -256,18 +383,23 @@ resource "docker_container" "rosenet-node-0" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index] + external = local.node_ports[count.index] + } } resource "docker_container" "rosenet-node-1" { + provider = docker.machine-1 - count = 4 + count = 4 name = "node-${count.index + 4}" image = docker_image.rosenet-node-1.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 4]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 4]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 4]}", "PORT=${local.node_ports[count.index + 4]}"] + depends_on = [ docker_container.rosenet-relay, @@ -280,18 +412,21 @@ resource "docker_container" "rosenet-node-1" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 4] + external = local.node_ports[count.index + 4] + } } resource "docker_container" "rosenet-node-2" { provider = docker.machine-2 - count = 4 + count = 4 name = "node-${count.index + 8}" image = docker_image.rosenet-node-2.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 8]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 8]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 8]}", "PORT=${local.node_ports[count.index + 8]}"] depends_on = [ docker_container.rosenet-relay, @@ -304,18 +439,21 @@ resource "docker_container" "rosenet-node-2" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 8] + external = local.node_ports[count.index + 8] + } } resource "docker_container" "rosenet-node-3" { provider = docker.machine-3 - count = 4 + count = 4 name = "node-${count.index + 12}" image = docker_image.rosenet-node-3.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 12]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 12]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 12]}", "PORT=${local.node_ports[count.index + 12]}"] depends_on = [ docker_container.rosenet-relay, @@ -328,18 +466,21 @@ resource "docker_container" "rosenet-node-3" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 12] + external = local.node_ports[count.index + 12] + } } resource "docker_container" "rosenet-node-4" { provider = docker.machine-4 - count = 4 + count = 4 name = "node-${count.index + 16}" image = docker_image.rosenet-node-4.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 16]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 16]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 16]}", "PORT=${local.node_ports[count.index + 16]}"] depends_on = [ docker_container.rosenet-relay, @@ -352,18 +493,21 @@ resource "docker_container" "rosenet-node-4" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 16] + external = local.node_ports[count.index + 16] + } } resource "docker_container" "rosenet-node-5" { provider = docker.machine-5 - count = 4 + count = 5 name = "node-${count.index + 20}" image = docker_image.rosenet-node-5.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 20]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 20]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 20]}", "PORT=${local.node_ports[count.index + 20]}"] depends_on = [ docker_container.rosenet-relay, @@ -376,18 +520,21 @@ resource "docker_container" "rosenet-node-5" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 20] + external = local.node_ports[count.index + 20] + } } resource "docker_container" "rosenet-node-6" { provider = docker.machine-6 - count = 4 + count = 5 - name = "node-${count.index + 24}" + name = "node-${count.index + 25}" image = docker_image.rosenet-node-6.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 24]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 25]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 25]}", "PORT=${local.node_ports[count.index + 25]}"] depends_on = [ docker_container.rosenet-relay, @@ -400,18 +547,21 @@ resource "docker_container" "rosenet-node-6" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 25] + external = local.node_ports[count.index + 25] + } } resource "docker_container" "rosenet-node-7" { provider = docker.machine-7 - count = 4 + count = 5 - name = "node-${count.index + 28}" + name = "node-${count.index + 30}" image = docker_image.rosenet-node-7.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 28]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 30]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 30]}", "PORT=${local.node_ports[count.index + 30]}"] depends_on = [ docker_container.rosenet-relay, @@ -424,18 +574,21 @@ resource "docker_container" "rosenet-node-7" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 30] + external = local.node_ports[count.index + 30] + } } resource "docker_container" "rosenet-node-8" { provider = docker.machine-8 - count = 4 + count = 5 - name = "node-${count.index + 32}" + name = "node-${count.index + 35}" image = docker_image.rosenet-node-8.image_id env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 32]}"] + "RELAY_MULTIADDRS=${join(",", [for i, v in local.relay_peer_ids : "/ip4/${var.relay-ip}/tcp/3333${i + 3}/p2p/${v}"])}", "PRIVATE_KEY=${local.node_private_keys[count.index + 35]}", "ALL_PEER_IDS=${join(",", local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 35]}", "PORT=${local.node_ports[count.index + 35]}"] depends_on = [ docker_container.rosenet-relay, @@ -448,42 +601,29 @@ resource "docker_container" "rosenet-node-8" { docker_image.rosenet-node-6, docker_image.rosenet-node-7, docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-9" { - provider = docker.machine-9 - count = 4 - - name = "node-${count.index + 36}" - image = docker_image.rosenet-node-9.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 36]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, ] + ports { + internal = local.node_ports[count.index + 35] + external = local.node_ports[count.index + 35] + } } resource "docker_container" "rosenet-relay" { provider = docker.relay-machine - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${join(",", local.node_peer_ids)}", "LISTEN_PORT=33333"] + count = 6 + + name = "relay-${count.index}" + image = docker_image.rosenet-relay.image_id + env = [ + "PRIVATE_KEY=${local.relay_private_keys[count.index]}", "WHITELIST=${join(",", concat(local.node_peer_ids, local.relay_peer_ids))}", "LISTEN_PORT=3333${count.index + 3}"] + ports { + internal = 33333 + count.index + external = 33333 + count.index + } ports { - internal = 33333 - external = 33333 + internal = 34333 + count.index + external = 34333 + count.index } + restart = "always" } diff --git a/tests/scaling-large-messages/package.json b/tests/scale/package.json similarity index 95% rename from tests/scaling-large-messages/package.json rename to tests/scale/package.json index db3ad8e..a52fdf8 100644 --- a/tests/scaling-large-messages/package.json +++ b/tests/scale/package.json @@ -1,5 +1,5 @@ { - "name": "@rosenet-tests/scaling-large-messages", + "name": "@rosenet-tests/scale", "private": true, "version": "0.0.0", "description": "RoseNet scaling large messages test", diff --git a/tests/basic-messaging/src/node/Dockerfile b/tests/scale/src/node/Dockerfile similarity index 72% rename from tests/basic-messaging/src/node/Dockerfile rename to tests/scale/src/node/Dockerfile index ff0ea1b..10b7086 100644 --- a/tests/basic-messaging/src/node/Dockerfile +++ b/tests/scale/src/node/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.11 +FROM public.ecr.aws/docker/library/node:20.11 WORKDIR /app @@ -7,12 +7,12 @@ COPY package-lock.json . COPY packages/rosenet-node/package.json ./packages/rosenet-node/ COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ COPY packages/utils/package.json ./packages/utils/ -COPY tests/basic-messaging/package.json ./tests/basic-messaging/ +COPY tests/scale/package.json ./tests/scale/ RUN npm ci COPY . . RUN npm run build -WORKDIR /app/tests/basic-messaging +WORKDIR /app/tests/scale CMD npm run start:node diff --git a/tests/scale/src/node/node.ts b/tests/scale/src/node/node.ts new file mode 100644 index 0000000..31e7a1b --- /dev/null +++ b/tests/scale/src/node/node.ts @@ -0,0 +1,109 @@ +import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; + +const node = await createRoseNetNode({ + logger: console, + relayMultiaddrs: process.env.RELAY_MULTIADDRS!.split(','), + privateKey: process.env.PRIVATE_KEY!, + port: +process.env.PORT!, +}); + +const largeMessage = 'x'.repeat(100_000); + +await node.start(); + +const wait = () => + new Promise((resolve) => { + setTimeout( + resolve, + 5 + + (3000 - Math.random() * 3000 + Math.random() * 6000) * + (Math.random() > 0.1 ? 1 : Math.random() < 0.1 ? 5 : 0.001), + ); + }); + +let sent = 0; +let received = 0; +let totalDelay = 0; +let maxDelay = 0; + +let counter = 0; +const data: Record = {}; + +setTimeout(async () => { + // eslint-disable-next-line no-constant-condition + while (counter <= 20000) { + const currentCounter = counter; + for (let i = 0; i < Math.random() * 30; i++) { + counter++; + if (Math.floor(counter / 50) % 6 === 5) { + console.log('> on a break'); + break; + } + for (const peer of process.env.ALL_PEER_IDS!.split(',')) { + if (peer !== process.env.NODE_PEER_ID! && Math.random() > 0.2) { + node.sendMessage(peer, largeMessage, async (error) => { + if (error) { + console.warn(`🚫 ${currentCounter} -> ${peer.slice(-5)}`); + data[peer.slice(-5)] = { + r: data[peer.slice(-5)]?.r ?? 0, + ss: data[peer.slice(-5)]?.ss ?? 0, + sf: data[peer.slice(-5)]?.sf ? data[peer.slice(-5)]?.sf + 1 : 1, + }; + } else { + console.info(`✅ ${currentCounter} -> ${peer.slice(-5)}`); + data[peer.slice(-5)] = { + r: data[peer.slice(-5)]?.r ?? 0, + ss: data[peer.slice(-5)]?.ss ? data[peer.slice(-5)]?.ss + 1 : 1, + sf: data[peer.slice(-5)]?.sf ?? 0, + }; + } + }); + } + } + + const message = `${largeMessage}.${Date.now().toString()}`; + await node.publish('rosenet-news', message); + sent++; + } + await wait(); + } +}, 30_000); + +node.handleIncomingMessage(async (from) => { + data[from.slice(-5)] = { + r: data[from.slice(-5)]?.r ? data[from.slice(-5)].r + 1 : 1, + ss: data[from.slice(-5)]?.ss ?? 0, + sf: data[from.slice(-5)]?.sf ?? 0, + }; +}); + +node.subscribe('rosenet-news', (message) => { + received++; + const delay = +(Date.now() - +message.split('.')[1]) / 1000; + totalDelay += +(Date.now() - +message.split('.')[1]) / 1000; + maxDelay = Math.max(maxDelay, delay); +}); + +setInterval(() => { + console.table({ + s: sent, + r: received, + avg: (totalDelay / (received || 1)).toFixed(3), + max: maxDelay.toFixed(3), + }); + console.table( + Object.keys(data).reduce( + (acc, cur) => ({ + ...acc, + [cur]: { + ...data[cur], + rate: +( + (data[cur].ss / (data[cur].ss + data[cur].sf || 1)) * + 100 + ).toFixed(2), + }, + }), + {}, + ), + ); +}, 3000); diff --git a/tests/scaling-pubsub/src/relay/Dockerfile b/tests/scale/src/relay/Dockerfile similarity index 72% rename from tests/scaling-pubsub/src/relay/Dockerfile rename to tests/scale/src/relay/Dockerfile index 8b1a249..482b20b 100644 --- a/tests/scaling-pubsub/src/relay/Dockerfile +++ b/tests/scale/src/relay/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.11 +FROM public.ecr.aws/docker/library/node:20.11 WORKDIR /app @@ -7,12 +7,12 @@ COPY package-lock.json . COPY packages/rosenet-node/package.json ./packages/rosenet-node/ COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-pubsub/package.json ./tests/scaling-pubsub/ +COPY tests/scale/package.json ./tests/scale/ RUN npm ci COPY . . RUN npm run build -WORKDIR /app/tests/scaling-pubsub +WORKDIR /app/tests/scale CMD npm run start:relay diff --git a/tests/scaling-peer-discovery/src/relay/relay.ts b/tests/scale/src/relay/relay.ts similarity index 83% rename from tests/scaling-peer-discovery/src/relay/relay.ts rename to tests/scale/src/relay/relay.ts index beb445a..58bf054 100644 --- a/tests/scaling-peer-discovery/src/relay/relay.ts +++ b/tests/scale/src/relay/relay.ts @@ -11,4 +11,5 @@ const node = await createRoseNetRelay({ maxReservations: 40, }); -node.start(); +await node.start(); +node.subscribe('rosenet-news', () => {}); diff --git a/tests/basic-messaging/ts-node-esm-loader.js b/tests/scale/ts-node-esm-loader.js similarity index 100% rename from tests/basic-messaging/ts-node-esm-loader.js rename to tests/scale/ts-node-esm-loader.js diff --git a/tests/basic-messaging/tsconfig.json b/tests/scale/tsconfig.json similarity index 100% rename from tests/basic-messaging/tsconfig.json rename to tests/scale/tsconfig.json diff --git a/tests/scaling-large-messages/variables.tf b/tests/scale/variables.tf similarity index 100% rename from tests/scaling-large-messages/variables.tf rename to tests/scale/variables.tf diff --git a/tests/scaling-large-messages/.eslintignore b/tests/scaling-large-messages/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/scaling-large-messages/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/scaling-large-messages/.terraform.lock.hcl b/tests/scaling-large-messages/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/scaling-large-messages/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/scaling-large-messages/main.tf b/tests/scaling-large-messages/main.tf deleted file mode 100644 index e55450a..0000000 --- a/tests/scaling-large-messages/main.tf +++ /dev/null @@ -1,489 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "machine-0" - host = var.machines[0] -} - -provider "docker" { - alias = "machine-1" - host = var.machines[1] -} - -provider "docker" { - alias = "machine-2" - host = var.machines[2] -} - -provider "docker" { - alias = "machine-3" - host = var.machines[3] -} - -provider "docker" { - alias = "machine-4" - host = var.machines[4] -} - -provider "docker" { - alias = "machine-5" - host = var.machines[5] -} - -provider "docker" { - alias = "machine-6" - host = var.machines[6] -} - -provider "docker" { - alias = "machine-7" - host = var.machines[7] -} - -provider "docker" { - alias = "machine-8" - host = var.machines[8] -} - -provider "docker" { - alias = "machine-9" - host = var.machines[9] -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - node_peer_ids = [ - "16Uiu2HAkykduGyaTTrv2sbS5VPiM1opuB8nwrLAFFbkcKJo12Rfp", - "16Uiu2HAm3BY2vHeracYytkbcr4uZN3uXq8RfaQtFQoTvbNUrBb2f", - "16Uiu2HAm2WNNuTmHNiVK2hYhJu7ZBWmKj7mHNG1aiX5WaXMrZG9n", - "16Uiu2HAmNTC7kpXQbovW1kEtCJ5CDEtAGw2DcZ22SBBvGJS18M7E", - "16Uiu2HAmTH1Rya56bKc84B8YbXFCrjpTra6ApHA92FPRTzkWHVjt", - "16Uiu2HAmQYggzsuCnePKhHMJfRJsZAAauFcrpkZGYuiXfkqueQTy", - "16Uiu2HAm4hsxuSJJHHBKfN1xXSauR1gwWLmvQCVjRkYDAzEvArWr", - "16Uiu2HAmNox2uEXiBhNFDN6ssHMe4b9eBffodaTSQeZzs25sspVY", - "16Uiu2HAmVhSVkyzwZvcHUyY7J7pU5PDFJ4iVC5hHb3A2Hs3uogKn", - "16Uiu2HAm8zG2vtPf2Q4ExhsSZtcCTzTzCxY4F64Vtduc6kHPEdNQ", - "16Uiu2HAmSjon8qun6SANsLP9Rm2SrX1Zmwb3XwVinF1UYH6gobUi", - "16Uiu2HAm4yUHDkxyoXVQpUanR8cLfzXMdSBXNHaBTMvzBKiqkJSD", - "16Uiu2HAmULwMmGM8r9WnAfwcyUQKW5kk7QyG7omihCZLQaxHL3id", - "16Uiu2HAmTXHmJEc6eMNXswSA2zGEjC6mQLimFE4xUHc2vBbbiaie", - "16Uiu2HAkztUutiTKFrjnpy8Bsxxwt8WcUQGJN3wrp562GMokTpfs", - "16Uiu2HAkwA4gJ9191vMaowQb9uRFrJsFKdKvwHkusXARkfZD2m4m", - "16Uiu2HAkvK2ZZSczh3gM7UKLKUtzNywnKz6ZyRpHvarDZCVCdwuu", - "16Uiu2HAmDGo4odJjeNqkA3U5QaNcgAkTiGNxg1n7N5vhe4GihcTD", - "16Uiu2HAmKXAFrEZbhDaF6w6dDbW4brhoQidLjUvovBo78pVEbQ1w", - "16Uiu2HAm6BkEADAtEN6YdWwxTJo2FpTmZ9VoswwpEjX1uPs9sW1V", - "16Uiu2HAmD2xpc8sgQC6j42Tz4SWmkVXAcwMJnfXHXmDAcfNDqhVL", - "16Uiu2HAmRL4FvuU6p3QgYQXPZyE6KBPTGiUjJmJjcoKFQpPu8FRs", - "16Uiu2HAm2P3EDniN91qv8mxyTxvtqLR5sgwL3tbyMnTCfhxe9Qhx", - "16Uiu2HAmRr7fccFXHqD6VGXJTcyuwVNjEp1dwk66Updf8YWtA3Tw", - "16Uiu2HAkxcr6mjnQUePe7axVpjQEjuUNB43bxrKdfaNVJe43FxeQ", - "16Uiu2HAmUiv8fF9BTmTzWeWKm8kpge7PHq4cKrgjgdZ2w6WpxHX9", - "16Uiu2HAmRWK6Q2cdvDfaaMg5Ybt1BctxTp5AB16CpPH61PsGKS74", - "16Uiu2HAmMJPD8Yr6aXHCrtUF91p7ifXhhvrsJdRjr4vr4LfXYwki", - "16Uiu2HAmGtoHooFuHddu44rtm5yoodpyfP6hzTBeo7JPAYuwwAam", - "16Uiu2HAm1vQzkH3rUaHPTHWX74fZoyT1URNDqHNCaSqLwoDSVppR", - "16Uiu2HAkzNB4nkwnBPy5GPRmdDFJTEBXRUAArAUDaYpNCYDrLTrB", - "16Uiu2HAm3nnNwidpojv9e8FjMMrk2C1wxXD82WaW51gFJMw3Pqf9", - "16Uiu2HAmPrKEPdS4WDSPTxVAX4J1XpKaKcyWUtcgQ7eq17AnLiEf", - "16Uiu2HAmPUJShifRseVUX7Ed3HBTBrn3uB2EX8bfaDQoRKWfgYpH", - "16Uiu2HAmE2opd1R4Aw31EWrPGvjpMTdBejU9H59RwDiSJHGwaq41", - "16Uiu2HAkv5pTUJHN5T9YZEXr3M5CnnsMPt2VxTqFg2Jdc1PZnu5L", - "16Uiu2HAmJpY3D531m9dy6XHZA93Mx5JRpLFAHWoKNcwybZSHYedw", - "16Uiu2HAmPVLymKwe8Tn563P8Zm2ypNQzMebz4VHL5M6WcRpejHFK", - "16Uiu2HAkz9qxRtMwbEEctXvx7U7i9i5eHpk6qzDgYTtMoLibJ14j", - "16Uiu2HAmRUtGay745Rmc4EUxxykVtadgKvgYPbf9mj4JmrWJtThp", - ] - node_private_keys = [ - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED800", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED801", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED802", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED803", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED804", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED805", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED806", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED807", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED808", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED809", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED810", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED811", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED812", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED813", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED814", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED815", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED816", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED817", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED818", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED819", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED820", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED821", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED822", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED823", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED824", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED825", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED826", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED827", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED828", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED829", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED830", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED831", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED832", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED833", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED834", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED835", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED836", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED837", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED838", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED839", - ] -} - -data "docker_registry_image" "rosenet-node" { - name = "ghcr.io/rosen-bridge/scaling-large-messages-test-node" -} - -data "docker_registry_image" "rosenet-relay" { - name = "ghcr.io/rosen-bridge/scaling-large-messages-test-relay" -} - -resource "docker_image" "rosenet-node-0" { - provider = docker.machine-0 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-1" { - provider = docker.machine-1 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-2" { - provider = docker.machine-2 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-3" { - provider = docker.machine-3 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-4" { - provider = docker.machine-4 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-5" { - provider = docker.machine-5 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-6" { - provider = docker.machine-6 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-7" { - provider = docker.machine-7 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-8" { - provider = docker.machine-8 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-9" { - provider = docker.machine-9 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - name = data.docker_registry_image.rosenet-relay.name - pull_triggers = [data.docker_registry_image.rosenet-relay.sha256_digest] -} - -resource "docker_container" "rosenet-node-0" { - provider = docker.machine-0 - count = 4 - - name = "node-${count.index}" - image = docker_image.rosenet-node-0.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-1" { - provider = docker.machine-1 - count = 4 - - name = "node-${count.index + 4}" - image = docker_image.rosenet-node-1.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 4]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 4]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-2" { - provider = docker.machine-2 - count = 4 - - name = "node-${count.index + 8}" - image = docker_image.rosenet-node-2.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 8]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 8]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-3" { - provider = docker.machine-3 - count = 4 - - name = "node-${count.index + 12}" - image = docker_image.rosenet-node-3.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 12]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 12]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-4" { - provider = docker.machine-4 - count = 4 - - name = "node-${count.index + 16}" - image = docker_image.rosenet-node-4.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 16]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 16]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-5" { - provider = docker.machine-5 - count = 4 - - name = "node-${count.index + 20}" - image = docker_image.rosenet-node-5.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 20]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 20]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-6" { - provider = docker.machine-6 - count = 4 - - name = "node-${count.index + 24}" - image = docker_image.rosenet-node-6.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 24]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 24]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-7" { - provider = docker.machine-7 - count = 4 - - name = "node-${count.index + 28}" - image = docker_image.rosenet-node-7.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 28]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 28]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-8" { - provider = docker.machine-8 - count = 4 - - name = "node-${count.index + 32}" - image = docker_image.rosenet-node-8.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 32]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 32]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-9" { - provider = docker.machine-9 - count = 4 - - name = "node-${count.index + 36}" - image = docker_image.rosenet-node-9.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 36]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 36]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${join(",", local.node_peer_ids)}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } -} diff --git a/tests/scaling-large-messages/src/node/Dockerfile b/tests/scaling-large-messages/src/node/Dockerfile deleted file mode 100644 index 751b06c..0000000 --- a/tests/scaling-large-messages/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-large-messages/package.json ./tests/scaling-large-messages/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling-large-messages - -CMD npm run start:node diff --git a/tests/scaling-large-messages/src/node/node.ts b/tests/scaling-large-messages/src/node/node.ts deleted file mode 100644 index 2d2edae..0000000 --- a/tests/scaling-large-messages/src/node/node.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: { - ...console, - debug: () => {}, - }, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -const largeMessage = 'x'.repeat(100_000); // 100kB string - -await node.start(); - -const wait = () => - new Promise((resolve) => { - setTimeout(resolve, 1 + Math.random() * 4); - }); - -setTimeout(async () => { - // send some large messages to initiate connections with other peers - const messages = Array.from({ length: 10 }).map(() => largeMessage); - for (const message of messages) { - for (const peer of process.env.ALL_PEER_IDS!.split(',')) { - if (peer !== process.env.NODE_PEER_ID!) { - try { - await node.sendMessage(peer, message); - console.info(`Large message sent, size: ${message.length}`); - } catch (error) { - console.warn( - `tried to send a large message to ${peer.slice(-5)} but failed due to error: ${error}`, - ); - } - await wait(); - } - } - } - - // then start publishing periodically - setInterval(async () => { - for (let i = 0; i < 10; i++) { - try { - const message = `${largeMessage}.${Date.now().toString()}`; - node.publish('rosenet-news', message); - console.info(`Large message published, length: ${message.length}`); - } catch (error) { - console.warn( - `tried to publish a large message but failed due to error: ${error}`, - ); - } - await wait(); - } - }, 10_000); -}, 30_000); - -node.handleIncomingMessage(async (_, message) => { - console.info(`Large message received, length: ${message?.length}`); -}); - -node.subscribe('rosenet-news', (message) => { - console.info( - `Large message received, length: ${message.length} (delay: ${(Date.now() - +message.split('.')[1]) / 1000}s)`, - ); -}); diff --git a/tests/scaling-large-messages/src/relay/Dockerfile b/tests/scaling-large-messages/src/relay/Dockerfile deleted file mode 100644 index f842144..0000000 --- a/tests/scaling-large-messages/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-large-messages/package.json ./tests/scaling-large-messages/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling-large-messages - -CMD npm run start:relay diff --git a/tests/scaling-large-messages/src/relay/relay.ts b/tests/scaling-large-messages/src/relay/relay.ts deleted file mode 100644 index beb445a..0000000 --- a/tests/scaling-large-messages/src/relay/relay.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: process.env.WHITELIST!.split(','), - maxReservations: 40, -}); - -node.start(); diff --git a/tests/scaling-large-messages/ts-node-esm-loader.js b/tests/scaling-large-messages/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/scaling-large-messages/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/scaling-large-messages/tsconfig.json b/tests/scaling-large-messages/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/scaling-large-messages/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/scaling-peer-discovery/.eslintignore b/tests/scaling-peer-discovery/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/scaling-peer-discovery/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/scaling-peer-discovery/.terraform.lock.hcl b/tests/scaling-peer-discovery/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/scaling-peer-discovery/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/scaling-peer-discovery/README.md b/tests/scaling-peer-discovery/README.md deleted file mode 100644 index 07abe5d..0000000 --- a/tests/scaling-peer-discovery/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet scaling peer discovery test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet scaling peer discovery test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/scaling-peer-discovery/package.json b/tests/scaling-peer-discovery/package.json deleted file mode 100644 index 370cbdd..0000000 --- a/tests/scaling-peer-discovery/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/scaling-peer-discovery", - "private": true, - "version": "0.0.0", - "description": "RoseNet scaling peer discovery test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/scaling-peer-discovery/src/node/Dockerfile b/tests/scaling-peer-discovery/src/node/Dockerfile deleted file mode 100644 index cd825f5..0000000 --- a/tests/scaling-peer-discovery/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-peer-discovery/package.json ./tests/scaling-peer-discovery/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling-peer-discovery - -CMD npm run start:node diff --git a/tests/scaling-peer-discovery/src/node/node.ts b/tests/scaling-peer-discovery/src/node/node.ts deleted file mode 100644 index 81fffb2..0000000 --- a/tests/scaling-peer-discovery/src/node/node.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -await node.start(); diff --git a/tests/scaling-peer-discovery/src/relay/Dockerfile b/tests/scaling-peer-discovery/src/relay/Dockerfile deleted file mode 100644 index ddce78c..0000000 --- a/tests/scaling-peer-discovery/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-peer-discovery/package.json ./tests/scaling-peer-discovery/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling-peer-discovery - -CMD npm run start:relay diff --git a/tests/scaling-peer-discovery/ts-node-esm-loader.js b/tests/scaling-peer-discovery/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/scaling-peer-discovery/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/scaling-peer-discovery/tsconfig.json b/tests/scaling-peer-discovery/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/scaling-peer-discovery/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/scaling-peer-discovery/variables.tf b/tests/scaling-peer-discovery/variables.tf deleted file mode 100644 index 6518b49..0000000 --- a/tests/scaling-peer-discovery/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "machines" { - type = list(string) -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/scaling-pubsub/.eslintignore b/tests/scaling-pubsub/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/scaling-pubsub/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/scaling-pubsub/README.md b/tests/scaling-pubsub/README.md deleted file mode 100644 index b41d364..0000000 --- a/tests/scaling-pubsub/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet scaling pubsub test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet scaling pubsub test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/scaling-pubsub/main.tf b/tests/scaling-pubsub/main.tf deleted file mode 100644 index fd35ecc..0000000 --- a/tests/scaling-pubsub/main.tf +++ /dev/null @@ -1,489 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "machine-0" - host = var.machines[0] -} - -provider "docker" { - alias = "machine-1" - host = var.machines[1] -} - -provider "docker" { - alias = "machine-2" - host = var.machines[2] -} - -provider "docker" { - alias = "machine-3" - host = var.machines[3] -} - -provider "docker" { - alias = "machine-4" - host = var.machines[4] -} - -provider "docker" { - alias = "machine-5" - host = var.machines[5] -} - -provider "docker" { - alias = "machine-6" - host = var.machines[6] -} - -provider "docker" { - alias = "machine-7" - host = var.machines[7] -} - -provider "docker" { - alias = "machine-8" - host = var.machines[8] -} - -provider "docker" { - alias = "machine-9" - host = var.machines[9] -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - node_peer_ids = [ - "16Uiu2HAkykduGyaTTrv2sbS5VPiM1opuB8nwrLAFFbkcKJo12Rfp", - "16Uiu2HAm3BY2vHeracYytkbcr4uZN3uXq8RfaQtFQoTvbNUrBb2f", - "16Uiu2HAm2WNNuTmHNiVK2hYhJu7ZBWmKj7mHNG1aiX5WaXMrZG9n", - "16Uiu2HAmNTC7kpXQbovW1kEtCJ5CDEtAGw2DcZ22SBBvGJS18M7E", - "16Uiu2HAmTH1Rya56bKc84B8YbXFCrjpTra6ApHA92FPRTzkWHVjt", - "16Uiu2HAmQYggzsuCnePKhHMJfRJsZAAauFcrpkZGYuiXfkqueQTy", - "16Uiu2HAm4hsxuSJJHHBKfN1xXSauR1gwWLmvQCVjRkYDAzEvArWr", - "16Uiu2HAmNox2uEXiBhNFDN6ssHMe4b9eBffodaTSQeZzs25sspVY", - "16Uiu2HAmVhSVkyzwZvcHUyY7J7pU5PDFJ4iVC5hHb3A2Hs3uogKn", - "16Uiu2HAm8zG2vtPf2Q4ExhsSZtcCTzTzCxY4F64Vtduc6kHPEdNQ", - "16Uiu2HAmSjon8qun6SANsLP9Rm2SrX1Zmwb3XwVinF1UYH6gobUi", - "16Uiu2HAm4yUHDkxyoXVQpUanR8cLfzXMdSBXNHaBTMvzBKiqkJSD", - "16Uiu2HAmULwMmGM8r9WnAfwcyUQKW5kk7QyG7omihCZLQaxHL3id", - "16Uiu2HAmTXHmJEc6eMNXswSA2zGEjC6mQLimFE4xUHc2vBbbiaie", - "16Uiu2HAkztUutiTKFrjnpy8Bsxxwt8WcUQGJN3wrp562GMokTpfs", - "16Uiu2HAkwA4gJ9191vMaowQb9uRFrJsFKdKvwHkusXARkfZD2m4m", - "16Uiu2HAkvK2ZZSczh3gM7UKLKUtzNywnKz6ZyRpHvarDZCVCdwuu", - "16Uiu2HAmDGo4odJjeNqkA3U5QaNcgAkTiGNxg1n7N5vhe4GihcTD", - "16Uiu2HAmKXAFrEZbhDaF6w6dDbW4brhoQidLjUvovBo78pVEbQ1w", - "16Uiu2HAm6BkEADAtEN6YdWwxTJo2FpTmZ9VoswwpEjX1uPs9sW1V", - "16Uiu2HAmD2xpc8sgQC6j42Tz4SWmkVXAcwMJnfXHXmDAcfNDqhVL", - "16Uiu2HAmRL4FvuU6p3QgYQXPZyE6KBPTGiUjJmJjcoKFQpPu8FRs", - "16Uiu2HAm2P3EDniN91qv8mxyTxvtqLR5sgwL3tbyMnTCfhxe9Qhx", - "16Uiu2HAmRr7fccFXHqD6VGXJTcyuwVNjEp1dwk66Updf8YWtA3Tw", - "16Uiu2HAkxcr6mjnQUePe7axVpjQEjuUNB43bxrKdfaNVJe43FxeQ", - "16Uiu2HAmUiv8fF9BTmTzWeWKm8kpge7PHq4cKrgjgdZ2w6WpxHX9", - "16Uiu2HAmRWK6Q2cdvDfaaMg5Ybt1BctxTp5AB16CpPH61PsGKS74", - "16Uiu2HAmMJPD8Yr6aXHCrtUF91p7ifXhhvrsJdRjr4vr4LfXYwki", - "16Uiu2HAmGtoHooFuHddu44rtm5yoodpyfP6hzTBeo7JPAYuwwAam", - "16Uiu2HAm1vQzkH3rUaHPTHWX74fZoyT1URNDqHNCaSqLwoDSVppR", - "16Uiu2HAkzNB4nkwnBPy5GPRmdDFJTEBXRUAArAUDaYpNCYDrLTrB", - "16Uiu2HAm3nnNwidpojv9e8FjMMrk2C1wxXD82WaW51gFJMw3Pqf9", - "16Uiu2HAmPrKEPdS4WDSPTxVAX4J1XpKaKcyWUtcgQ7eq17AnLiEf", - "16Uiu2HAmPUJShifRseVUX7Ed3HBTBrn3uB2EX8bfaDQoRKWfgYpH", - "16Uiu2HAmE2opd1R4Aw31EWrPGvjpMTdBejU9H59RwDiSJHGwaq41", - "16Uiu2HAkv5pTUJHN5T9YZEXr3M5CnnsMPt2VxTqFg2Jdc1PZnu5L", - "16Uiu2HAmJpY3D531m9dy6XHZA93Mx5JRpLFAHWoKNcwybZSHYedw", - "16Uiu2HAmPVLymKwe8Tn563P8Zm2ypNQzMebz4VHL5M6WcRpejHFK", - "16Uiu2HAkz9qxRtMwbEEctXvx7U7i9i5eHpk6qzDgYTtMoLibJ14j", - "16Uiu2HAmRUtGay745Rmc4EUxxykVtadgKvgYPbf9mj4JmrWJtThp", - ] - node_private_keys = [ - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED800", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED801", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED802", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED803", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED804", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED805", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED806", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED807", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED808", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED809", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED810", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED811", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED812", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED813", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED814", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED815", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED816", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED817", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED818", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED819", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED820", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED821", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED822", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED823", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED824", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED825", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED826", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED827", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED828", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED829", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED830", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED831", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED832", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED833", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED834", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED835", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED836", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED837", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED838", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED839", - ] -} - -data "docker_registry_image" "rosenet-node" { - name = "ghcr.io/rosen-bridge/scaling-pubsub-test-node" -} - -data "docker_registry_image" "rosenet-relay" { - name = "ghcr.io/rosen-bridge/scaling-pubsub-test-relay" -} - -resource "docker_image" "rosenet-node-0" { - provider = docker.machine-0 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-1" { - provider = docker.machine-1 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-2" { - provider = docker.machine-2 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-3" { - provider = docker.machine-3 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-4" { - provider = docker.machine-4 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-5" { - provider = docker.machine-5 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-6" { - provider = docker.machine-6 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-7" { - provider = docker.machine-7 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-8" { - provider = docker.machine-8 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-9" { - provider = docker.machine-9 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - name = data.docker_registry_image.rosenet-relay.name - pull_triggers = [data.docker_registry_image.rosenet-relay.sha256_digest] -} - -resource "docker_container" "rosenet-node-0" { - provider = docker.machine-0 - count = 4 - - name = "node-${count.index}" - image = docker_image.rosenet-node-0.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-1" { - provider = docker.machine-1 - count = 4 - - name = "node-${count.index + 4}" - image = docker_image.rosenet-node-1.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 4]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 4]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-2" { - provider = docker.machine-2 - count = 4 - - name = "node-${count.index + 8}" - image = docker_image.rosenet-node-2.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 8]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 8]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-3" { - provider = docker.machine-3 - count = 4 - - name = "node-${count.index + 12}" - image = docker_image.rosenet-node-3.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 12]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 12]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-4" { - provider = docker.machine-4 - count = 4 - - name = "node-${count.index + 16}" - image = docker_image.rosenet-node-4.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 16]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 16]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-5" { - provider = docker.machine-5 - count = 4 - - name = "node-${count.index + 20}" - image = docker_image.rosenet-node-5.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 20]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 20]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-6" { - provider = docker.machine-6 - count = 4 - - name = "node-${count.index + 24}" - image = docker_image.rosenet-node-6.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 24]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 24]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-7" { - provider = docker.machine-7 - count = 4 - - name = "node-${count.index + 28}" - image = docker_image.rosenet-node-7.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 28]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 28]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-8" { - provider = docker.machine-8 - count = 4 - - name = "node-${count.index + 32}" - image = docker_image.rosenet-node-8.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 32]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 32]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-9" { - provider = docker.machine-9 - count = 4 - - name = "node-${count.index + 36}" - image = docker_image.rosenet-node-9.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 36]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 36]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${join(",", local.node_peer_ids)}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } -} diff --git a/tests/scaling-pubsub/package.json b/tests/scaling-pubsub/package.json deleted file mode 100644 index fefbacd..0000000 --- a/tests/scaling-pubsub/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/scaling-pubsub", - "private": true, - "version": "0.0.0", - "description": "RoseNet scaling pubsub test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/scaling-pubsub/src/node/Dockerfile b/tests/scaling-pubsub/src/node/Dockerfile deleted file mode 100644 index 993dee0..0000000 --- a/tests/scaling-pubsub/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling-pubsub/package.json ./tests/scaling-pubsub/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling-pubsub - -CMD npm run start:node diff --git a/tests/scaling-pubsub/src/node/node.ts b/tests/scaling-pubsub/src/node/node.ts deleted file mode 100644 index 482fb05..0000000 --- a/tests/scaling-pubsub/src/node/node.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -await node.start(); - -const wait = () => - new Promise((resolve) => { - setTimeout(resolve, 1 + Math.random() * 4); - }); - -setTimeout(async () => { - // send some messages to initiate connections with other peers - const messages = Array.from({ length: 10 }).map((_, index) => - index.toString(), - ); - for (const message of messages) { - for (const peer of process.env.ALL_PEER_IDS!.split(',')) { - if (peer !== process.env.NODE_PEER_ID!) { - try { - await node.sendMessage(peer, message); - console.info(`Message sent: ${message}`); - } catch (error) { - console.warn( - `tried to send a message to ${peer.slice(-5)} but failed due to error: ${error}`, - ); - } - await wait(); - } - } - } - - // then start publishing periodically - setInterval(async () => { - for (let i = 0; i < 10; i++) { - try { - const message = Date.now().toString(); - node.publish('rosenet-news', message); - console.info(`Message published: ${message}`); - } catch (error) { - console.warn( - `tried to publish a message but failed due to error: ${error}`, - ); - } - await wait(); - } - }, 10_000); -}, 30_000); - -node.handleIncomingMessage(async () => {}); - -node.subscribe('rosenet-news', (message) => { - console.info( - `Message received: ${message} (delay: ${(Date.now() - +message) / 1000}s)`, - ); -}); diff --git a/tests/scaling-pubsub/src/relay/relay.ts b/tests/scaling-pubsub/src/relay/relay.ts deleted file mode 100644 index beb445a..0000000 --- a/tests/scaling-pubsub/src/relay/relay.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: process.env.WHITELIST!.split(','), - maxReservations: 40, -}); - -node.start(); diff --git a/tests/scaling-pubsub/ts-node-esm-loader.js b/tests/scaling-pubsub/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/scaling-pubsub/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/scaling-pubsub/tsconfig.json b/tests/scaling-pubsub/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/scaling-pubsub/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/scaling-pubsub/variables.tf b/tests/scaling-pubsub/variables.tf deleted file mode 100644 index 6518b49..0000000 --- a/tests/scaling-pubsub/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "machines" { - type = list(string) -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/scaling/.eslintignore b/tests/scaling/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/scaling/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/scaling/.terraform.lock.hcl b/tests/scaling/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/scaling/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/scaling/README.md b/tests/scaling/README.md deleted file mode 100644 index 7ee0bff..0000000 --- a/tests/scaling/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet scaling test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet scaling test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/scaling/main.tf b/tests/scaling/main.tf deleted file mode 100644 index 4a56bb0..0000000 --- a/tests/scaling/main.tf +++ /dev/null @@ -1,489 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "machine-0" - host = var.machines[0] -} - -provider "docker" { - alias = "machine-1" - host = var.machines[1] -} - -provider "docker" { - alias = "machine-2" - host = var.machines[2] -} - -provider "docker" { - alias = "machine-3" - host = var.machines[3] -} - -provider "docker" { - alias = "machine-4" - host = var.machines[4] -} - -provider "docker" { - alias = "machine-5" - host = var.machines[5] -} - -provider "docker" { - alias = "machine-6" - host = var.machines[6] -} - -provider "docker" { - alias = "machine-7" - host = var.machines[7] -} - -provider "docker" { - alias = "machine-8" - host = var.machines[8] -} - -provider "docker" { - alias = "machine-9" - host = var.machines[9] -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - node_peer_ids = [ - "16Uiu2HAkykduGyaTTrv2sbS5VPiM1opuB8nwrLAFFbkcKJo12Rfp", - "16Uiu2HAm3BY2vHeracYytkbcr4uZN3uXq8RfaQtFQoTvbNUrBb2f", - "16Uiu2HAm2WNNuTmHNiVK2hYhJu7ZBWmKj7mHNG1aiX5WaXMrZG9n", - "16Uiu2HAmNTC7kpXQbovW1kEtCJ5CDEtAGw2DcZ22SBBvGJS18M7E", - "16Uiu2HAmTH1Rya56bKc84B8YbXFCrjpTra6ApHA92FPRTzkWHVjt", - "16Uiu2HAmQYggzsuCnePKhHMJfRJsZAAauFcrpkZGYuiXfkqueQTy", - "16Uiu2HAm4hsxuSJJHHBKfN1xXSauR1gwWLmvQCVjRkYDAzEvArWr", - "16Uiu2HAmNox2uEXiBhNFDN6ssHMe4b9eBffodaTSQeZzs25sspVY", - "16Uiu2HAmVhSVkyzwZvcHUyY7J7pU5PDFJ4iVC5hHb3A2Hs3uogKn", - "16Uiu2HAm8zG2vtPf2Q4ExhsSZtcCTzTzCxY4F64Vtduc6kHPEdNQ", - "16Uiu2HAmSjon8qun6SANsLP9Rm2SrX1Zmwb3XwVinF1UYH6gobUi", - "16Uiu2HAm4yUHDkxyoXVQpUanR8cLfzXMdSBXNHaBTMvzBKiqkJSD", - "16Uiu2HAmULwMmGM8r9WnAfwcyUQKW5kk7QyG7omihCZLQaxHL3id", - "16Uiu2HAmTXHmJEc6eMNXswSA2zGEjC6mQLimFE4xUHc2vBbbiaie", - "16Uiu2HAkztUutiTKFrjnpy8Bsxxwt8WcUQGJN3wrp562GMokTpfs", - "16Uiu2HAkwA4gJ9191vMaowQb9uRFrJsFKdKvwHkusXARkfZD2m4m", - "16Uiu2HAkvK2ZZSczh3gM7UKLKUtzNywnKz6ZyRpHvarDZCVCdwuu", - "16Uiu2HAmDGo4odJjeNqkA3U5QaNcgAkTiGNxg1n7N5vhe4GihcTD", - "16Uiu2HAmKXAFrEZbhDaF6w6dDbW4brhoQidLjUvovBo78pVEbQ1w", - "16Uiu2HAm6BkEADAtEN6YdWwxTJo2FpTmZ9VoswwpEjX1uPs9sW1V", - "16Uiu2HAmD2xpc8sgQC6j42Tz4SWmkVXAcwMJnfXHXmDAcfNDqhVL", - "16Uiu2HAmRL4FvuU6p3QgYQXPZyE6KBPTGiUjJmJjcoKFQpPu8FRs", - "16Uiu2HAm2P3EDniN91qv8mxyTxvtqLR5sgwL3tbyMnTCfhxe9Qhx", - "16Uiu2HAmRr7fccFXHqD6VGXJTcyuwVNjEp1dwk66Updf8YWtA3Tw", - "16Uiu2HAkxcr6mjnQUePe7axVpjQEjuUNB43bxrKdfaNVJe43FxeQ", - "16Uiu2HAmUiv8fF9BTmTzWeWKm8kpge7PHq4cKrgjgdZ2w6WpxHX9", - "16Uiu2HAmRWK6Q2cdvDfaaMg5Ybt1BctxTp5AB16CpPH61PsGKS74", - "16Uiu2HAmMJPD8Yr6aXHCrtUF91p7ifXhhvrsJdRjr4vr4LfXYwki", - "16Uiu2HAmGtoHooFuHddu44rtm5yoodpyfP6hzTBeo7JPAYuwwAam", - "16Uiu2HAm1vQzkH3rUaHPTHWX74fZoyT1URNDqHNCaSqLwoDSVppR", - "16Uiu2HAkzNB4nkwnBPy5GPRmdDFJTEBXRUAArAUDaYpNCYDrLTrB", - "16Uiu2HAm3nnNwidpojv9e8FjMMrk2C1wxXD82WaW51gFJMw3Pqf9", - "16Uiu2HAmPrKEPdS4WDSPTxVAX4J1XpKaKcyWUtcgQ7eq17AnLiEf", - "16Uiu2HAmPUJShifRseVUX7Ed3HBTBrn3uB2EX8bfaDQoRKWfgYpH", - "16Uiu2HAmE2opd1R4Aw31EWrPGvjpMTdBejU9H59RwDiSJHGwaq41", - "16Uiu2HAkv5pTUJHN5T9YZEXr3M5CnnsMPt2VxTqFg2Jdc1PZnu5L", - "16Uiu2HAmJpY3D531m9dy6XHZA93Mx5JRpLFAHWoKNcwybZSHYedw", - "16Uiu2HAmPVLymKwe8Tn563P8Zm2ypNQzMebz4VHL5M6WcRpejHFK", - "16Uiu2HAkz9qxRtMwbEEctXvx7U7i9i5eHpk6qzDgYTtMoLibJ14j", - "16Uiu2HAmRUtGay745Rmc4EUxxykVtadgKvgYPbf9mj4JmrWJtThp", - ] - node_private_keys = [ - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED800", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED801", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED802", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED803", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED804", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED805", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED806", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED807", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED808", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED809", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED810", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED811", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED812", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED813", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED814", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED815", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED816", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED817", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED818", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED819", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED820", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED821", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED822", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED823", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED824", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED825", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED826", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED827", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED828", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED829", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED830", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED831", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED832", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED833", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED834", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED835", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED836", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED837", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED838", - "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED839", - ] -} - -data "docker_registry_image" "rosenet-node" { - name = "ghcr.io/rosen-bridge/scale-test-node" -} - -data "docker_registry_image" "rosenet-relay" { - name = "ghcr.io/rosen-bridge/scale-test-relay" -} - -resource "docker_image" "rosenet-node-0" { - provider = docker.machine-0 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-1" { - provider = docker.machine-1 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-2" { - provider = docker.machine-2 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-3" { - provider = docker.machine-3 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-4" { - provider = docker.machine-4 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-5" { - provider = docker.machine-5 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-6" { - provider = docker.machine-6 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-7" { - provider = docker.machine-7 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-8" { - provider = docker.machine-8 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-node-9" { - provider = docker.machine-9 - - name = data.docker_registry_image.rosenet-node.name - pull_triggers = [data.docker_registry_image.rosenet-node.sha256_digest] -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - name = data.docker_registry_image.rosenet-relay.name - pull_triggers = [data.docker_registry_image.rosenet-relay.sha256_digest] -} - -resource "docker_container" "rosenet-node-0" { - provider = docker.machine-0 - count = 4 - - name = "node-${count.index}" - image = docker_image.rosenet-node-0.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-1" { - provider = docker.machine-1 - count = 4 - - name = "node-${count.index + 4}" - image = docker_image.rosenet-node-1.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 4]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 4]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-2" { - provider = docker.machine-2 - count = 4 - - name = "node-${count.index + 8}" - image = docker_image.rosenet-node-2.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 8]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 8]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-3" { - provider = docker.machine-3 - count = 4 - - name = "node-${count.index + 12}" - image = docker_image.rosenet-node-3.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 12]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 12]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-4" { - provider = docker.machine-4 - count = 4 - - name = "node-${count.index + 16}" - image = docker_image.rosenet-node-4.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 16]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 16]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-5" { - provider = docker.machine-5 - count = 4 - - name = "node-${count.index + 20}" - image = docker_image.rosenet-node-5.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 20]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 20]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-6" { - provider = docker.machine-6 - count = 4 - - name = "node-${count.index + 24}" - image = docker_image.rosenet-node-6.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 24]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 24]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-7" { - provider = docker.machine-7 - count = 4 - - name = "node-${count.index + 28}" - image = docker_image.rosenet-node-7.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 28]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 28]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-8" { - provider = docker.machine-8 - count = 4 - - name = "node-${count.index + 32}" - image = docker_image.rosenet-node-8.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 32]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 32]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-node-9" { - provider = docker.machine-9 - count = 4 - - name = "node-${count.index + 36}" - image = docker_image.rosenet-node-9.image_id - env = [ - "RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index + 36]}", "ALL_PEER_IDS=${join("," ,local.node_peer_ids)}", "NODE_PEER_ID=${local.node_peer_ids[count.index + 36]}"] - - depends_on = [ - docker_container.rosenet-relay, - docker_image.rosenet-node-0, - docker_image.rosenet-node-1, - docker_image.rosenet-node-2, - docker_image.rosenet-node-3, - docker_image.rosenet-node-4, - docker_image.rosenet-node-5, - docker_image.rosenet-node-6, - docker_image.rosenet-node-7, - docker_image.rosenet-node-8, - docker_image.rosenet-node-9, - ] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${join(",", local.node_peer_ids)}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } -} diff --git a/tests/scaling/package.json b/tests/scaling/package.json deleted file mode 100644 index bfd2729..0000000 --- a/tests/scaling/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/scaling", - "private": true, - "version": "0.0.0", - "description": "RoseNet scaling test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/scaling/src/node/Dockerfile b/tests/scaling/src/node/Dockerfile deleted file mode 100644 index b5bc84e..0000000 --- a/tests/scaling/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling/package.json ./tests/scaling/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling - -CMD npm run start:node diff --git a/tests/scaling/src/node/node.ts b/tests/scaling/src/node/node.ts deleted file mode 100644 index c88a14d..0000000 --- a/tests/scaling/src/node/node.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: { - ...console, - debug: () => {}, - }, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -await node.start(); - -const MessageCounter = { - ackWaiting: 0, - total: 0, - increase() { - this.ackWaiting += 1; - this.total += 1; - }, - decrease() { - this.ackWaiting -= 1; - }, - startLogger() { - setInterval(() => { - console.info( - `>>> Counter: ${this.ackWaiting}, Total: ${this.total}, loss: ${this.ackWaiting && this.total ? ((this.ackWaiting * 100) / this.total).toFixed(2) : 0}%`, - ); - }, 30_000); - }, -}; - -const wait = () => - new Promise((resolve) => { - setTimeout(resolve, 1 + Math.random() * 9); - }); - -setTimeout(() => { - setInterval(async () => { - const messages = Array.from({ length: 10 }).map( - (_, index) => - `Ping@${new Date().toLocaleTimeString([], { hour12: false })}#${index}:${process.env.NODE_PEER_ID!.slice(-5)}`, - ); - for (const message of messages) { - for (const peer of process.env.ALL_PEER_IDS!.split(',')) { - if (peer !== process.env.NODE_PEER_ID!) { - try { - const actualMessage = `${message}->${peer.slice(-5)}`; - await node.sendMessage(peer, actualMessage); - MessageCounter.increase(); - console.info(`Message sent: ${actualMessage}`); - } catch (error) { - console.warn( - `tried to send a message to ${peer.slice(-5)} but failed due to error: ${error}`, - ); - } - await wait(); - } - } - } - }, 10_000); -}, 30_000); - -node.handleIncomingMessage(async (from, message) => { - if (message?.includes('Pong')) { - console.info(`Pong received: ${message}`); - MessageCounter.decrease(); - } else { - console.info(`Message received: ${message}`); - try { - const actualMessage = `Pong@${new Date().toLocaleTimeString([], { hour12: false })}:${message}`; - await node.sendMessage(from, actualMessage); - console.info(`Pong sent: ${actualMessage}`); - } catch (error) { - console.warn( - `tried to pong message ${message} but failed due to error: ${error}`, - ); - } - } -}); - -MessageCounter.startLogger(); diff --git a/tests/scaling/src/relay/Dockerfile b/tests/scaling/src/relay/Dockerfile deleted file mode 100644 index a94d050..0000000 --- a/tests/scaling/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/scaling/package.json ./tests/scaling/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/scaling - -CMD npm run start:relay diff --git a/tests/scaling/src/relay/relay.ts b/tests/scaling/src/relay/relay.ts deleted file mode 100644 index beb445a..0000000 --- a/tests/scaling/src/relay/relay.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: process.env.WHITELIST!.split(','), - maxReservations: 40, -}); - -node.start(); diff --git a/tests/scaling/ts-node-esm-loader.js b/tests/scaling/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/scaling/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/scaling/tsconfig.json b/tests/scaling/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/scaling/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/scaling/variables.tf b/tests/scaling/variables.tf deleted file mode 100644 index 6518b49..0000000 --- a/tests/scaling/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "machines" { - type = list(string) -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/simple-star/.eslintignore b/tests/simple-star/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/simple-star/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/simple-star/.terraform.lock.hcl b/tests/simple-star/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/simple-star/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/simple-star/README.md b/tests/simple-star/README.md deleted file mode 100644 index bd2923d..0000000 --- a/tests/simple-star/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet simple-star test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet simple star test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/simple-star/main.tf b/tests/simple-star/main.tf deleted file mode 100644 index 6e6fbbe..0000000 --- a/tests/simple-star/main.tf +++ /dev/null @@ -1,119 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "node-machine" - host = var.node-host -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - node_peer_ids = ["QmaeANgBs1DTSxWSrPPtobgQuxW8XTfsS4ydbK4rCHzqxG", "12D3KooWBtg3aaRMjxwedh83aGiUkwSxDwUZkzuJcfaqUmo7R3pq"] - node_private_keys = ["080012ae123082092a0201000282020100e1beab071d08200bde24eef00d049449b07770ff9910257b2d7d5dda242ce8f0e2f12e1af4b32d9efd2c090f66b0f29986dbb645dae9880089704a94e5066d594162ae6ee8892e6ec70701db0a6c445c04778eb3de1293aa1a23c3825b85c6620a2bc3f82f9b0c309bc0ab3aeb1873282bebd3da03c33e76c21e9beb172fd44c9e43be32e2c99827033cf8d0f0c606f4579326c930eb4e854395ad941256542c793902185153c474bed109d6ff5141ebf9cd256cf58893a37f83729f97e7cb435ec679d2e33901d27bb35aa0d7e20561da08885ef0abbf8e2fb48d6a5487047a9ecb1ad41fa7ed84f6e3e8ecd5d98b3982d2a901b4454991766da295ab78822add5612a2df83bcee814cf50973e80d7ef38111b1bd87da2ae92438a2c8cbcc70b31ee319939a3b9c761dbc13b5c086d6b64bf7ae7dacc14622375d92a8ff9af7eb962162bbddebf90acb32adb5e4e4029f1c96019949ecfbfeffd7ac1e3fbcc6b6168c34be3d5a2e5999fcbb39bba7adbca78eab09b9bc39f7fa4b93411f4cc175e70c0a083e96bfaefb04a9580b4753c1738a6a760ae1afd851a1a4bdad231cf56e9284d832483df215a46c1c21bdf0c6cfe951c18f1ee4078c79c13d63edb6e14feaeffabc90ad317e4875fe648101b0864097e998f0ca3025ef9638cd2b0caecd3770ab54a1d9c6ca959b0f5dcbc90caeefc4135baca6fd475224269bbe1b02030100010282020100a472ffa858efd8588ce59ee264b957452f3673acdf5631d7bfd5ba0ef59779c231b0bc838a8b14cae367b6d9ef572c03c7883b0a3c652f5c24c316b1ccfd979f13d0cd7da20c7d34d9ec32dfdc81ee7292167e706d705efde5b8f3edfcba41409e642f8897357df5d320d21c43b33600a7ae4e505db957c1afbc189d73f0b5d972d9aaaeeb232ca20eebd5de6fe7f29d01470354413cc9a0af1154b7af7c1029adcd67c74b4798afeb69e09f2cb387305e73a1b5f450202d54f0ef096fe1bde340219a1194d1ac9026e90b366cce0c59b239d10e4888f52ca1780824d39ae01a6b9f4dd6059191a7f12b2a3d8db3c2868cd4e5a5862b8b625a4197d52c6ac77710116ebd3ced81c4d91ad5fdfbed68312ebce7eea45c1833ca3acf7da2052820eacf5c6b07d086dabeb893391c71417fd8a4b1829ae2cf60d1749d0e25da19530d889461c21da3492a8dc6ccac7de83ac1c2185262c7473c8cc42f547cc9864b02a8073b6aa54a037d8c0de3914784e6205e83d97918b944f11b877b12084c0dd1d36592f8a4f8b8da5bb404c3d2c079b22b6ceabfbcb637c0dbe0201f0909d533f8bf308ada47aee641a012a494d31b54c974e58b87f140258258bb82f31692659db7aa07e17a5b2a0832c24e122d3a8babcc9ee74cbb07d3058bb85b15f6f6b2674aba9fd34367be9782d444335fbed31e3c4086c652597c27104938b47fa10282010100e9fdf843c1550070ca711cb8ff28411466198f0e212511c3186623890c0071bf6561219682fe7dbdfd81176eba7c4faba21614a20721e0fcd63768e6d925688ecc90992059ac89256e0524de90bf3d8a052ce6a9f6adafa712f3107a016e20c80255c9e37d8206d1bc327e06e66eb24288da866b55904fd8b59e6b2ab31bc5eab47e597093c63fab7872102d57b4c589c66077f534a61f5f65127459a33c91f6db61fc431b1ae90be92b4149a3255291baf94304e3efb77b1107b5a3bda911359c40a53c347ff9100baf8f36dc5cd991066b5bdc28b39ed644f404afe9213f4d31c9d4e40f3a5f5e3c39bebeb244e84137544e1a1839c1c8aaebf0c78a7fad590282010100f6fa1f1e6b803742d5490b7441152f500970f46feb0b73a6e4baba2aaf3c0e245ed852fc31d86a8e46eb48e90fac409989dfee45238f97e8f1f8e83a136488c1b04b8a7fb695f37b8616307ff8a8d63e8cfa0b4fb9b9167ffaebabf111aa5a4344afbabd002ae8961c38c02da76a9149abdde93eb389eb32595c29ba30d8283a7885218a5a9d33f7f01dbdf85f3aad016c071395491338ec318d39220e1c7bd69d3d6b520a13a30d745c102b827ad9984b0dd6aed73916ffa82a06c1c111e7047dcd2668f988a0570a71474992eecf416e068f029ec323d5d635fd24694fc9bf96973c255d26c772a95bf8b7f876547a5beabf86f06cd21b67994f944e7a5493028201010095b02fd30069e547426a8bea58e8a2816f33688dac6c6f6974415af8402244a22133baedf34ce499d7036f3f19b38eb00897c18949b0c5a25953c71aeeccfc8f6594173157cc854bd98f16dffe8f28ca13b77eb43a2730585c49fc3f608cd811bb54b03b84bddaa8ef910988567f783012266199667a546a18fd88271fbf63a45ae4fd4884706da8befb9117c0a4d73de5172f8640b1091ed8a4aea3ed4641463f5ff6a5e3401ad7d0c92811f87956d1fd5f9a1d15c7f3839a08698d9f35f9d966e5000f7cb2655d7b6c4adcd8a9d950ea5f61bb7c9a33c17508f9baa313eecfee4ae493249ebe05a5d7770bbd3551b2eeb752e3649e0636de08e3d672e66cb90282010100ad93e4c31072b063fc5ab5fe22afacece775c795d0efdf7c704cfc027bde0d626a7646fc905bb5a80117e3ca49059af14e0160089f9190065be9bfecf12c3b2145b211c8e89e42dd91c38e9aa23ca73697063564f6f6aa6590088a738722df056004d18d7bccac62b3bafef6172fc2a4b071ea37f31eff7a076bcab7dd144e51a9da8754219352aef2c73478971539fa41de4759285ea626fa3c72e7085be47d554d915bbb5149cb6ef835351f231043049cd941506a034bf2f8767f3e1e42ead92f91cb3d75549b57ef7d56ac39c2d80d67f6a2b4ca192974bfc5060e2dd171217971002193dba12e7e4133ab201f07500a90495a38610279b13a48d54f0c99028201003e3a1ac0c2b67d54ed5c4bbe04a7db99103659d33a4f9d35809e1f60c282e5988dddc964527f3b05e6cc890eab3dcb571d66debf3a5527704c87264b3954d7265f4e8d2c637dd89b491b9cf23f264801f804b90454d65af0c4c830d1aef76f597ef61b26ca857ecce9cb78d4f6c2218c00d2975d46c2b013fbf59b750c3b92d8d3ed9e6d1fd0ef1ec091a5c286a3fe2dead292f40f380065731e2079ebb9f2a7ef2c415ecbb488da98f3a12609ca1b6ec8c734032c8bd513292ff842c375d4acd1b02dfb206b24cd815f8e2f9d4af8e7dea0370b19c1b23cc531d78b40e06e1119ee2e08f6f31c6e2e8444c568d13c5d451a291ae0c9f1d4f27d23b3a00d60ad", "080112407e0830617c4a7de83925dfb2694556b12936c477a0e1feb2e148ec9da60fee7d1ed1e8fae2c4a144b8be8fd4b47bf3d3b34b871c3cacf6010f0e42d474fce27e"] -} - -resource "docker_image" "rosenet-node" { - provider = docker.node-machine - - build { - context = "../.." - dockerfile = "./tests/simple-star/src/node/Dockerfile" - } - name = "rosenet-node" - - triggers = { - node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) - node_sha1 = filesha1("./src/node/node.ts") - dockerfile_sha1 = filesha1("./src/node/Dockerfile") - } -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - build { - context = "../.." - dockerfile = "./tests/simple-star/src/relay/Dockerfile" - } - name = "rosenet-relay" - - triggers = { - relay_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-relay/lib/**") : filesha1(f)])) - relay_sha1 = filesha1("./src/relay/relay.ts") - dockerfile_sha1 = filesha1("./src/relay/Dockerfile") - } -} - -resource "docker_container" "rosenet-node" { - provider = docker.node-machine - - count = 2 - - name = "node-${count.index}" - image = docker_image.rosenet-node.image_id - env = ["RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}"] - - depends_on = [docker_container.rosenet-relay] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELIST=${join(",", local.node_peer_ids)}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } - - depends_on = [docker_image.rosenet-node] -} - -data "docker_logs" "relay-logs" { - provider = docker.relay-machine - - name = docker_container.rosenet-relay.name - follow = true - - depends_on = [docker_container.rosenet-node] -} - -data "docker_logs" "node-logs" { - provider = docker.node-machine - - count = 2 - - name = docker_container.rosenet-node[count.index].name - follow = true - - lifecycle { - postcondition { - # Check if connection to relay log is present - condition = anytrue([for log in self.logs_list_string: can(regex("Peer connected.*${local.relay_peer_id}", log))]) - error_message = "The node did not connect to the relay" - } - postcondition { - # Check if the other node is discovered - condition = anytrue([ - for index, log in self.logs_list_string: alltrue([ - strcontains(log, "Peer identified"), - try(strcontains(self.logs_list_string[index + 1], "rosenet-node"), false) - ]) - ]) - error_message = "The other node is not discovered" - } - } -} diff --git a/tests/simple-star/package.json b/tests/simple-star/package.json deleted file mode 100644 index 6f37003..0000000 --- a/tests/simple-star/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/simple-star", - "private": true, - "version": "0.0.0", - "description": "RoseNet simple star test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/simple-star/src/node/Dockerfile b/tests/simple-star/src/node/Dockerfile deleted file mode 100644 index 0be9fa4..0000000 --- a/tests/simple-star/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/simple-star/package.json ./tests/simple-star/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/simple-star - -CMD npm run start:node diff --git a/tests/simple-star/src/node/node.ts b/tests/simple-star/src/node/node.ts deleted file mode 100644 index 4ae6f72..0000000 --- a/tests/simple-star/src/node/node.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 20000); diff --git a/tests/simple-star/src/relay/Dockerfile b/tests/simple-star/src/relay/Dockerfile deleted file mode 100644 index bbcfce5..0000000 --- a/tests/simple-star/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/simple-star/package.json ./tests/simple-star/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/simple-star - -CMD npm run start:relay diff --git a/tests/simple-star/src/relay/relay.ts b/tests/simple-star/src/relay/relay.ts deleted file mode 100644 index c2eeea5..0000000 --- a/tests/simple-star/src/relay/relay.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: process.env.WHITELIST!.split(','), -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 25000); diff --git a/tests/simple-star/ts-node-esm-loader.js b/tests/simple-star/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/simple-star/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/simple-star/tsconfig.json b/tests/simple-star/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/simple-star/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/simple-star/variables.tf b/tests/simple-star/variables.tf deleted file mode 100644 index 46dec1a..0000000 --- a/tests/simple-star/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "node-host" { - type = string -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/whitelist-node/.eslintignore b/tests/whitelist-node/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/whitelist-node/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/whitelist-node/.terraform.lock.hcl b/tests/whitelist-node/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/whitelist-node/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/whitelist-node/README.md b/tests/whitelist-node/README.md deleted file mode 100644 index 9617276..0000000 --- a/tests/whitelist-node/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet whitelist-node test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet node whitelist test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/whitelist-node/main.tf b/tests/whitelist-node/main.tf deleted file mode 100644 index 584f3ea..0000000 --- a/tests/whitelist-node/main.tf +++ /dev/null @@ -1,123 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "node-machine" - host = var.node-host -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - whitelisted_relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - whitelisted_relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - blacklisted_relay_peer_id = "QmaeANgBs1DTSxWSrPPtobgQuxW8XTfsS4ydbK4rCHzqxG" - blacklisted_relay_private_key = "080012ae123082092a0201000282020100e1beab071d08200bde24eef00d049449b07770ff9910257b2d7d5dda242ce8f0e2f12e1af4b32d9efd2c090f66b0f29986dbb645dae9880089704a94e5066d594162ae6ee8892e6ec70701db0a6c445c04778eb3de1293aa1a23c3825b85c6620a2bc3f82f9b0c309bc0ab3aeb1873282bebd3da03c33e76c21e9beb172fd44c9e43be32e2c99827033cf8d0f0c606f4579326c930eb4e854395ad941256542c793902185153c474bed109d6ff5141ebf9cd256cf58893a37f83729f97e7cb435ec679d2e33901d27bb35aa0d7e20561da08885ef0abbf8e2fb48d6a5487047a9ecb1ad41fa7ed84f6e3e8ecd5d98b3982d2a901b4454991766da295ab78822add5612a2df83bcee814cf50973e80d7ef38111b1bd87da2ae92438a2c8cbcc70b31ee319939a3b9c761dbc13b5c086d6b64bf7ae7dacc14622375d92a8ff9af7eb962162bbddebf90acb32adb5e4e4029f1c96019949ecfbfeffd7ac1e3fbcc6b6168c34be3d5a2e5999fcbb39bba7adbca78eab09b9bc39f7fa4b93411f4cc175e70c0a083e96bfaefb04a9580b4753c1738a6a760ae1afd851a1a4bdad231cf56e9284d832483df215a46c1c21bdf0c6cfe951c18f1ee4078c79c13d63edb6e14feaeffabc90ad317e4875fe648101b0864097e998f0ca3025ef9638cd2b0caecd3770ab54a1d9c6ca959b0f5dcbc90caeefc4135baca6fd475224269bbe1b02030100010282020100a472ffa858efd8588ce59ee264b957452f3673acdf5631d7bfd5ba0ef59779c231b0bc838a8b14cae367b6d9ef572c03c7883b0a3c652f5c24c316b1ccfd979f13d0cd7da20c7d34d9ec32dfdc81ee7292167e706d705efde5b8f3edfcba41409e642f8897357df5d320d21c43b33600a7ae4e505db957c1afbc189d73f0b5d972d9aaaeeb232ca20eebd5de6fe7f29d01470354413cc9a0af1154b7af7c1029adcd67c74b4798afeb69e09f2cb387305e73a1b5f450202d54f0ef096fe1bde340219a1194d1ac9026e90b366cce0c59b239d10e4888f52ca1780824d39ae01a6b9f4dd6059191a7f12b2a3d8db3c2868cd4e5a5862b8b625a4197d52c6ac77710116ebd3ced81c4d91ad5fdfbed68312ebce7eea45c1833ca3acf7da2052820eacf5c6b07d086dabeb893391c71417fd8a4b1829ae2cf60d1749d0e25da19530d889461c21da3492a8dc6ccac7de83ac1c2185262c7473c8cc42f547cc9864b02a8073b6aa54a037d8c0de3914784e6205e83d97918b944f11b877b12084c0dd1d36592f8a4f8b8da5bb404c3d2c079b22b6ceabfbcb637c0dbe0201f0909d533f8bf308ada47aee641a012a494d31b54c974e58b87f140258258bb82f31692659db7aa07e17a5b2a0832c24e122d3a8babcc9ee74cbb07d3058bb85b15f6f6b2674aba9fd34367be9782d444335fbed31e3c4086c652597c27104938b47fa10282010100e9fdf843c1550070ca711cb8ff28411466198f0e212511c3186623890c0071bf6561219682fe7dbdfd81176eba7c4faba21614a20721e0fcd63768e6d925688ecc90992059ac89256e0524de90bf3d8a052ce6a9f6adafa712f3107a016e20c80255c9e37d8206d1bc327e06e66eb24288da866b55904fd8b59e6b2ab31bc5eab47e597093c63fab7872102d57b4c589c66077f534a61f5f65127459a33c91f6db61fc431b1ae90be92b4149a3255291baf94304e3efb77b1107b5a3bda911359c40a53c347ff9100baf8f36dc5cd991066b5bdc28b39ed644f404afe9213f4d31c9d4e40f3a5f5e3c39bebeb244e84137544e1a1839c1c8aaebf0c78a7fad590282010100f6fa1f1e6b803742d5490b7441152f500970f46feb0b73a6e4baba2aaf3c0e245ed852fc31d86a8e46eb48e90fac409989dfee45238f97e8f1f8e83a136488c1b04b8a7fb695f37b8616307ff8a8d63e8cfa0b4fb9b9167ffaebabf111aa5a4344afbabd002ae8961c38c02da76a9149abdde93eb389eb32595c29ba30d8283a7885218a5a9d33f7f01dbdf85f3aad016c071395491338ec318d39220e1c7bd69d3d6b520a13a30d745c102b827ad9984b0dd6aed73916ffa82a06c1c111e7047dcd2668f988a0570a71474992eecf416e068f029ec323d5d635fd24694fc9bf96973c255d26c772a95bf8b7f876547a5beabf86f06cd21b67994f944e7a5493028201010095b02fd30069e547426a8bea58e8a2816f33688dac6c6f6974415af8402244a22133baedf34ce499d7036f3f19b38eb00897c18949b0c5a25953c71aeeccfc8f6594173157cc854bd98f16dffe8f28ca13b77eb43a2730585c49fc3f608cd811bb54b03b84bddaa8ef910988567f783012266199667a546a18fd88271fbf63a45ae4fd4884706da8befb9117c0a4d73de5172f8640b1091ed8a4aea3ed4641463f5ff6a5e3401ad7d0c92811f87956d1fd5f9a1d15c7f3839a08698d9f35f9d966e5000f7cb2655d7b6c4adcd8a9d950ea5f61bb7c9a33c17508f9baa313eecfee4ae493249ebe05a5d7770bbd3551b2eeb752e3649e0636de08e3d672e66cb90282010100ad93e4c31072b063fc5ab5fe22afacece775c795d0efdf7c704cfc027bde0d626a7646fc905bb5a80117e3ca49059af14e0160089f9190065be9bfecf12c3b2145b211c8e89e42dd91c38e9aa23ca73697063564f6f6aa6590088a738722df056004d18d7bccac62b3bafef6172fc2a4b071ea37f31eff7a076bcab7dd144e51a9da8754219352aef2c73478971539fa41de4759285ea626fa3c72e7085be47d554d915bbb5149cb6ef835351f231043049cd941506a034bf2f8767f3e1e42ead92f91cb3d75549b57ef7d56ac39c2d80d67f6a2b4ca192974bfc5060e2dd171217971002193dba12e7e4133ab201f07500a90495a38610279b13a48d54f0c99028201003e3a1ac0c2b67d54ed5c4bbe04a7db99103659d33a4f9d35809e1f60c282e5988dddc964527f3b05e6cc890eab3dcb571d66debf3a5527704c87264b3954d7265f4e8d2c637dd89b491b9cf23f264801f804b90454d65af0c4c830d1aef76f597ef61b26ca857ecce9cb78d4f6c2218c00d2975d46c2b013fbf59b750c3b92d8d3ed9e6d1fd0ef1ec091a5c286a3fe2dead292f40f380065731e2079ebb9f2a7ef2c415ecbb488da98f3a12609ca1b6ec8c734032c8bd513292ff842c375d4acd1b02dfb206b24cd815f8e2f9d4af8e7dea0370b19c1b23cc531d78b40e06e1119ee2e08f6f31c6e2e8444c568d13c5d451a291ae0c9f1d4f27d23b3a00d60ad" - node_peer_id = "12D3KooWBtg3aaRMjxwedh83aGiUkwSxDwUZkzuJcfaqUmo7R3pq" - node_private_key = "080112407e0830617c4a7de83925dfb2694556b12936c477a0e1feb2e148ec9da60fee7d1ed1e8fae2c4a144b8be8fd4b47bf3d3b34b871c3cacf6010f0e42d474fce27e" -} - -resource "docker_image" "rosenet-node" { - provider = docker.node-machine - - build { - context = "../.." - dockerfile = "./tests/whitelist-node/src/node/Dockerfile" - } - name = "rosenet-node" - - triggers = { - node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) - node_sha1 = filesha1("./src/node/node.ts") - dockerfile_sha1 = filesha1("./src/node/Dockerfile") - } -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - build { - context = "../.." - dockerfile = "./tests/whitelist-node/src/relay/Dockerfile" - } - name = "rosenet-relay" - - triggers = { - relay_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-relay/lib/**") : filesha1(f)])) - relay_sha1 = filesha1("./src/relay/relay.ts") - dockerfile_sha1 = filesha1("./src/relay/Dockerfile") - } -} - -resource "docker_container" "rosenet-node" { - provider = docker.node-machine - - name = "node" - image = docker_image.rosenet-node.image_id - env = ["RELAY_MULTIADDRS=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.whitelisted_relay_peer_id},/ip4/${var.relay-ip}/tcp/44444/p2p/${local.blacklisted_relay_peer_id}", "PRIVATE_KEY=${local.node_private_key}", "WHITELISTED_PEER_ID=${local.whitelisted_relay_peer_id}"] - - depends_on = [docker_container.rosenet-whitelisted-relay, docker_container.rosenet-blacklisted-relay] -} - -resource "docker_container" "rosenet-whitelisted-relay" { - provider = docker.relay-machine - - name = "whitelisted-relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.whitelisted_relay_private_key}", "WHITELISTED_PEER_ID=${local.node_peer_id}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } - - depends_on = [docker_image.rosenet-node] -} - -resource "docker_container" "rosenet-blacklisted-relay" { - provider = docker.relay-machine - - name = "blacklisted-relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.blacklisted_relay_private_key}", "WHITELISTED_PEER_ID=${local.node_peer_id}", "LISTEN_PORT=44444"] - ports { - internal = 44444 - external = 44444 - } - - depends_on = [docker_image.rosenet-node] -} - -data "docker_logs" "node-logs" { - provider = docker.node-machine - - name = docker_container.rosenet-node.name - follow = true - - # Currently we only check dial prevention, but the main point of whitelisting - # is for inbound connections, so conditions for such connections should be - # added later - # local:ergo/rosen-bridge/p2p#50 - lifecycle { - postcondition { - # Check if whitelisted relay peer id is connected - condition = anytrue([for log in self.logs_list_string: can(regex("Peer connected.*${local.whitelisted_relay_peer_id}", log))]) - error_message = "Whitelisted relay was not connected" - } - postcondition { - # Check if blacklisted relay peer id is not connected - condition = !anytrue([for log in self.logs_list_string: can(regex("Peer connected.*${local.blacklisted_relay_peer_id}", log))]) - error_message = "Blacklisted relay was connected" - } - } - - depends_on = [docker_container.rosenet-node] -} diff --git a/tests/whitelist-node/package.json b/tests/whitelist-node/package.json deleted file mode 100644 index 8bcf5cb..0000000 --- a/tests/whitelist-node/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/whitelist-node", - "private": true, - "version": "0.0.0", - "description": "RoseNet node whitelist test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/whitelist-node/src/node/Dockerfile b/tests/whitelist-node/src/node/Dockerfile deleted file mode 100644 index 6124576..0000000 --- a/tests/whitelist-node/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/whitelist-node/package.json ./tests/whitelist-node/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/whitelist-node - -CMD npm run start:node diff --git a/tests/whitelist-node/src/node/node.ts b/tests/whitelist-node/src/node/node.ts deleted file mode 100644 index 1051397..0000000 --- a/tests/whitelist-node/src/node/node.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: process.env.RELAY_MULTIADDRS!.split(','), - privateKey: process.env.PRIVATE_KEY!, - whitelist: [process.env.WHITELISTED_PEER_ID!], -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 20000); diff --git a/tests/whitelist-node/src/relay/Dockerfile b/tests/whitelist-node/src/relay/Dockerfile deleted file mode 100644 index 3396064..0000000 --- a/tests/whitelist-node/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/whitelist-node/package.json ./tests/whitelist-node/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/whitelist-node - -CMD npm run start:relay diff --git a/tests/whitelist-node/src/relay/relay.ts b/tests/whitelist-node/src/relay/relay.ts deleted file mode 100644 index 31ca572..0000000 --- a/tests/whitelist-node/src/relay/relay.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: [process.env.WHITELISTED_PEER_ID!], -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 25000); diff --git a/tests/whitelist-node/ts-node-esm-loader.js b/tests/whitelist-node/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/whitelist-node/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/whitelist-node/tsconfig.json b/tests/whitelist-node/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/whitelist-node/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/whitelist-node/variables.tf b/tests/whitelist-node/variables.tf deleted file mode 100644 index 46dec1a..0000000 --- a/tests/whitelist-node/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "node-host" { - type = string -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -} diff --git a/tests/whitelist-relay/.eslintignore b/tests/whitelist-relay/.eslintignore deleted file mode 100644 index 1521c8b..0000000 --- a/tests/whitelist-relay/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/tests/whitelist-relay/.terraform.lock.hcl b/tests/whitelist-relay/.terraform.lock.hcl deleted file mode 100644 index f526901..0000000 --- a/tests/whitelist-relay/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/kreuzwerker/docker" { - version = "3.0.2" - constraints = "~> 3.0.1" - hashes = [ - "h1:cT2ccWOtlfKYBUE60/v2/4Q6Stk1KYTNnhxSck+VPlU=", - "zh:15b0a2b2b563d8d40f62f83057d91acb02cd0096f207488d8b4298a59203d64f", - "zh:23d919de139f7cd5ebfd2ff1b94e6d9913f0977fcfc2ca02e1573be53e269f95", - "zh:38081b3fe317c7e9555b2aaad325ad3fa516a886d2dfa8605ae6a809c1072138", - "zh:4a9c5065b178082f79ad8160243369c185214d874ff5048556d48d3edd03c4da", - "zh:5438ef6afe057945f28bce43d76c4401254073de01a774760169ac1058830ac2", - "zh:60b7fadc287166e5c9873dfe53a7976d98244979e0ab66428ea0dea1ebf33e06", - "zh:61c5ec1cb94e4c4a4fb1e4a24576d5f39a955f09afb17dab982de62b70a9bdd1", - "zh:a38fe9016ace5f911ab00c88e64b156ebbbbfb72a51a44da3c13d442cd214710", - "zh:c2c4d2b1fd9ebb291c57f524b3bf9d0994ff3e815c0cd9c9bcb87166dc687005", - "zh:d567bb8ce483ab2cf0602e07eae57027a1a53994aba470fa76095912a505533d", - "zh:e83bf05ab6a19dd8c43547ce9a8a511f8c331a124d11ac64687c764ab9d5a792", - "zh:e90c934b5cd65516fbcc454c89a150bfa726e7cf1fe749790c7480bbeb19d387", - "zh:f05f167d2eaf913045d8e7b88c13757e3cf595dd5cd333057fdafc7c4b7fed62", - "zh:fcc9c1cea5ce85e8bcb593862e699a881bd36dffd29e2e367f82d15368659c3d", - ] -} diff --git a/tests/whitelist-relay/README.md b/tests/whitelist-relay/README.md deleted file mode 100644 index a97032f..0000000 --- a/tests/whitelist-relay/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# RoseNet whitelist-relay test - -## Table of contents - -- [Introduction](#introduction) -- [Usage](#usage) - -## Introduction - -RoseNet relay whitelist test - -## Usage - -You need to have [OpenTofu](https://opentofu.org/) installed. Then, after -[passing required variables](https://opentofu.org/docs/language/values/variables/#assigning-values-to-root-module-variables) (defined in [`variables.tf`](./variables.tf)), -run the following commands. It should complete with no errors. - -```bash -tofu init -tofu apply -``` - -Finally run `tofu destroy` to destroy the infrastructure. diff --git a/tests/whitelist-relay/main.tf b/tests/whitelist-relay/main.tf deleted file mode 100644 index b6a0378..0000000 --- a/tests/whitelist-relay/main.tf +++ /dev/null @@ -1,104 +0,0 @@ -terraform { - required_providers { - docker = { - source = "kreuzwerker/docker" - version = "~> 3.0.1" - } - } -} - -provider "docker" { - alias = "node-machine" - host = var.node-host -} - -provider "docker" { - alias = "relay-machine" - host = var.relay-host -} - -locals { - relay_peer_id = "16Uiu2HAmLhLvBoYaoZfaMUKuibM6ac163GwKY74c5kiSLg5KvLpY" - relay_private_key = "0802122053DADF1D5A164D6B4ACDB15E24AA4C5B1D3461BDBD42ABEDB0A4404D56CED8FB" - whitelisted_peer_id = "QmaeANgBs1DTSxWSrPPtobgQuxW8XTfsS4ydbK4rCHzqxG" - blacklisted_peer_id = "12D3KooWBtg3aaRMjxwedh83aGiUkwSxDwUZkzuJcfaqUmo7R3pq" - node_private_keys = ["080012ae123082092a0201000282020100e1beab071d08200bde24eef00d049449b07770ff9910257b2d7d5dda242ce8f0e2f12e1af4b32d9efd2c090f66b0f29986dbb645dae9880089704a94e5066d594162ae6ee8892e6ec70701db0a6c445c04778eb3de1293aa1a23c3825b85c6620a2bc3f82f9b0c309bc0ab3aeb1873282bebd3da03c33e76c21e9beb172fd44c9e43be32e2c99827033cf8d0f0c606f4579326c930eb4e854395ad941256542c793902185153c474bed109d6ff5141ebf9cd256cf58893a37f83729f97e7cb435ec679d2e33901d27bb35aa0d7e20561da08885ef0abbf8e2fb48d6a5487047a9ecb1ad41fa7ed84f6e3e8ecd5d98b3982d2a901b4454991766da295ab78822add5612a2df83bcee814cf50973e80d7ef38111b1bd87da2ae92438a2c8cbcc70b31ee319939a3b9c761dbc13b5c086d6b64bf7ae7dacc14622375d92a8ff9af7eb962162bbddebf90acb32adb5e4e4029f1c96019949ecfbfeffd7ac1e3fbcc6b6168c34be3d5a2e5999fcbb39bba7adbca78eab09b9bc39f7fa4b93411f4cc175e70c0a083e96bfaefb04a9580b4753c1738a6a760ae1afd851a1a4bdad231cf56e9284d832483df215a46c1c21bdf0c6cfe951c18f1ee4078c79c13d63edb6e14feaeffabc90ad317e4875fe648101b0864097e998f0ca3025ef9638cd2b0caecd3770ab54a1d9c6ca959b0f5dcbc90caeefc4135baca6fd475224269bbe1b02030100010282020100a472ffa858efd8588ce59ee264b957452f3673acdf5631d7bfd5ba0ef59779c231b0bc838a8b14cae367b6d9ef572c03c7883b0a3c652f5c24c316b1ccfd979f13d0cd7da20c7d34d9ec32dfdc81ee7292167e706d705efde5b8f3edfcba41409e642f8897357df5d320d21c43b33600a7ae4e505db957c1afbc189d73f0b5d972d9aaaeeb232ca20eebd5de6fe7f29d01470354413cc9a0af1154b7af7c1029adcd67c74b4798afeb69e09f2cb387305e73a1b5f450202d54f0ef096fe1bde340219a1194d1ac9026e90b366cce0c59b239d10e4888f52ca1780824d39ae01a6b9f4dd6059191a7f12b2a3d8db3c2868cd4e5a5862b8b625a4197d52c6ac77710116ebd3ced81c4d91ad5fdfbed68312ebce7eea45c1833ca3acf7da2052820eacf5c6b07d086dabeb893391c71417fd8a4b1829ae2cf60d1749d0e25da19530d889461c21da3492a8dc6ccac7de83ac1c2185262c7473c8cc42f547cc9864b02a8073b6aa54a037d8c0de3914784e6205e83d97918b944f11b877b12084c0dd1d36592f8a4f8b8da5bb404c3d2c079b22b6ceabfbcb637c0dbe0201f0909d533f8bf308ada47aee641a012a494d31b54c974e58b87f140258258bb82f31692659db7aa07e17a5b2a0832c24e122d3a8babcc9ee74cbb07d3058bb85b15f6f6b2674aba9fd34367be9782d444335fbed31e3c4086c652597c27104938b47fa10282010100e9fdf843c1550070ca711cb8ff28411466198f0e212511c3186623890c0071bf6561219682fe7dbdfd81176eba7c4faba21614a20721e0fcd63768e6d925688ecc90992059ac89256e0524de90bf3d8a052ce6a9f6adafa712f3107a016e20c80255c9e37d8206d1bc327e06e66eb24288da866b55904fd8b59e6b2ab31bc5eab47e597093c63fab7872102d57b4c589c66077f534a61f5f65127459a33c91f6db61fc431b1ae90be92b4149a3255291baf94304e3efb77b1107b5a3bda911359c40a53c347ff9100baf8f36dc5cd991066b5bdc28b39ed644f404afe9213f4d31c9d4e40f3a5f5e3c39bebeb244e84137544e1a1839c1c8aaebf0c78a7fad590282010100f6fa1f1e6b803742d5490b7441152f500970f46feb0b73a6e4baba2aaf3c0e245ed852fc31d86a8e46eb48e90fac409989dfee45238f97e8f1f8e83a136488c1b04b8a7fb695f37b8616307ff8a8d63e8cfa0b4fb9b9167ffaebabf111aa5a4344afbabd002ae8961c38c02da76a9149abdde93eb389eb32595c29ba30d8283a7885218a5a9d33f7f01dbdf85f3aad016c071395491338ec318d39220e1c7bd69d3d6b520a13a30d745c102b827ad9984b0dd6aed73916ffa82a06c1c111e7047dcd2668f988a0570a71474992eecf416e068f029ec323d5d635fd24694fc9bf96973c255d26c772a95bf8b7f876547a5beabf86f06cd21b67994f944e7a5493028201010095b02fd30069e547426a8bea58e8a2816f33688dac6c6f6974415af8402244a22133baedf34ce499d7036f3f19b38eb00897c18949b0c5a25953c71aeeccfc8f6594173157cc854bd98f16dffe8f28ca13b77eb43a2730585c49fc3f608cd811bb54b03b84bddaa8ef910988567f783012266199667a546a18fd88271fbf63a45ae4fd4884706da8befb9117c0a4d73de5172f8640b1091ed8a4aea3ed4641463f5ff6a5e3401ad7d0c92811f87956d1fd5f9a1d15c7f3839a08698d9f35f9d966e5000f7cb2655d7b6c4adcd8a9d950ea5f61bb7c9a33c17508f9baa313eecfee4ae493249ebe05a5d7770bbd3551b2eeb752e3649e0636de08e3d672e66cb90282010100ad93e4c31072b063fc5ab5fe22afacece775c795d0efdf7c704cfc027bde0d626a7646fc905bb5a80117e3ca49059af14e0160089f9190065be9bfecf12c3b2145b211c8e89e42dd91c38e9aa23ca73697063564f6f6aa6590088a738722df056004d18d7bccac62b3bafef6172fc2a4b071ea37f31eff7a076bcab7dd144e51a9da8754219352aef2c73478971539fa41de4759285ea626fa3c72e7085be47d554d915bbb5149cb6ef835351f231043049cd941506a034bf2f8767f3e1e42ead92f91cb3d75549b57ef7d56ac39c2d80d67f6a2b4ca192974bfc5060e2dd171217971002193dba12e7e4133ab201f07500a90495a38610279b13a48d54f0c99028201003e3a1ac0c2b67d54ed5c4bbe04a7db99103659d33a4f9d35809e1f60c282e5988dddc964527f3b05e6cc890eab3dcb571d66debf3a5527704c87264b3954d7265f4e8d2c637dd89b491b9cf23f264801f804b90454d65af0c4c830d1aef76f597ef61b26ca857ecce9cb78d4f6c2218c00d2975d46c2b013fbf59b750c3b92d8d3ed9e6d1fd0ef1ec091a5c286a3fe2dead292f40f380065731e2079ebb9f2a7ef2c415ecbb488da98f3a12609ca1b6ec8c734032c8bd513292ff842c375d4acd1b02dfb206b24cd815f8e2f9d4af8e7dea0370b19c1b23cc531d78b40e06e1119ee2e08f6f31c6e2e8444c568d13c5d451a291ae0c9f1d4f27d23b3a00d60ad", "080112407e0830617c4a7de83925dfb2694556b12936c477a0e1feb2e148ec9da60fee7d1ed1e8fae2c4a144b8be8fd4b47bf3d3b34b871c3cacf6010f0e42d474fce27e"] -} - -resource "docker_image" "rosenet-node" { - provider = docker.node-machine - - build { - context = "../.." - dockerfile = "./tests/whitelist-relay/src/node/Dockerfile" - } - name = "rosenet-node" - - triggers = { - node_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-node/lib/**") : filesha1(f)])) - node_sha1 = filesha1("./src/node/node.ts") - dockerfile_sha1 = filesha1("./src/node/Dockerfile") - } -} - -resource "docker_image" "rosenet-relay" { - provider = docker.relay-machine - - build { - context = "../.." - dockerfile = "./tests/whitelist-relay/src/relay/Dockerfile" - } - name = "rosenet-relay" - - triggers = { - relay_package_sha1 = sha1(join("", [for f in fileset(path.module, "../../packages/rosenet-relay/lib/**") : filesha1(f)])) - relay_sha1 = filesha1("./src/relay/relay.ts") - dockerfile_sha1 = filesha1("./src/relay/Dockerfile") - } -} - -resource "docker_container" "rosenet-node" { - provider = docker.node-machine - - count = 2 - - name = "node-${count.index}" - image = docker_image.rosenet-node.image_id - env = ["RELAY_MULTIADDR=/ip4/${var.relay-ip}/tcp/33333/p2p/${local.relay_peer_id}", "PRIVATE_KEY=${local.node_private_keys[count.index]}"] - - depends_on = [docker_container.rosenet-relay] -} - -resource "docker_container" "rosenet-relay" { - provider = docker.relay-machine - - name = "relay" - image = docker_image.rosenet-relay.image_id - env = ["PRIVATE_KEY=${local.relay_private_key}", "WHITELISTED_PEER_ID=${local.whitelisted_peer_id}", "LISTEN_PORT=33333"] - ports { - internal = 33333 - external = 33333 - } -} - -data "docker_logs" "relay-logs" { - provider = docker.relay-machine - - name = docker_container.rosenet-relay.name - follow = true - - lifecycle { - postcondition { - # Check if whitelisted peer id is connected - condition = anytrue([for log in self.logs_list_string: can(regex("Peer connected.*${local.whitelisted_peer_id}", log))]) - error_message = "Whitelisted peer id was not connected to the relay" - } - postcondition { - # Check if blacklisted peer id is not connected - condition = !anytrue([for log in self.logs_list_string: can(regex("Peer connected.*${local.blacklisted_peer_id}", log))]) - error_message = "Blacklisted peer id was connected to the relay" - } - } - - depends_on = [docker_container.rosenet-node] -} diff --git a/tests/whitelist-relay/package.json b/tests/whitelist-relay/package.json deleted file mode 100644 index 055dd78..0000000 --- a/tests/whitelist-relay/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@rosenet-tests/whitelist-relay", - "private": true, - "version": "0.0.0", - "description": "RoseNet relay whitelist test", - "repository": "https://github.com/rosen-bridge/rosenet", - "license": "GPL-3.0", - "author": "Rosen Team", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "scripts": { - "lint": "eslint --fix . && npm run prettify", - "prettify": "prettier --write . --ignore-path ./.gitignore", - "start:node": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/node/node.ts", - "start:relay": "node --loader ./ts-node-esm-loader.js --loader extensionless ./src/relay/relay.ts", - "type-check": "tsc --noEmit" - }, - "devDependencies": { - "@types/node": "^20.11.9", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "extensionless": "^1.9.6", - "prettier": "^3.2.4", - "ts-node": "^10.7.0", - "tsconfig-paths": "^4.1.2", - "typescript": "^5.3.3" - }, - "dependencies": { - "@rosen-bridge/rosenet-node": "^0.0.0", - "@rosen-bridge/rosenet-relay": "^0.0.0" - } -} diff --git a/tests/whitelist-relay/src/node/Dockerfile b/tests/whitelist-relay/src/node/Dockerfile deleted file mode 100644 index a1dfc58..0000000 --- a/tests/whitelist-relay/src/node/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/whitelist-relay/package.json ./tests/whitelist-relay/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/whitelist-relay - -CMD npm run start:node diff --git a/tests/whitelist-relay/src/node/node.ts b/tests/whitelist-relay/src/node/node.ts deleted file mode 100644 index 4ae6f72..0000000 --- a/tests/whitelist-relay/src/node/node.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createRoseNetNode } from '@rosen-bridge/rosenet-node'; - -const node = await createRoseNetNode({ - logger: console, - relayMultiaddrs: [process.env.RELAY_MULTIADDR!], - privateKey: process.env.PRIVATE_KEY!, -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 20000); diff --git a/tests/whitelist-relay/src/relay/Dockerfile b/tests/whitelist-relay/src/relay/Dockerfile deleted file mode 100644 index b31f6a6..0000000 --- a/tests/whitelist-relay/src/relay/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM node:20.11 - -WORKDIR /app - -COPY package.json . -COPY package-lock.json . -COPY packages/rosenet-node/package.json ./packages/rosenet-node/ -COPY packages/rosenet-relay/package.json ./packages/rosenet-relay/ -COPY packages/utils/package.json ./packages/utils/ -COPY tests/whitelist-relay/package.json ./tests/whitelist-relay/ -RUN npm ci - -COPY . . -RUN npm run build - -WORKDIR /app/tests/whitelist-relay - -CMD npm run start:relay diff --git a/tests/whitelist-relay/src/relay/relay.ts b/tests/whitelist-relay/src/relay/relay.ts deleted file mode 100644 index 31ca572..0000000 --- a/tests/whitelist-relay/src/relay/relay.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { createRoseNetRelay } from '@rosen-bridge/rosenet-relay'; - -const node = await createRoseNetRelay({ - logger: console, - privateKey: process.env.PRIVATE_KEY!, - listen: { - host: '0.0.0.0', - port: Number(process.env.LISTEN_PORT), - }, - whitelist: [process.env.WHITELISTED_PEER_ID!], -}); - -node.start(); - -setTimeout(() => { - process.exit(0); -}, 25000); diff --git a/tests/whitelist-relay/ts-node-esm-loader.js b/tests/whitelist-relay/ts-node-esm-loader.js deleted file mode 100644 index 6a27e30..0000000 --- a/tests/whitelist-relay/ts-node-esm-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -import { resolve as resolveTs } from 'ts-node/esm'; -import * as tsConfigPaths from 'tsconfig-paths'; -import { pathToFileURL } from 'url'; - -const { absoluteBaseUrl, paths } = tsConfigPaths.loadConfig(); -const matchPath = tsConfigPaths.createMatchPath(absoluteBaseUrl, paths); - -export function resolve(specifier, ctx, defaultResolve) { - const match = matchPath(specifier); - return match - ? resolveTs(pathToFileURL(`${match}`).href, ctx, defaultResolve) - : resolveTs(specifier, ctx, defaultResolve); -} - -export { load, transformSource } from 'ts-node/esm'; diff --git a/tests/whitelist-relay/tsconfig.json b/tests/whitelist-relay/tsconfig.json deleted file mode 100644 index 42af8ed..0000000 --- a/tests/whitelist-relay/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "baseUrl": ".", - }, - "include": ["src"], - "ts-node": { - "esm": true, - }, - "references": [ - { - "path": "../../packages/rosenet-node/tsconfig.build.json", - }, - { - "path": "../../packages/rosenet-relay/tsconfig.build.json", - }, - ], -} diff --git a/tests/whitelist-relay/variables.tf b/tests/whitelist-relay/variables.tf deleted file mode 100644 index 46dec1a..0000000 --- a/tests/whitelist-relay/variables.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "node-host" { - type = string -} - -variable "relay-host" { - type = string -} - -variable "relay-ip" { - type = string -}