Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

testing(json rpc): Add backend test suite with mock grpc query client #1199

Merged
merged 12 commits into from
Jul 23, 2022

Conversation

danburck
Copy link
Contributor

@danburck danburck commented Jul 22, 2022

Description

This PR adds a backend testing suite in order to unit test the JSON-RPC backend. It uses a mock for the grpc client to create the following setup:

JSON-PRC-CLIENT -> BACKEND -> Mock GRPC CLIENT -> APP

where

  • a JSON-PRC-CLIENT doesn't need to be instantiated because we directly call the backend methods
  • APP doesn't need to be instantiated because the Mock GRPC CLIENT response with fake data

Notes

  • I included a first unit test. After this setup is merged we need to add more coverage
  • An alternative to a mocked grpc, would be to run a grpc server, that would mimic the actual grpc response.

@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #1199 (3b6e368) into main (cd41c48) will decrease coverage by 7.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1199      +/-   ##
==========================================
- Coverage   62.32%   55.29%   -7.03%     
==========================================
  Files          91       94       +3     
  Lines        7413     8391     +978     
==========================================
+ Hits         4620     4640      +20     
- Misses       2563     3517     +954     
- Partials      230      234       +4     
Impacted Files Coverage Δ
rpc/backend/evm_backend.go 0.99% <0.00%> (ø)
rpc/backend/backend.go 86.66% <0.00%> (ø)
rpc/backend/utils.go 0.00% <0.00%> (ø)

@danburck danburck changed the title ENG 119 json rpc backend test suite testing(json rpc): Add backend test suite with mock grpc query client Jul 22, 2022
@danburck danburck marked this pull request as ready for review July 22, 2022 15:51
rpc/backend/evm_backend_test.go Outdated Show resolved Hide resolved
rpc/backend/backend_suite_test.go Show resolved Hide resolved
@fedekunze fedekunze enabled auto-merge (squash) July 23, 2022 07:25
@fedekunze fedekunze merged commit c626a5c into main Jul 23, 2022
@fedekunze fedekunze deleted the ENG-119-json-rpc-backend-test-suite branch July 23, 2022 09:16
hoanguyenkh pushed a commit to AstraProtocol/ethermint that referenced this pull request Jul 27, 2022
…evmos#1199)

* tests(json-rpc): wip evm_backend unit test setup

* tests(json-rpc): wip evm_backend unit test setup

* fix viper

* wip query client mock

* fix first backend test except error message

* clean up

* wip Context with Height

* fix JSON RPC backend test setup

* typo

* refactor folder structure

* Update rpc/backend/evm_backend_test.go

Co-authored-by: Federico Kunze Küllmer <[email protected]>
facs95 pushed a commit that referenced this pull request Aug 12, 2022
…#1199)

* tests(json-rpc): wip evm_backend unit test setup

* tests(json-rpc): wip evm_backend unit test setup

* fix viper

* wip query client mock

* fix first backend test except error message

* clean up

* wip Context with Height

* fix JSON RPC backend test setup

* typo

* refactor folder structure

* Update rpc/backend/evm_backend_test.go

Co-authored-by: Federico Kunze Küllmer <[email protected]>
hoanguyenkh pushed a commit to AstraProtocol/ethermint that referenced this pull request Aug 17, 2022
…evmos#1199)

* tests(json-rpc): wip evm_backend unit test setup

* tests(json-rpc): wip evm_backend unit test setup

* fix viper

* wip query client mock

* fix first backend test except error message

* clean up

* wip Context with Height

* fix JSON RPC backend test setup

* typo

* refactor folder structure

* Update rpc/backend/evm_backend_test.go

Co-authored-by: Federico Kunze Küllmer <[email protected]>
devon-chain pushed a commit to PundiAI/ethermint that referenced this pull request Nov 17, 2022
…evmos#1199)

* tests(json-rpc): wip evm_backend unit test setup

* tests(json-rpc): wip evm_backend unit test setup

* fix viper

* wip query client mock

* fix first backend test except error message

* clean up

* wip Context with Height

* fix JSON RPC backend test setup

* typo

* refactor folder structure

* Update rpc/backend/evm_backend_test.go

Co-authored-by: Federico Kunze Küllmer <[email protected]>
(cherry picked from commit 8be0403)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants