Skip to content

Problem: The commit mode behaves incorrectly.#2510

Merged
ttmc merged 5 commits intobigchaindb:masterfrom
ldmberman:parse-tendermint-commit-response
Sep 6, 2018
Merged

Problem: The commit mode behaves incorrectly.#2510
ttmc merged 5 commits intobigchaindb:masterfrom
ldmberman:parse-tendermint-commit-response

Conversation

@ldmberman
Copy link
Copy Markdown
Contributor

Solution: Parse the Tendermint response properly. The functionality was disabled in https://github.com/bigchaindb/bigchaindb/pull/2235/files#diff-c6511560546a7dc577e7e647b5bfdaceL68 and was not fixed since then.

@ldmberman ldmberman requested review from kansi and vrde September 4, 2018 12:42
deliver_tx_code = result['deliver_tx'].get('code', 0)
error_code = check_tx_code or deliver_tx_code
else:
error_code = result.get('code', 0)
Copy link
Copy Markdown
Contributor

@kansi kansi Sep 4, 2018

Choose a reason for hiding this comment

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

Can we please have a test case for this response object

Copy link
Copy Markdown
Contributor

@kansi kansi left a comment

Choose a reason for hiding this comment

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

Looks good. Please check the CI


result = response['result']
if mode == self.mode_commit:
check_tx_code = result.get('check_tx', {}).get('code', 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you omit the second parameter, get returns None if the lookup is unsuccessful, so you can just write check_tx_code = result.get('check_tx', {}).get('code') if you want.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

0 is the success code the API uses so I put it there but None would work here as well. I do not have a preference.

Copy link
Copy Markdown
Contributor

@vrde vrde left a comment

Choose a reason for hiding this comment

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

I don't have a clear understanding of what kind of response Tendermint, but if the acceptance test passes, I'm happy :)

I've added a small comment on your code that you can address if you want.

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2510 into master will increase coverage by 0.28%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2510      +/-   ##
==========================================
+ Coverage   91.73%   92.02%   +0.28%     
==========================================
  Files          41       42       +1     
  Lines        2467     2519      +52     
==========================================
+ Hits         2263     2318      +55     
+ Misses        204      201       -3

@ttmc ttmc merged commit 6994946 into bigchaindb:master Sep 6, 2018
vrde pushed a commit to vrde/bigchaindb that referenced this pull request Sep 6, 2018
* Problem: The commit mode behaves incorrectly.

Solution: Parse the Tendermint response properly. The functionality was disabled in https://github.com/bigchaindb/bigchaindb/pull/2235/files#diff-c6511560546a7dc577e7e647b5bfdaceL68 and was not fixed since then.

* Add a test case for the sync mode.

* Do not strictly expect deliver_tx in the response.

* Fix post_mock in web/test_transactions.py.

* Check for the error field first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants