mirror of
https://github.com/vacp2p/minime.git
synced 2026-01-08 21:17:56 -05:00
tests: port existing JS tests to foundry tests (#9)
This commit is contained in:
@@ -4,8 +4,36 @@ pragma solidity >=0.8.19 <=0.9.0;
|
||||
import { BaseScript } from "./Base.s.sol";
|
||||
import { DeploymentConfig } from "./DeploymentConfig.s.sol";
|
||||
|
||||
import { MiniMeToken } from "../contracts/MiniMeToken.sol";
|
||||
import { MiniMeTokenFactory } from "../contracts/MiniMeToken.sol";
|
||||
|
||||
contract Deploy is BaseScript {
|
||||
function run() public returns (DeploymentConfig deploymentConfig) {
|
||||
function run()
|
||||
public
|
||||
returns (DeploymentConfig deploymentConfig, MiniMeTokenFactory minimeFactory, MiniMeToken minimeToken)
|
||||
{
|
||||
deploymentConfig = new DeploymentConfig(broadcaster);
|
||||
(
|
||||
,
|
||||
address parentToken,
|
||||
uint256 parentSnapShotBlock,
|
||||
string memory name,
|
||||
uint8 decimals,
|
||||
string memory symbol,
|
||||
bool transferEnabled
|
||||
) = deploymentConfig.activeNetworkConfig();
|
||||
|
||||
vm.startBroadcast(broadcaster);
|
||||
minimeFactory = new MiniMeTokenFactory();
|
||||
minimeToken = new MiniMeToken(
|
||||
minimeFactory,
|
||||
MiniMeToken(payable(parentToken)),
|
||||
parentSnapShotBlock,
|
||||
name,
|
||||
decimals,
|
||||
symbol,
|
||||
transferEnabled
|
||||
);
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,12 @@ contract DeploymentConfig is Script {
|
||||
|
||||
struct NetworkConfig {
|
||||
address deployer;
|
||||
address parentToken;
|
||||
uint256 parentSnapShotBlock;
|
||||
string name;
|
||||
uint8 decimals;
|
||||
string symbol;
|
||||
bool transferEnabled;
|
||||
}
|
||||
|
||||
NetworkConfig public activeNetworkConfig;
|
||||
@@ -17,17 +23,25 @@ contract DeploymentConfig is Script {
|
||||
address private deployer;
|
||||
|
||||
constructor(address _broadcaster) {
|
||||
deployer = _broadcaster;
|
||||
if (block.chainid == 31_337) {
|
||||
activeNetworkConfig = getOrCreateAnvilEthConfig();
|
||||
} else {
|
||||
revert DeploymentConfig_NoConfigForChain(block.chainid);
|
||||
}
|
||||
if (_broadcaster == address(0)) revert DeploymentConfig_InvalidDeployerAddress();
|
||||
deployer = _broadcaster;
|
||||
}
|
||||
|
||||
function getOrCreateAnvilEthConfig() public view returns (NetworkConfig memory) {
|
||||
return NetworkConfig({ deployer: deployer });
|
||||
return NetworkConfig({
|
||||
deployer: deployer,
|
||||
parentToken: address(0),
|
||||
parentSnapShotBlock: 0,
|
||||
name: "MiniMe Test Token",
|
||||
decimals: 18,
|
||||
symbol: "MMT",
|
||||
transferEnabled: true
|
||||
});
|
||||
}
|
||||
|
||||
// This function is a hack to have it excluded by `forge coverage` until
|
||||
|
||||
Reference in New Issue
Block a user