Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Unable to write tests for events when using Solidity Events #7

Description

@pointtoken

The convention when writing Solidity Smart Contracts is to capitalize events (http://solidity.readthedocs.io/en/develop/structure-of-a-contract.html#events) aka

contract SimpleAuction {
    event HighestBidIncreased(address bidder, uint amount); // Event

    function bid() payable {
        // ...
        HighestBidIncreased(msg.sender, msg.value); // Triggering event
    }
}

Such a contract will generate a javascript function that will appear as

SimpleAuction.HighestBidIncreased

But if you try to use the ABI when writing tests for ethjs, you will anger ESLint with the error:

A function with a name starting with an uppercase letter should only be used as a constructor  ne
w-cap

The workaround is to write solidity contracts with events starting with a lower case character, which isn't ideal if there are linting constraints introduced in Solidity which force uppercase event names.

Activity

  1. MicahZoltu commented on Oct 7, 2017

    @MicahZoltu

    That feels like a bug in the linter. The linter shouldn't be complaining when a method with capital first letter is called, it should be complaining when such a method is declared. Otherwise the linter will complain about the output of third party libraries (like in this case).

  2. SilentCicero commented on Nov 3, 2017

    @SilentCicero
    Member

    This seems to be linting related yes. I can shut off that setting within the linter for EthJS proper.

  3. SupremeTechnopriest commented on Dec 12, 2017

    @SupremeTechnopriest

    you can disable the line for your event with // eslint-disable-line

  4. MicahZoltu commented on Dec 13, 2017

    @MicahZoltu

    It is the solidity linter, not EcmaScript linter. Though, Solidity did also just add disabling linting via comments as well, but I don't know the comment off-hand.

  5. SilentCicero commented on Dec 13, 2017

    @SilentCicero
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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