Skip to content

Commit

Permalink
#1751 multiple transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Jan 15, 2024
1 parent e6f7572 commit 3995d47
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions test/historicstate/hardhat/scripts/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function getTraceJsonOptions(_tracer: string): Promise<object> {

const TEST_CONTRACT_DEPLOY_FILE_NAME = TEST_CONTRACT_NAME + ".deploy.defaultTracer.json";
const TEST_CONTRACT_RUN_FILE_NAME = TEST_CONTRACT_NAME + "." + RUN_FUNCTION_NAME + ".defaultTracer.json";
const TEST_TRANSFER_FILE_NAME = TEST_CONTRACT_NAME + ".transfer.defaultTracer.json";
const TEST_CONTRACT_CALL_DEFAULTTRACER_FILE_NAME = TEST_CONTRACT_NAME + "." + CALL_FUNCTION_NAME + ".defaultTracer.json";
const TEST_CONTRACT_CALL_CALLTRACER_FILE_NAME = TEST_CONTRACT_NAME + "." + CALL_FUNCTION_NAME + ".callTracer.json";
const TEST_CONTRACT_CALL_PRESTATETRACER_FILE_NAME = TEST_CONTRACT_NAME + "." + CALL_FUNCTION_NAME + ".prestateTracer.json";
Expand Down Expand Up @@ -149,7 +150,7 @@ async function getBlockTrace(blockNumber: number): Promise<String> {

async function getAndPrintTransactionTrace(hash: string, _skaleFileName: string): Promise<String> {

console.log("Calling debug_traceTransaction to generate " + _skaleFileName);
console.log("Calling debug_traceTransaction to generate " + _skaleFileName + " for tx " + hash);

const trace = await ethers.provider.send('debug_traceTransaction', [hash, {}]);

Expand Down Expand Up @@ -215,13 +216,44 @@ async function sendMoneyWithoutConfirmation(): Promise<int> {

// Send the transaction and wait until it is submitted ot the queue
const txResponse = signer.sendTransaction(tx);
//await txResponse.wait();

if (hre.network.name == "geth") {
await txResponse;
}

console.log(`Submitted a tx to send 0.1 ETH to ${newWallet.address}`);

return currentNonce;
}

async function sendMoneyWithConfirmation() : Promise<string> {
// Generate a new wallet
const newWallet = generateNewWallet();

await sleep(3000); // Sleep for 1000 milliseconds (1 second)

// Get the first signer from Hardhat's local network
const [signer] = await hre.ethers.getSigners();

const currentNonce = await signer.getTransactionCount();

// Define the transaction
const tx = {
to: newWallet.address,
value: hre.ethers.utils.parseEther("0.1"),
};

// Send the transaction and wait until it is submitted ot the queue
const txResponse = await signer.sendTransaction(tx);
const txReceipt = await txResponse.wait();

console.log(`Submitted a tx to send 0.1 ETH to ${newWallet.address}`);

return txReceipt.transactionHash!;
}



async function callTestContractRun(deployedContract: any): Promise<void> {

let currentNonce : int = await sendMoneyWithoutConfirmation();
Expand All @@ -237,6 +269,10 @@ async function callTestContractRun(deployedContract: any): Promise<void> {
await getAndPrintTransactionTrace(transferReceipt.hash, TEST_CONTRACT_RUN_FILE_NAME);
await getBlockTrace(transferReceipt.blockNumber);

const transferHash : string = await sendMoneyWithConfirmation();
await getAndPrintTransactionTrace(transferHash, TEST_TRANSFER_FILE_NAME);


}

async function callDebugTraceCall(_deployedContract: any, _tracer: string, _traceFileName: string): Promise<void> {
Expand Down

0 comments on commit 3995d47

Please sign in to comment.