From a888da149a46d0173c523d18d393b32739e5c7c6 Mon Sep 17 00:00:00 2001 From: Sam MacPherson Date: Fri, 15 Mar 2024 08:18:20 -0400 Subject: [PATCH] return 0 target assets when disabled --- src/plans/D3MOperatorPlan.sol | 2 ++ src/tests/plans/D3MOperatorPlan.t.sol | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plans/D3MOperatorPlan.sol b/src/plans/D3MOperatorPlan.sol index 847c7042..f8f884b8 100644 --- a/src/plans/D3MOperatorPlan.sol +++ b/src/plans/D3MOperatorPlan.sol @@ -80,6 +80,8 @@ contract D3MOperatorPlan is ID3MPlan { } function getTargetAssets(uint256) external override view returns (uint256) { + if (enabled == 0) return 0; + return targetAssets; } diff --git a/src/tests/plans/D3MOperatorPlan.t.sol b/src/tests/plans/D3MOperatorPlan.t.sol index d3686cbb..a782df98 100644 --- a/src/tests/plans/D3MOperatorPlan.t.sol +++ b/src/tests/plans/D3MOperatorPlan.t.sol @@ -84,7 +84,7 @@ contract D3MOperatorPlanTest is D3MPlanBaseTest { function test_implements_getTargetAssets() public { _setupOperatorAndTargetAssets(); - uint256 result = plan.getTargetAssets(123e18); + uint256 result = plan.getTargetAssets(123e18); // argument doesn't matter assertEq(result, 100e18); } @@ -94,11 +94,15 @@ contract D3MOperatorPlanTest is D3MPlanBaseTest { assertEq(plan.enabled(), 1); assertTrue(plan.active()); + assertEq(plan.getTargetAssets(0), 100e18); + vm.expectEmit(true, true, true, true); emit Disable(); plan.disable(); + assertTrue(!plan.active()); assertEq(plan.enabled(), 0); + assertEq(plan.getTargetAssets(0), 0); // returns 0 when disabled } }