Skip to content

Commit c623bb1

Browse files
authored
Merge pull request #16 from fidlabs/feature/utests
unit tests
2 parents 9f7512f + 476b932 commit c623bb1

33 files changed

+1963
-27
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ PROXY_ADDRESS_CALIBNET=
1414
PROXY_ADDRESS_MAINNET=
1515

1616
# For Mainnet deployment
17+
# Collateral deposit per CID in wei (1 FIL = 10^18 wei)
1718
COLLATERAL_PER_CID=100000000000000000 # 0.1 FIL
19+
# Minimum required storage providers and maximum replicas
20+
# Note: This is a critical configuration that should be set according to your contract requirements.
21+
# It defines the number of storage providers picked for each allocation package
1822
MIN_REQUIRED_STORAGE_PROVIDERS=2
23+
# Maximum replicas to available for users for each CID in an allocation package
24+
# Minimum is 1, maximum has to be less than or equal to the number of storage providers
1925
MAX_REPLICAS=3
2026

2127
# For Devnet bash deploy scripts

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,14 @@ PROXY_ADDRESS_CALIBNET=
229229
PROXY_ADDRESS_MAINNET=
230230
231231
# For Mainnet deployment
232+
# Collateral deposit per CID in wei (1 FIL = 10^18 wei)
232233
COLLATERAL_PER_CID=100000000000000000 # 0.1 FIL
233-
MIN_REQUIRED_STORAGE_PROVIDERS=2
234+
# Minimum required storage providers and maximum replicas
235+
# Note: This is a critical configuration that should be set according to your contract requirements.
236+
# It defines the number of storage providers picked for each allocation package
237+
MIN_REQUIRED_STORAGE_PROVIDERS=2
238+
# Maximum replicas to available for users for each CID in an allocation package
239+
# Minimum is 1, maximum has to be less than or equal to the number of storage providers
234240
MAX_REPLICAS=3
235241
236242
# For Devnet bash deploy scripts

src/diamond/DiamondCutFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {LibDiamond} from "../libraries/LibDiamond.sol";
1515

1616
contract DiamondCutFacet is IFacet, IDiamondCut {
1717
// get the function selectors for this facet for deployment and update scripts
18-
function selectors() external pure returns (bytes4[] memory) {
18+
function selectors() external pure virtual returns (bytes4[] memory) {
1919
bytes4[] memory _selectors = new bytes4[](1);
2020
_selectors[0] = this.diamondCut.selector;
2121
return _selectors;

src/diamond/DiamondLoupeFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {IERC165} from "../interfaces/IERC165.sol";
1515

1616
contract DiamondLoupeFacet is IFacet, IDiamondLoupe, IERC165 {
1717
// get the function selectors for this facet for deployment and update scripts
18-
function selectors() external pure returns (bytes4[] memory) {
18+
function selectors() external pure virtual returns (bytes4[] memory) {
1919
bytes4[] memory _selectors = new bytes4[](4);
2020
_selectors[0] = this.facets.selector;
2121
_selectors[1] = this.facetFunctionSelectors.selector;

src/facets/AllocateFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract AllocateFacet is IFacet, Modifiers, PausableUpgradeable {
2323
using AllocationResponseCbor for DataCapTypes.TransferReturn;
2424

2525
// get the function selectors for this facet for deployment and update scripts
26-
function selectors() external pure returns (bytes4[] memory selectors_) {
26+
function selectors() external pure virtual returns (bytes4[] memory selectors_) {
2727
selectors_ = new bytes4[](1);
2828
selectors_[0] = this.allocate.selector;
2929
}

src/facets/AllocatorManagerFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {IFacet} from "../interfaces/IFacet.sol";
1212
*/
1313
contract AllocatorManagerFacet is IFacet, Modifiers {
1414
// get the function selectors for this facet for deployment and update scripts
15-
function selectors() external pure returns (bytes4[] memory selectors_) {
15+
function selectors() external pure virtual returns (bytes4[] memory selectors_) {
1616
selectors_ = new bytes4[](3);
1717
selectors_[0] = this.addAllocator.selector;
1818
selectors_[1] = this.removeAllocator.selector;

src/facets/DevnetFacet.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import {IFacet} from "../interfaces/IFacet.sol";
66
import {Modifiers} from "../Modifiers.sol";
77

88
contract DevnetFacet is IFacet, Modifiers {
9-
error NotOnDevnet();
9+
error NotOnDevnet(uint256 chainId);
1010

11+
/**
12+
* @notice Build-in protection against deploying this facet on mainnet or testnet.
13+
* 314159 - calibnet
14+
* 31415926 - localnet / devenet
15+
* 31337 - hardhat localnet
16+
*/
1117
constructor() {
12-
if (block.chainid != 31415926 && block.chainid != 314159) {
13-
revert NotOnDevnet();
18+
if (block.chainid != 31415926 && block.chainid != 314159 && block.chainid != 31337) {
19+
revert NotOnDevnet(block.chainid);
1420
}
1521
}
1622

src/facets/FilecoinFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ contract FilecoinFacet is IFacet {
1414
address private constant _DATACAP_ADDRESS = address(0xfF00000000000000000000000000000000000007);
1515

1616
// get the function selectors for this facet for deployment and update scripts
17-
function selectors() external pure returns (bytes4[] memory selectors_) {
17+
function selectors() external pure virtual returns (bytes4[] memory selectors_) {
1818
selectors_ = new bytes4[](1);
1919
selectors_[0] = this.handle_filecoin_method.selector;
2020
}

src/facets/OwnerFacet.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {IFacet} from "../interfaces/IFacet.sol";
1515
*/
1616
contract OwnerFacet is IFacet, Modifiers, PausableUpgradeable {
1717
// get the function selectors for this facet for deployment and update scripts
18-
function selectors() external pure returns (bytes4[] memory selectors_) {
18+
function selectors() external pure virtual returns (bytes4[] memory selectors_) {
1919
selectors_ = new bytes4[](7);
2020
selectors_[0] = this.setCollateralPerCID.selector;
2121
selectors_[1] = this.setMinRequiredStorageProviders.selector;
@@ -61,7 +61,7 @@ contract OwnerFacet is IFacet, Modifiers, PausableUpgradeable {
6161

6262
function setDataCapTermMaxDays(int64 dataCapTermMaxDays) external onlyOwner {
6363
if (
64-
dataCapTermMaxDays <= FilecoinEpochCalculator.TERM_MIN
64+
dataCapTermMaxDays <= FilecoinEpochCalculator.TERM_MIN_IN_DAYS
6565
|| dataCapTermMaxDays > FilecoinEpochCalculator.FIVE_YEARS_IN_DAYS
6666
) {
6767
revert ErrorLib.InvalidDataCapTermMaxDays();

src/facets/OwnershipFacet.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {ErrorLib} from "../libraries/Errors.sol";
88

99
contract OwnershipFacet is IFacet, IERC173 {
1010
// get the function selectors for this facet for deployment and update scripts
11-
function selectors() external pure override returns (bytes4[] memory selectors_) {
11+
function selectors() external pure virtual override returns (bytes4[] memory selectors_) {
1212
selectors_ = new bytes4[](4);
1313
selectors_[0] = this.transferOwnership.selector;
1414
selectors_[1] = this.owner.selector;

0 commit comments

Comments
 (0)