generated from storming0x/foundry_strategy_mix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StrategyMigration.t.sol
38 lines (32 loc) · 1.32 KB
/
StrategyMigration.t.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
33
34
35
36
37
38
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.12;
import {StrategyFixture} from "./utils/StrategyFixture.sol";
// NOTE: if the name of the strat or file changes this needs to be updated
import {Strategy} from "../Strategy.sol";
contract StrategyMigrationTest is StrategyFixture {
function setUp() public override {
super.setUp();
}
// TODO: Add tests that show proper migration of the strategy to a newer one
// Use another copy of the strategy to simmulate the migration
// Show that nothing is lost.
function testMigration(uint256 _amount) public {
vm.assume(_amount > minFuzzAmt && _amount < maxFuzzAmt);
deal(address(want), user, _amount);
// Deposit to the vault and harvest
vm.prank(user);
want.approve(address(vault), _amount);
vm.prank(user);
vault.deposit(_amount);
skip(1);
vm.prank(strategist);
strategy.harvest();
assertRelApproxEq(strategy.estimatedTotalAssets(), _amount, DELTA);
// Migrate to a new strategy
vm.prank(strategist);
Strategy newStrategy = Strategy(deployStrategy(address(vault)));
vm.prank(gov);
vault.migrateStrategy(address(strategy), address(newStrategy));
assertRelApproxEq(newStrategy.estimatedTotalAssets(), _amount, DELTA);
}
}