ethereum: deploy test token nonce race condition fix

Noticed this error happening in tilt sometimes:

[tests] Error: Returned error: VM Exception while processing transaction: the tx
doesn't have the correct nonce. account has nonce of: 17 tx has nonce of: 16

It's not safe to submit txs in parallel, because the nonce can get out of sync.
Instead we should submit them serially.
This commit is contained in:
Kevin Peters 2022-10-28 15:39:10 +00:00 committed by Evan Gray
parent 914aa99a60
commit 25d2f24b03
1 changed files with 6 additions and 11 deletions

View File

@ -16,19 +16,14 @@ const interateToStandardTransactionCount = async () => {
);
const transactionsToBurn = 32 - transactionCount;
const promises = [];
for (let i = 0; i < transactionsToBurn; i++) {
promises.push(
web3.eth.sendTransaction({
to: accounts[0],
from: accounts[0],
value: 530,
})
);
await web3.eth.sendTransaction({
to: accounts[0],
from: accounts[0],
value: 530,
})
}
await Promise.all(promises);
const burnCount = await web3.eth.getTransactionCount(accounts[0], "latest");
console.log("transaction count after burn: ", burnCount);
@ -36,7 +31,7 @@ const interateToStandardTransactionCount = async () => {
return Promise.resolve();
};
module.exports = async function(callback) {
module.exports = async function (callback) {
try {
const accounts = await web3.eth.getAccounts();