@@ -803,9 +803,9 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
803803
804804 // First batch (3 pieces) with key "meta" => metadataShort
805805 Cids.Cid[] memory pieceData1 = new Cids.Cid [](3 );
806- pieceData1[0 ].data = bytes ( "1_0:1111 " );
807- pieceData1[1 ].data = bytes ( "1_1:111100000 " );
808- pieceData1[2 ].data = bytes ( "1_2:11110000000000 " );
806+ pieceData1[0 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( "1_0:1111 " )) );
807+ pieceData1[1 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( "1_1:111100000 " )) );
808+ pieceData1[2 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( "1_2:11110000000000 " )) );
809809 string [] memory keys1 = new string [](1 );
810810 string [] memory values1 = new string [](1 );
811811 keys1[0 ] = "meta " ;
@@ -817,8 +817,10 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
817817
818818 // Second batch (2 pieces) with key "meta" => metadataLong
819819 Cids.Cid[] memory pieceData2 = new Cids.Cid [](2 );
820- pieceData2[0 ].data = bytes ("2_0:22222222222222222222 " );
821- pieceData2[1 ].data = bytes ("2_1:222222222222222222220000000000000000000000000000000000000000 " );
820+ pieceData2[0 ] = Cids.CommPv2FromDigest (0 , 4 , keccak256 (abi.encodePacked ("2_0:22222222222222222222 " )));
821+ pieceData2[1 ] = Cids.CommPv2FromDigest (
822+ 0 , 4 , keccak256 (abi.encodePacked ("2_1:222222222222222222220000000000000000000000000000000000000000000 " ))
823+ );
822824 string [] memory keys2 = new string [](1 );
823825 string [] memory values2 = new string [](1 );
824826 keys2[0 ] = "meta " ;
@@ -1161,6 +1163,65 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
11611163 assertEq (dataSetId, 1 , "Dataset should be created with above-minimum funds " );
11621164 }
11631165
1166+ // function testInsufficientFunds_AddPieces() public {
1167+ // // Setup: Client with exactly the minimum funds (0.06 USDFC)
1168+ // address exactClient = makeAddr("exactClient");
1169+ // uint256 exactAmount = 6e16; // Exactly 0.06 USDFC
1170+
1171+ // // Transfer tokens from test contract to the test client
1172+ // mockUSDFC.safeTransfer(exactClient, exactAmount);
1173+
1174+ // vm.startPrank(exactClient);
1175+ // payments.setOperatorApproval(mockUSDFC, address(pdpServiceWithPayments), true, 1000e18, 1000e18, 365 days);
1176+ // mockUSDFC.approve(address(payments), exactAmount);
1177+ // payments.deposit(mockUSDFC, exactClient, exactAmount);
1178+ // vm.stopPrank();
1179+
1180+ // // Prepare dataset creation data
1181+ // (string[] memory dsKeys, string[] memory dsValues) = _getSingleMetadataKV("label", "Exact Minimum Test");
1182+ // FilecoinWarmStorageService.DataSetCreateData memory createData = FilecoinWarmStorageService.DataSetCreateData({
1183+ // payer: exactClient,
1184+ // clientDataSetId: 1000,
1185+ // metadataKeys: dsKeys,
1186+ // metadataValues: dsValues,
1187+ // signature: FAKE_SIGNATURE
1188+ // });
1189+
1190+ // bytes memory encodedCreateData = abi.encode(
1191+ // createData.payer,
1192+ // createData.clientDataSetId,
1193+ // createData.metadataKeys,
1194+ // createData.metadataValues,
1195+ // createData.signature
1196+ // );
1197+
1198+ // // Should succeed with exact minimum
1199+ // makeSignaturePass(exactClient);
1200+ // vm.prank(serviceProvider);
1201+ // uint256 dataSetId = mockPDPVerifier.createDataSet(pdpServiceWithPayments, encodedCreateData);
1202+
1203+ // vm.prank(exactClient);
1204+ // payments.withdraw(mockUSDFC, 59999999999961600); // Withdraw all funds, leaving 0 balance
1205+
1206+ // // Prepare piece addition data
1207+ // Cids.Cid[] memory pieceData = new Cids.Cid[](1);
1208+ // pieceData[0] = Cids.CommPv2FromDigest(0, 4, keccak256(abi.encodePacked("piece:belowMinimum")));
1209+ // string[] memory keys = new string[](0);
1210+ // string[] memory values = new string[](0);
1211+ // uint256 firstAdded = 0;
1212+ // // Expect revert when adding pieces due to insufficient funds
1213+ // makeSignaturePass(exactClient);
1214+ // vm.expectRevert(
1215+ // abi.encodeWithSelector(
1216+ // Errors.InsufficientLockupFunds.selector, exactClient, 6e16, 5e16
1217+ // )
1218+ // );
1219+ // vm.prank(serviceProvider);
1220+ // mockPDPVerifier.addPieces(
1221+ // pdpServiceWithPayments, dataSetId, firstAdded, pieceData, 0, FAKE_SIGNATURE, keys, values
1222+ // );
1223+ // }
1224+
11641225 // Operator Approval Validation Tests
11651226 function testOperatorApproval_NotApproved () public {
11661227 // Setup: Client with sufficient funds but no operator approval
@@ -4558,7 +4619,7 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
45584619
45594620 // Prepare piece data
45604621 Cids.Cid[] memory pieceData = new Cids.Cid [](1 );
4561- pieceData[0 ].data = bytes ( "test_piece_1 " );
4622+ pieceData[0 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( "test_piece_1 " )) );
45624623 string [] memory keys = new string [](0 );
45634624 string [] memory values = new string [](0 );
45644625
@@ -4604,7 +4665,7 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
46044665
46054666 // Prepare piece data
46064667 Cids.Cid[] memory pieceData = new Cids.Cid [](1 );
4607- pieceData[0 ].data = bytes ( " test_piece " );
4668+ pieceData[0 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( " test_piece_1 " )) );
46084669 string [] memory keys = new string [](0 );
46094670 string [] memory values = new string [](0 );
46104671
@@ -4678,7 +4739,7 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
46784739
46794740 // Prepare piece data
46804741 Cids.Cid[] memory pieceData = new Cids.Cid [](1 );
4681- pieceData[0 ].data = bytes ( " test " );
4742+ pieceData[0 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( " test_piece_1 " )) );
46824743 string [] memory keys = new string [](0 );
46834744 string [] memory values = new string [](0 );
46844745
@@ -4725,7 +4786,7 @@ contract FilecoinWarmStorageServiceTest is MockFVMTest {
47254786
47264787 // Prepare piece data
47274788 Cids.Cid[] memory pieceData = new Cids.Cid [](1 );
4728- pieceData[0 ].data = bytes ( " test " );
4789+ pieceData[0 ] = Cids. CommPv2FromDigest ( 0 , 4 , keccak256 ( abi.encodePacked ( " test_piece_1 " )) );
47294790 string [] memory keys = new string [](0 );
47304791 string [] memory values = new string [](0 );
47314792
0 commit comments