0

Let's say I have a contract which, for the sake of this post, inherits OpenZeppelin's Ownable. I made a minor update (in terms of code / complexity: an override & revert to disable a method). Then I added tests, and the results were like this:

Contract: SampleMetaverse
  ✓ does not allow renouncing the ownership (using: account 0)
  ✓ does not allow transferring ownership to others than the owner (using: account 1)
  ✓ allows transferring ownership to self (using: account 0) (407ms)
  ✓ allows transferring ownership to others (using: account 0) (89ms)
  ✓ does not allow renouncing the ownership (using: account 1)
  ✓ allows transferring ownership to self (using: account 1) (115ms)
  ✓ allows transferring ownership to others (using: account 1) (92ms)

I see the numbers in milliseconds to be in red (this is a truffle test). To what extent should I care about this?

The contract (the part I am testing) goes like this, actually:

abstract contract SafeOwnable is Ownable {
    constructor() Ownable() {}

    /**
     * @dev Trying to renounce the ownership is forbidden in these contracts.
     */
    function renounceOwnership() public override onlyOwner {
        revert("SafeOwnable: ownership cannot be renounced");
    }
}

1 Answer 1

1

Not a concern.

The redness is an artifact of the test framework that happens to think the times are a little on the high side. This is irrelevant.

Transactions that arrive in blocks can be considered as executed in the past. All nodes are therefore in catch-up mode. Any reasonably fast computer can process everything in a block before the next block arrives. The maximum complexity of a block is limited by the block gas limit.

You should be concerned with the maximum gas consumption of a transaction, and time complexity (aim for O(1)), but temporal time is of no concern at all.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.