Skip to content

Commit 04f4b23

Browse files
committed
fix: scenario1 ensure deployer has enough funds
Signed-off-by: Tomás Migone <[email protected]>
1 parent f159e05 commit 04f4b23

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

e2e/scenarios/lib/accounts.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { BigNumber } from 'ethers'
3+
import { ethers } from 'hardhat'
24
import { NetworkContracts } from '../../../cli/contracts'
35
import { ensureETHBalance, ensureGRTBalance } from './helpers'
46

@@ -20,6 +22,22 @@ export const setupAccounts = async (
2022
...fixture.curators.map((c) => c.signer.address),
2123
]
2224

25+
// Ensure sender has enough funds to distribute
26+
const minEthBalance = BigNumber.from(fixture.ethAmount).mul(beneficiaries.length)
27+
const minGRTBalance = BigNumber.from(fixture.grtAmount).mul(beneficiaries.length)
28+
29+
const senderEthBalance = await ethers.provider.getBalance(sender.address)
30+
const senderGRTBalance = await contracts.GraphToken.balanceOf(sender.address)
31+
32+
if (senderEthBalance.lt(minEthBalance) || senderGRTBalance.lt(minGRTBalance)) {
33+
console.log(`Sender ETH balance: ${senderEthBalance}`)
34+
console.log(`Required ETH balance: ${minEthBalance}`)
35+
console.log(`Sender GRT balance: ${senderGRTBalance}`)
36+
console.log(`Required GRT balance: ${minGRTBalance}`)
37+
throw new Error(`Sender does not have enough funds to distribute.`)
38+
}
39+
40+
// Fund the accounts
2341
await ensureETHBalance(contracts, sender, beneficiaries, fixture.ethAmount)
2442

2543
for (const beneficiary of beneficiaries) {

0 commit comments

Comments
 (0)