async function runTest (count) {
const contract = await deployContract(contractCompiled.abi, contractCompiled.bin, signer)
const len = userAddresses.length
const amount = ethers.BigNumber.from(100000)
const txhashes = []
const receipts = []
const balances = {}
const amountsPerUser = {}
const overrides = {
gasLimit: 60000,
}
for (let user of userAddresses) {
balances[user] = await contract.balanceOf(user)
amountsPerUser[user] = ethers.BigNumber.from(0)
}
for (let i = 0; i < count; i++) {
const user = userAddresses[i % len]
const maxPriorityFeePerGas = 250000000 + Math.floor(Math.random() * 10000000)
const maxFeePerGas = maxPriorityFeePerGas + Math.floor(Math.random() * 10000)
const _overrides = {
...overrides,
maxFeePerGas,
maxPriorityFeePerGas,
}
let receipt = await contract.mintFor(amount, user, _overrides)
amountsPerUser[user] = amountsPerUser[user].add(amount)
txhashes.push(receipt)
}
console.log('txhashes', txhashes.length)
mutable resultShow = 'tx: ' + txhashes.length + '\n'
for (let i = 0; i < count; i++) {
const user = userAddresses[i % len]
let receipt = txhashes[i]
receipt = await receipt.wait()
receipts.push(receipt)
const stat = `block ${receipt.blockNumber} gasUsed ${receipt.gasUsed.toString()} ; cumulativeGasUsed ${receipt.cumulativeGasUsed.toString()} ; effectiveGasPrice ${receipt.cumulativeGasUsed.toString()}`
mutable resultShow += stat + '\n'
console.log(stat)
}
for (let i in userAddresses) {
const user = userAddresses[i]
const balance = await contract.balanceOf(user)
const expectedBalance = balances[user].add(amountsPerUser[user])
if (!balance.eq(expectedBalance)) throw new Error(`User ${i}: Balance ${balance} not equal to ${expectedBalance}`)
}
return receipts;
}