From c6b8873ad3c68480ee5b32f815a7f26b87d04890 Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Thu, 1 Aug 2024 11:30:04 -0300 Subject: [PATCH] rename --- ...e-importer.yml => e2e-leader-follower.yml} | 8 +- ...r.env.local => stratus-follower.env.local} | 0 .../integration/test/helpers/rpc.ts | 2 +- .../{importer.test.ts => leader-follower.ts} | 80 +++++++++---------- justfile | 20 ++--- 5 files changed, 55 insertions(+), 55 deletions(-) rename .github/workflows/{e2e-importer.yml => e2e-leader-follower.yml} (93%) rename config/{stratus-with-importer.env.local => stratus-follower.env.local} (100%) rename e2e/cloudwalk-contracts/integration/test/{importer.test.ts => leader-follower.ts} (72%) diff --git a/.github/workflows/e2e-importer.yml b/.github/workflows/e2e-leader-follower.yml similarity index 93% rename from .github/workflows/e2e-importer.yml rename to .github/workflows/e2e-leader-follower.yml index e61d77ba0..39ff969d6 100644 --- a/.github/workflows/e2e-importer.yml +++ b/.github/workflows/e2e-leader-follower.yml @@ -1,4 +1,4 @@ -name: E2E Importer +name: E2E Leader & Follower on: pull_request: @@ -26,10 +26,10 @@ on: - 'Cargo.toml' jobs: - importer_test: + leader_follower_test: strategy: fail-fast: false - name: E2E Importer on BRLCToken + name: E2E Leader & Follower on BRLCToken runs-on: ubuntu-latest timeout-minutes: 45 @@ -78,7 +78,7 @@ jobs: run: just contracts-flatten --token - name: Run e2e tests - run: just e2e-importer-online-up + run: just e2e-leader-follower-up env: CARGO_PROFILE_RELEASE_DEBUG: 0 RUST_LOG: error diff --git a/config/stratus-with-importer.env.local b/config/stratus-follower.env.local similarity index 100% rename from config/stratus-with-importer.env.local rename to config/stratus-follower.env.local diff --git a/e2e/cloudwalk-contracts/integration/test/helpers/rpc.ts b/e2e/cloudwalk-contracts/integration/test/helpers/rpc.ts index 8ca9a1392..19529083f 100644 --- a/e2e/cloudwalk-contracts/integration/test/helpers/rpc.ts +++ b/e2e/cloudwalk-contracts/integration/test/helpers/rpc.ts @@ -44,7 +44,7 @@ export let ETHERJS = new JsonRpcProvider(providerUrl, undefined); export function updateProviderUrl(providerName: string) { switch (providerName) { - case "importer": + case "stratus-follower": providerUrl = "http://localhost:3001?app=e2e"; break; case "stratus": diff --git a/e2e/cloudwalk-contracts/integration/test/importer.test.ts b/e2e/cloudwalk-contracts/integration/test/leader-follower.ts similarity index 72% rename from e2e/cloudwalk-contracts/integration/test/importer.test.ts rename to e2e/cloudwalk-contracts/integration/test/leader-follower.ts index 451125a55..e9c23d0fc 100644 --- a/e2e/cloudwalk-contracts/integration/test/importer.test.ts +++ b/e2e/cloudwalk-contracts/integration/test/leader-follower.ts @@ -13,7 +13,7 @@ import { updateProviderUrl, } from "./helpers/rpc"; -describe("Importer integration test", function () { +describe("Leader & Follower integration test", function () { before(async function () { await setDeployer(); }); @@ -92,10 +92,10 @@ describe("Importer integration test", function () { } }); - it(`${params.name}: Validate transaction mined delay between Stratus and Importer`, async function () { - // Get Stratus timestamps + it(`${params.name}: Validate transaction mined delay between Stratus Leader & Follower`, async function () { + // Get Stratus Leader timestamps updateProviderUrl("stratus"); - const stratusTimestamps = await Promise.all( + const leaderTimestamps = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash]); const block = await sendWithRetry("eth_getBlockByNumber", [receipt.blockNumber, false]); @@ -103,9 +103,9 @@ describe("Importer integration test", function () { }), ); - // Get Importer timestamps - updateProviderUrl("importer"); - const importerTimestamps = await Promise.all( + // Get Stratus Follower timestamps + updateProviderUrl("stratus-follower"); + const followerTimestamps = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash], 20); const block = await sendWithRetry("eth_getBlockByNumber", [receipt.blockNumber, false]); @@ -113,32 +113,32 @@ describe("Importer integration test", function () { }), ); - // Total time it took for Stratus to process all the blocks containing transactions - const stratusProcessingTime = stratusTimestamps[stratusTimestamps.length - 1] - stratusTimestamps[0]; + // Total time it took for Stratus Leader to process all the blocks containing transactions + const leaderProcessingTime = leaderTimestamps[leaderTimestamps.length - 1] - leaderTimestamps[0]; - // Total time it took for Importer to process all the blocks containing transactions - const importerProcessingTime = - importerTimestamps[importerTimestamps.length - 1] - importerTimestamps[0]; + // Total time it took for Stratus Follower to process all the blocks containing transactions + const followerProcessingTime = + followerTimestamps[followerTimestamps.length - 1] - followerTimestamps[0]; console.log(` ✔ Number of transactions sent: ${txHashList.length}`); console.log( - ` ✔ Stratus processing time: ${stratusProcessingTime}s | Importer processing time: ${importerProcessingTime}s`, + ` ✔ Stratus Leader processing time: ${leaderProcessingTime}s | Stratus Follower processing time: ${followerProcessingTime}s`, ); }); - it(`${params.name}: Validate all transactions were imported from Stratus to Importer`, async function () { - // Get Stratus transaction receipts + it(`${params.name}: Validate all transactions were imported from Stratus Leader to Follower`, async function () { + // Get Stratus Leader transaction receipts updateProviderUrl("stratus"); - const stratusReceipts = await Promise.all( + const leaderReceipts = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash]); return receipt; }), ); - // Get Importer transaction receipts - updateProviderUrl("importer"); - const importerReceipts = await Promise.all( + // Get Stratus Follower transaction receipts + updateProviderUrl("stratus-follower"); + const followerReceipts = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash]); return receipt; @@ -147,53 +147,53 @@ describe("Importer integration test", function () { // Assert that all transactions were imported for (let i = 0; i < txHashList.length; i++) { - expect(stratusReceipts[i]).to.exist; - expect(importerReceipts[i]).to.exist; + expect(leaderReceipts[i]).to.exist; + expect(followerReceipts[i]).to.exist; } }); - it(`${params.name}: Validate each transaction was imported into the same block between Stratus and Importer`, async function () { - // Get Stratus block numbers + it(`${params.name}: Validate each transaction was imported into the same block between Stratus Leader and Follower`, async function () { + // Get Stratus Leader block numbers updateProviderUrl("stratus"); - const stratusBlockNumbers = await Promise.all( + const leaderBlockNumbers = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash]); return receipt.blockNumber; }), ); - // Get Importer block numbers - updateProviderUrl("importer"); - const importerBlockNumbers = await Promise.all( + // Get Stratus Follower block numbers + updateProviderUrl("stratus-follower"); + const followerBlockNumbers = await Promise.all( txHashList.map(async (txHash) => { const receipt = await sendWithRetry("eth_getTransactionReceipt", [txHash], 20); return receipt.blockNumber; }), ); - // Assert that each transaction fell into the same block between Stratus and Importer + // Assert that each transaction fell into the same block between Stratus Leader and Follower for (let i = 0; i < txHashList.length; i++) { expect( - stratusBlockNumbers[i], - `Transaction ${txHashList[i]} did not fall into the same block between Stratus and Importer`, - ).to.equal(importerBlockNumbers[i]); + leaderBlockNumbers[i], + `Transaction ${txHashList[i]} did not fall into the same block between Stratus Leader and Follower`, + ).to.equal(followerBlockNumbers[i]); } }); - it(`${params.name}: Validate balances between Stratus and Importer`, async function () { + it(`${params.name}: Validate balances between Stratus Leader and Follower`, async function () { for (let i = 0; i < wallets.length; i++) { - // Get Stratus balance + // Get Stratus Leader balance updateProviderUrl("stratus"); - const stratusBalance = await brlcToken.balanceOf(wallets[i].address); + const leaderBalance = await brlcToken.balanceOf(wallets[i].address); - // Get Importer balance - updateProviderUrl("importer"); - const importerBalance = await brlcToken.balanceOf(wallets[i].address); + // Get Stratus Follower balance + updateProviderUrl("stratus-follower"); + const followerBalance = await brlcToken.balanceOf(wallets[i].address); // Assert that the balances are equal - expect(stratusBalance).to.equal( - importerBalance, - `Wallet ${wallets[i].address} balances are not equal between Stratus and Importer`, + expect(leaderBalance).to.equal( + followerBalance, + `Wallet ${wallets[i].address} balances are not equal between Stratus Leader and Follower`, ); } updateProviderUrl("stratus"); diff --git a/justfile b/justfile index e8d34d055..b6e883218 100644 --- a/justfile +++ b/justfile @@ -90,8 +90,8 @@ stratus *args="": cargo {{nightly_flag}} run --bin stratus {{release_flag}} --features dev -- --leader {{args}} # Bin: Stratus main service as follower -stratus-with-importer *args="": - LOCAL_ENV_PATH=stratus-with-importer cargo {{nightly_flag}} run --bin stratus {{release_flag}} --features dev -- --follower {{args}} +stratus-follower *args="": + LOCAL_ENV_PATH=stratus-follower cargo {{nightly_flag}} run --bin stratus {{release_flag}} --features dev -- --follower {{args}} # Bin: Download external RPC blocks and receipts to temporary storage rpc-downloader *args="": @@ -256,18 +256,18 @@ e2e-flamegraph: just _log "Running cargo flamegraph" cargo flamegraph --bin importer-online --deterministic --features dev -- --external-rpc=http://localhost:3003/rpc --chain-id=2009 -e2e-importer-online: +e2e-leader-follower: #!/bin/bash - just e2e-importer-online-up + just e2e-leader-follower-up result_code=$? - just e2e-importer-online-down + just e2e-leader-follower-down exit $result_code -# E2E: Importer Online -e2e-importer-online-up: +# E2E: Leader & Follower Up +e2e-leader-follower-up: #!/bin/bash # Build Stratus binary @@ -292,7 +292,7 @@ e2e-importer-online-up: ( cd e2e/cloudwalk-contracts/integration npm install - npx hardhat test test/importer.test.ts --network stratus --bail + npx hardhat test test/leader-follower.test.ts --network stratus --bail if [ $? -ne 0 ]; then just _log "Tests failed" exit 1 @@ -303,8 +303,8 @@ e2e-importer-online-up: ) fi -# E2E: Importer Online -e2e-importer-online-down: +# E2E: Leader & Follower Down +e2e-leader-follower-down: #!/bin/bash # Kill Stratus