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

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

Open
pointtoken opened this issue Sep 21, 2017 · 5 comments
Open

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

pointtoken opened this issue Sep 21, 2017 · 5 comments

Comments

@pointtoken
Copy link

pointtoken commented Sep 21, 2017

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.

@MicahZoltu
Copy link

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).

@SilentCicero
Copy link
Member

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

@SupremeTechnopriest
Copy link

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

@MicahZoltu
Copy link

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.

@SilentCicero
Copy link
Member

SilentCicero commented Dec 13, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants