-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beanstalk-3 pizzaman remediations (#1011)
- Loading branch information
Showing
14 changed files
with
474 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule forge-std
updated
18 files
+12 −6 | .github/workflows/ci.yml | |
+1 −3 | .github/workflows/sync.yml | |
+2 −2 | foundry.toml | |
+1 −1 | package.json | |
+1 −1 | src/StdAssertions.sol | |
+8 −17 | src/StdChains.sol | |
+3 −18 | src/StdInvariant.sol | |
+1 −1 | src/StdStorage.sol | |
+1 −1 | src/StdUtils.sol | |
+6 −204 | src/Vm.sol | |
+382 −401 | src/console.sol | |
+1,555 −1 | src/console2.sol | |
+5 −1 | src/mocks/MockERC721.sol | |
+4 −693 | src/safeconsole.sol | |
+7 −12 | test/StdChains.t.sol | |
+1 −1 | test/StdCheats.t.sol | |
+0 −8 | test/StdStorage.t.sol | |
+2 −2 | test/Vm.t.sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "forge-std/Test.sol"; | ||
import {TestHelper, IMockFBeanstalk} from "test/foundry/utils/TestHelper.sol"; | ||
import {MockFieldFacet} from "contracts/mocks/mockFacets/MockFieldFacet.sol"; | ||
import {MockSeasonFacet} from "contracts/mocks/mockFacets/MockSeasonFacet.sol"; | ||
import {C} from "contracts/C.sol"; | ||
|
||
contract ListingTest is TestHelper { | ||
// test accounts | ||
address[] farmers; | ||
|
||
MockFieldFacet field = MockFieldFacet(BEANSTALK); | ||
MockSeasonFacet season = MockSeasonFacet(BEANSTALK); | ||
|
||
function setUp() public { | ||
initializeBeanstalkTestState(true, false); | ||
|
||
season.siloSunrise(0); | ||
|
||
// initalize farmers from farmers (farmer0 == diamond deployer) | ||
farmers.push(users[1]); | ||
farmers.push(users[2]); | ||
|
||
// max approve. | ||
maxApproveBeanstalk(farmers); | ||
|
||
mintTokensToUsers(farmers, C.BEAN, MAX_DEPOSIT_BOUND); | ||
|
||
field.incrementTotalSoilE(1000e18); | ||
|
||
// mine 300 blocks | ||
vm.roll(300); | ||
|
||
//set temp | ||
bs.setYieldE(0); | ||
|
||
console.log("bs.activeField(): ", bs.activeField()); | ||
|
||
// sow 1000 | ||
vm.prank(users[1]); | ||
uint256 pods = bs.sow(1000e6, 0, 0); | ||
console.log("Pods: ", pods); | ||
vm.prank(users[2]); | ||
bs.sow(1000e6, 0, 0); | ||
} | ||
|
||
function testCreatePodListing_InvalidMinFillAmount() public { | ||
IMockFBeanstalk.PodListing memory podListing = IMockFBeanstalk.PodListing({ | ||
lister: users[1], | ||
fieldId: bs.activeField(), | ||
index: 0, | ||
start: 0, | ||
podAmount: 50, | ||
pricePerPod: 100, | ||
maxHarvestableIndex: 100, | ||
minFillAmount: 60, // Invalid: greater than podAmount | ||
mode: 0 | ||
}); | ||
|
||
vm.expectRevert("Marketplace: minFillAmount must be <= podAmount."); | ||
vm.prank(users[1]); | ||
bs.createPodListing(podListing); | ||
} | ||
|
||
function testCreatePodListing_ValidMinFillAmount() public { | ||
// no revert | ||
IMockFBeanstalk.PodListing memory podListing = IMockFBeanstalk.PodListing({ | ||
lister: users[1], | ||
fieldId: bs.activeField(), | ||
index: 0, | ||
start: 0, | ||
podAmount: 50, | ||
pricePerPod: 100, | ||
maxHarvestableIndex: 100, | ||
minFillAmount: 30, // Valid: less than or equal to podAmount | ||
mode: 0 | ||
}); | ||
vm.prank(users[1]); | ||
bs.createPodListing(podListing); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.