Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-aranha-cw committed Aug 1, 2024
1 parent a479629 commit c6b8873
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Importer
name: E2E Leader & Follower

on:
pull_request:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion e2e/cloudwalk-contracts/integration/test/helpers/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -92,53 +92,53 @@ 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]);
return parseInt(block.timestamp, 16);
}),
);

// 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]);
return parseInt(block.timestamp, 16);
}),
);

// 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;
Expand All @@ -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");
Expand Down
20 changes: 10 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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="":
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c6b8873

Please sign in to comment.