Skip to content

Commit

Permalink
misc coverage increase (#993)
Browse files Browse the repository at this point in the history
* factory 100%

* fix return

* test insuffient liquidity case

* test insuffient liquidity case
  • Loading branch information
jrhea authored Apr 19, 2024
1 parent c2f8f0b commit 25231b2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/integrations/factory/HyperdriveFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,32 @@ contract HyperdriveFactoryBaseTest is HyperdriveTest {

return hyperdrive;
}

function test_deployTargetInvalidDeployerCoordinator(
address deployer,
address pool
) external {
deal(address(dai), deployer, CONTRIBUTION);

vm.startPrank(deployer);

dai.approve(address(deployerCoordinator), CONTRIBUTION);

deploymentId = keccak256(abi.encode(deploymentId));
salt = keccak256(abi.encode(salt));
config.vaultSharesToken = IERC20(pool);
vm.expectRevert(IHyperdriveFactory.InvalidDeployerCoordinator.selector);
factory.deployTarget(
deploymentId,
address(0),
config,
new bytes(0),
APR,
APR,
0,
salt
);
}
}

contract ERC4626FactoryMultiDeployTest is HyperdriveFactoryBaseTest {
Expand Down
13 changes: 13 additions & 0 deletions test/units/libraries/YieldSpaceMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ contract YieldSpaceMathTest is Test {
);
uint256 pythonResult4 = 78866.87433323538e18;
assertApproxEqAbs(result4, pythonResult4, 1e9);

// test y < dy
vm.expectRevert(
abi.encodeWithSelector(IHyperdrive.InsufficientLiquidity.selector)
);
yieldSpaceMath.calculateSharesInGivenBondsOutUp(
100000e18, // shareReserves
99e18, // bondReserves + s
100e18, // amountIn
1e18 - ONE.divDown(2e18).mulDown(timeStretch), // stretchedTimeElapsed
1e18, // c
1e18 // mu
);
}

// This test verifies that sane values won't result in the YieldSpace math
Expand Down

0 comments on commit 25231b2

Please sign in to comment.