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

R4R: Increase BaseApp Test Coverage #3468

Merged
merged 18 commits into from
Feb 6, 2019
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Feb 1, 2019

Adds a test case for #3259 and a few other small test cases to increase coverage. In addition, minor cleanup to godocs and general structure (no functional changes). This PR is pending further additional test cases we deem necessary.

closes: #556
closes: #3259


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Feb 1, 2019

Codecov Report

Merging #3468 into develop will increase coverage by 0.46%.
The diff coverage is 77.14%.

@@             Coverage Diff             @@
##           develop    #3468      +/-   ##
===========================================
+ Coverage    59.51%   59.97%   +0.46%     
===========================================
  Files          135      135              
  Lines         9981     9960      -21     
===========================================
+ Hits          5940     5974      +34     
+ Misses        3669     3619      -50     
+ Partials       372      367       -5

@jackzampolin
Copy link
Member

🔥🚀🌔

// Implements ABCI.
// Delegates to CommitMultiStore if it implements Queryable
// Query implements the ABCI interface. It delegates to CommitMultiStore if it
// implements Queryable.
func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be really nice to have the ABCI query functionality documented in detail for each module and query. cc @mossid

@alexanderbez
Copy link
Contributor Author

Added a test case for #3259 and a few other small ones. Anything else you think I should cover @cwgoes ?

@alexanderbez alexanderbez changed the title WIP: Increase BaseApp Test Coverage R4R: Increase BaseApp Test Coverage Feb 5, 2019
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These testcases look fine; thanks for cleaning up all the comments - can we also add some for:

  • LoadVersion usage
  • Bad query paths on the query router
  • Quick message router tests (add router_test.go)

And can we cleanup:

  • baseapp/helpers.go - RunForever is not used, probably the other functions aren't either
  • Delete baseapp/query.go - unused, very out of date
  • Remove the entire testdata folder - unused, very out of date

// Router returns the router of the BaseApp.
func (app *BaseApp) Router() Router {
if app.sealed {
// TODO: Why are panicing here on returning the router???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becase AddRoute can be called, I think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this right? can we update the comment?

baseapp/baseapp.go Outdated Show resolved Hide resolved
baseapp/baseapp_test.go Outdated Show resolved Hide resolved
@@ -117,7 +120,8 @@ func (app *BaseApp) SetCommitMultiStoreTracer(w io.Writer) {
app.cms.WithTracer(w)
}

// Mount IAVL or DB stores to the provided keys in the BaseApp multistore
// MountStores mounts all IAVL or DB stores to the provided keys in the BaseApp
// multistore.
func (app *BaseApp) MountStores(keys ...*sdk.KVStoreKey) {
Copy link
Member

@jackzampolin jackzampolin Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this MountStores function take both transient keys and store keys? It could look like:

func (app *BaseApp) MountStores(keys ...interface{}) {
  for _, key := range keys {
    switch key.(type) {
    case *sdk.KVStoreKey:
      if !app.fauxMerkleMode {
        app.MountStore(key, sdk.StoreTypeIAVL)
      } else {
        app.MountStore(key, sdk.StoreTypeDB)
      }
    case *sdk.TransientStoreKey:
      app.MountStore(key, sdk.StoreTypeTransient
    }
    default:
       panic("Invalid key type")
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea - but perhaps best for a separate PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I think this falls under general app.go cleanup

@alexanderbez
Copy link
Contributor Author

@cwgoes I've address your comments. In addition, I also cleaned up the existing router a bit (now using a map instead of a slice).

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few further notes on comments; otherwise LGTM.

// Router returns the router of the BaseApp.
func (app *BaseApp) Router() Router {
if app.sealed {
// TODO: Why are panicing here on returning the router???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this right? can we update the comment?

baseapp/baseapp_test.go Outdated Show resolved Hide resolved
baseapp/baseapp_test.go Outdated Show resolved Hide resolved
baseapp/baseapp_test.go Outdated Show resolved Hide resolved
baseapp/baseapp_test.go Outdated Show resolved Hide resolved
@alexanderbez
Copy link
Contributor Author

@cwgoes addressed

@cwgoes cwgoes merged commit 52350c5 into develop Feb 6, 2019
@cwgoes cwgoes deleted the bez/556-baseapp-test-coverage branch February 6, 2019 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test that baseapp correctly handles gas on aborted txs baseapp test coverage not enough
4 participants