proofchain/packages/contracts/test/logistics/mocks/MockParametricInsurance.sol
caelum0x fb76a963d9 feat: Wave A — +56 contracts across 8 real-world domains (120 total, 1468 tests)
- tradefinance: LoC, bill of exchange, factoring, PO financing, dynamic discounting,
  securitization + tranche tokens, credit lines, guarantees
- compliance: sanctions/AML, certificate of origin, phytosanitary, halal, recalls,
  export licenses, duty/tariff, customs declaration
- dpp: EU Digital Product Passport (ERC721) + lifecycle/materials/repairability/recycling
- logistics: freight, cold-chain, bonded warehouse, fleet, containers, proof-of-delivery
- commodities: tokens, harvest/grading registries, storage receipts, price oracle, vault
- energy: renewable energy certs (ERC1155), emissions trading, water/biodiversity, green bonds
- workforce: soulbound worker credentials, safety training, milestone payroll, skills
- data: IoT sensors, quality inspection, lab tests, oracle aggregator, data marketplace
- 1468 forge tests green; 117 ABIs exported; DeployPlatform extended

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-31 21:12:08 +03:00

50 lines
1.8 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import { IPolicyManager } from "../../../src/interfaces/IPolicyManager.sol";
/// @notice Combined test double for the {PolicyManager} reads and {ClaimsProcessor.fileClaim} write
/// that {ColdChainMonitor} touches for its parametric-payout hook. Registered at BOTH the
/// POLICY_MANAGER and CLAIMS_PROCESSOR AddressBook keys.
contract MockParametricInsurance {
mapping(bytes32 => bytes32) public policyForBatch;
mapping(bytes32 => IPolicyManager.Policy) private _policies;
// Records of parametric claims filed via fileClaim.
bytes32 public lastPolicyId;
uint256 public lastAmount;
uint256 public fileCount;
bool public shouldRevert;
function setPolicy(bytes32 batchId, bytes32 policyId, uint256 coverage, IPolicyManager.PolicyState state) external {
policyForBatch[batchId] = policyId;
_policies[policyId] = IPolicyManager.Policy({
policyId: policyId,
batchId: batchId,
holder: address(0xBEEF),
token: address(0),
coverage: coverage,
premium: 0,
issuedAt: uint64(block.timestamp),
state: state
});
}
function setShouldRevert(bool v) external {
shouldRevert = v;
}
function policyOf(bytes32 policyId) external view returns (IPolicyManager.Policy memory) {
return _policies[policyId];
}
/// @notice Mirrors {IClaimsProcessor.fileClaim}; records the call.
function fileClaim(bytes32 policyId, uint256 amount) external returns (bytes32) {
require(!shouldRevert, "claims down");
lastPolicyId = policyId;
lastAmount = amount;
fileCount += 1;
return keccak256(abi.encode(policyId, amount, fileCount));
}
}