-
Notifications
You must be signed in to change notification settings - Fork 686
Open
Description
- ComputeTotal function does not satisfy its specification
Lines 24 to 39 in 1b712d6
function ComputeTotal() public { if (Manufacturer != msg.sender) { revert(); } // calculate total for only the first 12 values, in case more than 12 are entered for (uint i = 0; i < 12; i++) { Total += DefectiveComponentsCount[i]; } State = StateType.ComputeTotal; }
As documented by its following specification, computeTotal funtion can only be called once. However, in the contract implementation, there is no such restriction.
Lines 73 to 99 in 1b712d6
| "States": [{ | |
| "Name": "Create", | |
| "DisplayName": "Create", | |
| "Description": "...", | |
| "PercentComplete": 50, | |
| "Value": 0, | |
| "Style": "Success", | |
| "Transitions": [{ | |
| "AllowedRoles": [], | |
| "AllowedInstanceRoles": ["Manufacturer"], | |
| "Description": "...", | |
| "Function": "ComputeTotal", | |
| "NextStates": ["ComputeTotal"], | |
| "DisplayName": "Compute Total" | |
| }] | |
| }, | |
| { | |
| "Name": "ComputeTotal", | |
| "DisplayName": "Compute Total", | |
| "Description": "...", | |
| "PercentComplete": 100, | |
| "Value": 1, | |
| "Style": "Success", | |
| "Transitions": [] | |
| } | |
| ] | |
| }] |
- Bug repair
We can fix such bug using the following statement.
// call this function to send a request
function ComputeTotal() public
{
// Fix
if (State != StateType.Create)
{
revert();
}
...Metadata
Metadata
Assignees
Labels
No labels