Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceptance test support for getLogs #140

Closed
Nana-EC opened this issue Jun 2, 2022 · 2 comments · Fixed by #292
Closed

Add acceptance test support for getLogs #140

Nana-EC opened this issue Jun 2, 2022 · 2 comments · Fixed by #292
Assignees
Labels
enhancement New feature or request limechain P2 process Build, test and deployment-process related tasks
Milestone

Comments

@Nana-EC
Copy link
Collaborator

Nana-EC commented Jun 2, 2022

Problem

#103 added support for getLogs.
However , this preceded the acceptance tests so support was not added

Solution

Add a tests that calls eth_getLogs with coverage for a combination of the following params

  • fromBlock
  • toBlock
  • address
  • topics
  • blockhash

Alternatives

No response

@Nana-EC Nana-EC added enhancement New feature or request P2 process Build, test and deployment-process related tasks labels Jun 2, 2022
@Nana-EC Nana-EC added this to the 0.2.0 milestone Jun 2, 2022
@Daniel-K-Ivanov
Copy link
Collaborator

  • If nothing is passed in the filter (filter is empty) f.e:
{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "eth_getLogs",
  "params": [
    {}
  ]
}

The response must be all logs from the most recent block

  • If only fromBlock is specified, we must query all logs from the beginning (specified block) until now for all contracts.
  • If only toBlock is specified, we must query all blocks until the toBlock
  • Add tests with 1, 2, 3, and 4 topics filter -> topics must be considered OR filter not AND
  • If we are passing only address -> we must return all logs for that address (address can be account or contract). If no events are found the response should be:
{
  "jsonrpc": "2.0",
  "id": 0,
  "result": []
}

@Daniel-K-Ivanov Daniel-K-Ivanov removed their assignment Jun 20, 2022
@Nana-EC Nana-EC modified the milestones: 0.2.0, 0.3.0 Jun 21, 2022
@Nana-EC Nana-EC added P3 P2 and removed P2 P3 labels Jun 24, 2022
@Kalina-Todorova
Copy link

Kalina-Todorova commented Jun 28, 2022

We can use this contract to test all options:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

contract Logs {

    event Log0(uint256 num1) anonymous; // Does not include topic
    event Log1(uint256 indexed num0);
    event Log2(uint256 indexed num0, uint256 indexed num1);
    event Log3(uint256 indexed num0, uint256 indexed num1, uint256 indexed num2);
    event Log4(uint256 indexed num0, uint256 indexed num1, uint256 indexed num2, uint256 num3);

    function log0(uint n) public {
        emit Log0(n);
    }

    function log1(uint n) public {
        emit Log1(n);
    }

    function log2(uint n0, uint n1) public {
        emit Log2(n0, n1);
    }

    function log3(uint n0, uint n1, uint n2) public {
        emit Log3(n0, n1, n2);
    }

    function log4(uint n0, uint n1, uint n2, uint n3) public {
        emit Log4(n0, n1, n2, n3);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request limechain P2 process Build, test and deployment-process related tasks
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants