Skip to content

Bug report in defective-component-counter smart contract #278

@academic-starter

Description

@academic-starter

As documented by its following specification, computeTotal funtion can only be called once. However, in the contract implementation, there is no such restriction.

"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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions