Skip to content

Commit

Permalink
use built in provider.send function
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed May 12, 2021
1 parent 72a1d09 commit 690f43d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions test/token/ERC20/extensions/draft-ERC20Votes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,21 @@ const Delegation = [
{ name: 'expiry', type: 'uint256' },
];

function send (method, params = []) {
return new Promise(resolve => web3.currentProvider.send({ jsonrpc: '2.0', method, params }, resolve));
}

async function batchInBlock (txs) {
await send('evm_setAutomine', [false]);
await network.provider.send('evm_setAutomine', [false]);

try {
const promises = txs.map(fn => fn());
await Promise.all(promises.map(p => events.once(p, 'transactionHash')));
await send('evm_mine');
await network.provider.send('evm_mine');
const receipts = await Promise.all(promises);

const minedBlocks = new Set(receipts.map(({ receipt }) => receipt.blockNumber));
expect(minedBlocks.size).to.equal(1);

return receipts;
} finally {
await send('evm_setAutomine', [true]);
await network.provider.send('evm_setAutomine', [true]);
}
}

Expand Down

0 comments on commit 690f43d

Please sign in to comment.