Skip to content

Commit

Permalink
Deploy only once for fork tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed May 22, 2024
1 parent 8c38ba2 commit 427ef88
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ out/
.vscode
brownie-deploy/
.idea
deployments-fork.json
deployments-fork*.json
broadcast/*
6 changes: 5 additions & 1 deletion script/deploy/DeployManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ contract DeployManager is Script {
mapping(string => address) public deployedContracts;
mapping(string => bool) public scriptsExecuted;

string internal forkFileId = "";

function isForked() public view returns (bool) {
return vm.isContext(VmSafe.ForgeContext.ScriptDryRun) || vm.isContext(VmSafe.ForgeContext.Test)
|| vm.isContext(VmSafe.ForgeContext.TestGroup);
Expand All @@ -28,10 +30,12 @@ contract DeployManager is Script {
}

function getForkDeploymentFilePath() public view returns (string memory) {
return string(abi.encodePacked(vm.projectRoot(), "/build/deployments-fork.json"));
return string(abi.encodePacked(vm.projectRoot(), "/build/deployments-fork-", forkFileId, ".json"));
}

function setUp() external {
forkFileId = Strings.toString(block.timestamp);

string memory chainIdStr = Strings.toString(block.chainid);
string memory chainIdKey = string(abi.encodePacked(".", chainIdStr));

Expand Down
4 changes: 3 additions & 1 deletion tests/governance/XOGNGovernanceForkTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ contract XOGNGovernanceForkTest is Test {

int256 constant NEW_STAKE = -1;

function setUp() external {
constructor() {
deployManager = new DeployManager();

deployManager.setUp();
deployManager.run();
}

function setUp() external {
xogn = ExponentialStaking(deployManager.getDeployment("XOGN"));
timelock = Timelock(payable(Addresses.TIMELOCK));
xognGov = Governance(payable(deployManager.getDeployment("XOGN_GOV")));
Expand Down
4 changes: 3 additions & 1 deletion tests/staking/MigratorForkTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ contract MigratorForkTest is Test {

address public ogvWhale = Addresses.GOV_MULTISIG;

function setUp() external {
constructor() {
deployManager = new DeployManager();

deployManager.setUp();
deployManager.run();
}

function setUp() external {
migrator = Migrator(deployManager.getDeployment("MIGRATOR"));

veogv = OgvStaking(Addresses.VEOGV);
Expand Down
4 changes: 3 additions & 1 deletion tests/staking/OGNRewardsSourceForkTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ contract OGNRewardsSourceForkTest is Test {

int256 constant NEW_STAKE = -1;

function setUp() external {
constructor() {
deployManager = new DeployManager();

deployManager.setUp();
deployManager.run();
}

function setUp() external {
xogn = ExponentialStaking(deployManager.getDeployment("XOGN"));
timelock = Timelock(payable(Addresses.TIMELOCK));
xognGov = Governance(payable(deployManager.getDeployment("XOGN_GOV")));
Expand Down
4 changes: 3 additions & 1 deletion tests/staking/XOGNStakingForkTest.t..sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ contract XOGNStakingForkTest is Test {

int256 constant NEW_STAKE = -1;

function setUp() external {
constructor() {
deployManager = new DeployManager();

deployManager.setUp();
deployManager.run();
}

function setUp() external {
xogn = ExponentialStaking(deployManager.getDeployment("XOGN"));
timelock = Timelock(payable(Addresses.TIMELOCK));
xognGov = Governance(payable(deployManager.getDeployment("XOGN_GOV")));
Expand Down

0 comments on commit 427ef88

Please sign in to comment.