Skip to content

Commit

Permalink
implementation of a test for insufficiant balance problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfingNerd committed Jan 12, 2022
1 parent 1858265 commit 0c35c39
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/regression/runInsufficiantBalanceSpam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { ConfigManager } from "../configManager";
import { BigNumber } from "bignumber.js";


async function sleep(milliseconds: number) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}

export async function insufficientBalanceTest() {

console.log('testing block proposals with invalid transactions lead to 0-tx-Blocks');
Expand Down Expand Up @@ -72,24 +76,31 @@ export async function insufficientBalanceTest() {

// now track if the blockchain is creating empty blocks or not for a time.
// concept:
// const secondsToCheck = 60;
const secondsToCheck = 60;

// let now = new Date(Date.now());
// const end = new Date();
// end.setSeconds(now.getSeconds() + secondsToCheck);
let now = new Date(Date.now());
const end = new Date();
end.setSeconds(now.getSeconds() + secondsToCheck);

// let lastCheckedBlock = await web3.eth.getBlockNumber();
let lastCheckedBlock = await web3.eth.getBlockNumber();

// while(Date.now() < end.getDate()) {
do {
const currentBlock = await web3.eth.getBlockNumber();


// }
if (currentBlock > lastCheckedBlock) {
const block = await web3.eth.getBlock(currentBlock);
const countOfTransactions = block.transactions.length;
if (countOfTransactions === 0) {
console.log('empty block found in block', currentBlock);
}

await sleep(333);
}

// anzeigen
const back2Result = await txback_2;
} while(Date.now() < end.getDate())

console.log('Uh it worked!!');
// const back2Result = await txback_2;
// console.log('Uh it worked!!');
}


Expand Down

0 comments on commit 0c35c39

Please sign in to comment.