mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-08 08:03:06 +00:00
add load generator
This commit is contained in:
parent
a0afbccc99
commit
365fa7c8b9
31
sz-poc-offsite-2025/evm/load/load.js
Normal file
31
sz-poc-offsite-2025/evm/load/load.js
Normal file
@ -0,0 +1,31 @@
|
||||
// load-script-rate.js
|
||||
import { ethers } from "ethers";
|
||||
|
||||
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
async function main() {
|
||||
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
|
||||
const sender = ethers.Wallet.fromPhrase(
|
||||
"test test test test test test test test test test test junk"
|
||||
).connect(provider);
|
||||
|
||||
const to = "0x1000000000000000000000000000000000000000";
|
||||
const value = ethers.parseEther("0.01");
|
||||
const maxTxs = 10000; // total number of txs to send
|
||||
|
||||
console.log(`Sending up to ${maxTxs} txs at ~1 tx/s…`);
|
||||
let nonce = await provider.getTransactionCount(sender.address);
|
||||
|
||||
for (let i = 0; i < maxTxs; i++) {
|
||||
// fire‐and‐forget each sendTransaction
|
||||
sender.sendTransaction({ to, value, gasLimit: 21_000, nonce: nonce + i })
|
||||
.then(tx => console.log(` → tx #${i} sent: ${tx.hash}`))
|
||||
.catch(err => console.error(` ! error on tx #${i}:`, err));
|
||||
|
||||
await sleep(1000);
|
||||
}
|
||||
|
||||
console.log("Done scheduling txs.");
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
3
sz-poc-offsite-2025/evm/load/package.json
Normal file
3
sz-poc-offsite-2025/evm/load/package.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user