Skip to content

Commit

Permalink
refactor(axon-tests): query the balance of every test account
Browse files Browse the repository at this point in the history
  • Loading branch information
Flouse committed Aug 7, 2023
1 parent bd255d9 commit 3ab7ef6
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions contracts/scripts/before-axon-devnet.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
const hardhat = require("hardhat");
const { ethers } = require("hardhat");

/*
* Deposit test accounts before running test.
*/
* Deposit for test accounts before running tests.
*/
async function main() {
const MIN_BALANCE = 100_000_000_000;
const ethers = hardhat.ethers;
const [a1, a2, genesis, a3, a4] = await ethers.getSigners();
if (await a1.getBalance() < MIN_BALANCE) {
await genesis.sendTransaction({ to: a1.address, value: MIN_BALANCE })
const signers = await ethers.getSigners();

// Query the balance of every test account
let [b1, b2, _bg, b3, b4] = signers.map(async account => {
const balance = await account.getBalance();
console.log(`native token balance of ${account.address}: ${balance.toString()}`);
return balance;
});

const [a1, a2, genesis, a3, a4] = signers;
if (await b1 < MIN_BALANCE) {
await genesis.sendTransaction({ to: a1.address, value: MIN_BALANCE });
}
if (await a2.getBalance() < MIN_BALANCE) {
await genesis.sendTransaction({ to: a2.address, value: MIN_BALANCE })
if (await b2 < MIN_BALANCE) {
await genesis.sendTransaction({ to: a2.address, value: MIN_BALANCE });
}
if (await a3.getBalance() < MIN_BALANCE) {
await genesis.sendTransaction({ to: a3.address, value: MIN_BALANCE })
if (await b3 < MIN_BALANCE) {
await genesis.sendTransaction({ to: a3.address, value: MIN_BALANCE });
}
if (await a4.getBalance() < MIN_BALANCE) {
await genesis.sendTransaction({ to: a4.address, value: MIN_BALANCE })
if (await b4 < MIN_BALANCE) {
await genesis.sendTransaction({ to: a4.address, value: MIN_BALANCE });
}
}

Expand All @@ -27,7 +35,8 @@ main()
console.error(error);
process.exit(1);
});

/**
* How to run this?
* > npx hardhat run scripts/before-axon-devnet.js --network axon_devnet
* > npx hardhat run scripts/before-axon-devnet.js --network axon_alphanet
*/

0 comments on commit 3ab7ef6

Please sign in to comment.