-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtilities.sol
32 lines (27 loc) · 1.09 KB
/
Utilities.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "forge-std/Test.sol";
contract Utilities is Test {
bytes32 internal nextUser = keccak256(abi.encodePacked("user address"));
function getNextUserAddress() external returns (address payable) {
//bytes32 to address conversion
address payable user = payable(address(uint160(uint256(nextUser))));
nextUser = keccak256(abi.encodePacked(nextUser));
return user;
}
/// @notice create users with 100 ether balance
function createUsers(uint256 userNum) external returns (address payable[] memory) {
address payable[] memory users = new address payable[](userNum);
for (uint256 i = 0; i < userNum; i++) {
address payable user = this.getNextUserAddress();
vm.deal(user, 100 ether);
users[i] = user;
}
return users;
}
/// @notice move block.number forward by a given number of blocks
function mineBlocks(uint256 numBlocks) external {
uint256 targetBlock = block.number + numBlocks;
vm.roll(targetBlock);
}
}