Test

This document is better viewed at https://docs.etherisc.com/contracts/api/test

Contracts

TestCoinAlternativeImplementation

import "@etherisc/gif-contracts/contracts/test/TestCoinAlternativeImplementation.sol";

constructor() public

Constructor function that creates a new ERC20 token with the given name and symbol, and mints the initial supply to the sender.

transferFrom(address _from, address _to, uint256 _value) → bool public

Transfer tokens from one address to another.

TestCompromisedProduct

import "@etherisc/gif-contracts/contracts/test/TestCompromisedProduct.sol";

onlyPolicyHolder(bytes32 policyId) modifier

constructor(bytes32 fakeProductName, address tokenAddress, uint256 fakeComponentId, uint256 fakeRiskpoolId, address registryAddress) public

Constructor function to initialize the component with the given parameters.

applyForPolicy(uint256 premium, uint256 sumInsured, bytes metaData, bytes applicationData) → bytes32 processId external

Allows a policy holder to apply for a new policy by submitting an application with the specified premium, sum insured, metaData, and applicationData.

collectPremium(bytes32 policyId) external

Collects the premium for a given policy.

submitClaim(bytes32 policyId, uint256 claimAmount) external

Allows a policy holder to submit a claim for the specified policy.

getToken() → address token external

Returns the address of the token used by this contract.

getPolicyFlow() → address policyFlow external

Returns the address of the policy flow contract.

getRiskpoolId() → uint256 riskpoolId external

Returns the ID of the risk pool.

getApplicationDataStructure() → string dataStructure external

Returns the data structure of the application.

getClaimDataStructure() → string dataStructure external

Returns the data structure of the claim data.

getPayoutDataStructure() → string dataStructure external

Returns the data structure of the payout information.

riskPoolCapacityCallback(uint256 capacity) external

Callback function to update the risk pool’s capacity.

setId(uint256 id) external

Sets the ID of the contract.

getName() → bytes32 external

Returns the name of the component.

getId() → uint256 external

Returns the ID of the component.

getType() → enum IComponent.ComponentType external

Returns the ComponentType of the product.

getState() → enum IComponent.ComponentState external

Returns the current state of the component.

getOwner() → address external

Returns the address of the contract owner.

getRegistry() → contract IRegistry external

Returns the current registry contract instance.

isProduct() → bool public

Checks if the contract is a product.

isOracle() → bool public

Returns a boolean value indicating whether the contract is an oracle.

isRiskpool() → bool public

Check if the contract is a risk pool.

proposalCallback() external

This function is a callback function for proposals.

Returns: None

approvalCallback() external

This function is a callback function that is called after an approval has been made.

declineCallback() external

This function is called when a user declines a transaction in the dApp.

suspendCallback() external

Suspends the callback function.

resumeCallback() external

This function is a callback function that is triggered when a paused contract is resumed.

pauseCallback() external

Callback function that is called when the contract is paused. This function does not take any parameters.

unpauseCallback() external

This function is called by the owner of the contract to unpause the contract after it has been paused.

archiveCallback() external

This function is a callback function that is executed when a contract is archived.

TestOracle

import "@etherisc/gif-contracts/contracts/test/TestOracle.sol";

constructor(bytes32 oracleName, address registry) public

Constructor function for creating an Oracle contract.

request(uint256 requestId, bytes input) external

Requests data from the oracle contract.

cancel(uint256 requestId) external

Cancels a Chainlink request.

respond(uint256 requestId, bool isLossEvent) public

Responds to an oracle request with a boolean value indicating whether a loss event occurred.

_oracleCalculation(uint256 counter) → bool isLossEvent internal

Performs an oracle calculation to determine if a loss event occurred.

TestProduct

import "@etherisc/gif-contracts/contracts/test/TestProduct.sol";
Functions

constructor(bytes32 productName, address tokenAddress, address capitalOwner, uint256 oracleId, uint256 riskpoolId, address registryAddress) public

Constructor function for creating a new instance of the Product contract.

applyForPolicy(uint256 premium, uint256 sumInsured, bytes metaData, bytes applicationData) → bytes32 processId external

Allows a policy holder to apply for a new insurance policy by submitting an application with the specified premium, sum insured, metadata and application data.

applyForPolicy(address payable policyHolder, uint256 premium, uint256 sumInsured, bytes metaData, bytes applicationData) → bytes32 processId external

Creates a new insurance application and underwrites it if possible.

newAppliation(uint256 premium, uint256 sumInsured, bytes metaData, bytes applicationData) → bytes32 processId external

Creates a new insurance application.

revoke(bytes32 processId) external

Revokes a process identified by its processId. Only the policy holder can revoke a process.

decline(bytes32 processId) external

Declines a specific process by its ID.

underwrite(bytes32 processId) external

Underwrites a policy for a given process ID.

collectPremium(bytes32 policyId) → bool success, uint256 fee, uint256 netPremium external

Collects the premium for a specific policy.

collectPremium(bytes32 policyId, uint256 amount) → bool success, uint256 fee, uint256 netPremium external

Collects the premium for a specific policy.

adjustPremiumSumInsured(bytes32 processId, uint256 expectedPremiumAmount, uint256 sumInsuredAmount) external

Adjusts the premium and sum insured amounts for a given process ID.

expire(bytes32 policyId) external

Expire a policy by its ID.

close(bytes32 policyId) external

Closes a policy with the given ID.

submitClaim(bytes32 policyId, uint256 claimAmount) → uint256 claimId external

Allows a policy holder to submit a claim for a specific policy.

submitClaimNoOracle(bytes32 policyId, uint256 claimAmount) → uint256 claimId external

Allows a policy holder to submit a claim without the need for an oracle.

submitClaimWithDeferredResponse(bytes32 policyId, uint256 claimAmount) → uint256 claimId, uint256 requestId external

Submits a claim for a specific policy with a deferred response from the oracle. Increases the claims counter and creates a new claim application. Then, requests a response from the oracle via an external call with encoded query data.

confirmClaim(bytes32 policyId, uint256 claimId, uint256 confirmedAmount) external

Confirms the amount to be paid out for a specific claim.

declineClaim(bytes32 policyId, uint256 claimId) external

Allows the owner of the contract to decline a claim.

closeClaim(bytes32 policyId, uint256 claimId) external

Closes a specific claim for a given policy.

createPayout(bytes32 policyId, uint256 claimId, uint256 payoutAmount) → uint256 payoutId external

Creates a new payout for a specific policy and claim.

newPayout(bytes32 policyId, uint256 claimId, uint256 payoutAmount) → uint256 payoutId external

Creates a new payout for a claim under a policy.

processPayout(bytes32 policyId, uint256 payoutId) external

Processes a payout for a specific policy.

oracleCallback(uint256 requestId, bytes32 policyId, bytes responseData) external

This function is called by the oracle to provide the response data for a specified policy ID and request ID.

getClaimId(bytes32 policyId) → uint256 external

Returns the claim ID associated with a given policy ID.

getPayoutId(bytes32 policyId) → uint256 external

Returns the payout ID associated with a given policy ID.

applications() → uint256 external

Returns the number of applications that have been submitted.

policies() → uint256 external

Returns the number of policies in the _policies array.

claims() → uint256 external

Returns the number of claims made by users.

LogTestProductFundingReceived(address sender, uint256 amount) event

LogTestOracleCallbackReceived(uint256 requestId, bytes32 policyId, bytes response) event

TestRegistryCompromisedController

import "@etherisc/gif-contracts/contracts/test/TestRegistryCompromisedController.sol";

getContract(bytes32 contractName) → address moduleAddress external

Returns the address of a registered contract.

upgradeToV2(address compromisedPolicyModuleAddress, address originalQueryModuleAddress) public

Upgrades the Policy Manager contract to version 2.

TestRiskpool

import "@etherisc/gif-contracts/contracts/test/TestRiskpool.sol";
Functions

constructor(bytes32 name, uint256 collateralization, address erc20Token, address wallet, address registry) public

Constructor function for the Riskpool contract.

bundleMatchesApplication(struct IBundle.Bundle bundle, struct IPolicy.Application application) → bool isMatching public

This function checks if a given bundle matches a given application.

TestTransferFrom

import "@etherisc/gif-contracts/contracts/test/TestTransferFrom.sol";

unifiedTransferFrom(contract IERC20 token, address from, address to, uint256 amount) → bool external

Transfers tokens from a specified address to another specified address using the TransferHelper library.

LogTransferHelperInputValidation1Failed(bool tokenIsContract, address from, address to) event

LogTransferHelperInputValidation2Failed(uint256 balance, uint256 allowance) event

LogTransferHelperCallFailed(bool callSuccess, uint256 returnDataLength, bytes returnData) event