create account

Beem: unable to get only the first op via account.history() and account.get_account_history() by stmdev

View this thread on: hive.blogpeakd.comecency.com
· @stmdev ·
$36.84
Beem: unable to get only the first op via account.history() and account.get_account_history()
#### Project Information

* Repository: https://github.com/holgern/beem
* Project Name: Beem
* Publisher: @holger80

#### Expected behavior

`account.history()` and `account.get_account_history()` should return only the first blockchain operation of an account when called with `start=0, stop=0, use_block_num=False`.

#### Actual behavior

`account.history()` returns the full history and `account.get_account_history()` returns `limit+1` operations when called with `start=0, stop=0, use_block_num=False`.


#### How to reproduce

```python
from beem.account import Account
import sys
opnum = int(sys.argv[1])
a = Account("stmdev")
ops = list(a.history(opnum, opnum, use_block_num=False))
print("a.history() returned %d ops" % (len(ops)))

ops = list(a.history_reverse(opnum, opnum, use_block_num=False))
print("a.history_reverse() returned %d ops" % (len(ops)))

ops = list(a.get_account_history(index=opnum+1, limit=opnum+1,
                                 start=opnum, stop=opnum,
                                 use_block_num=False))
print("a.get_account_history() returned %d ops" % (len(ops)))
```

Output:
```
# python getop.py 0
a.history() returned 1756 ops
a.history_reverse() returned 1 ops
a.get_account_history() returned 2 ops
```

The same for operation number 1 works:
```
# python getop.py 1
a.history() returned 1 ops
a.history_reverse() returned 1 ops
a.get_account_history() returned 1 ops
```

#### Environment

```
# beempy --version
beempy, version 0.19.34
# python --version
Python 3.6.5
```


### Possible fix

`history()`, `history_reverse()`, and `get_account_history()` check for `if start` / `if stop` at several stages, however this check is `False` for both `None` and `0`. Changing those checks to `if start is not None` / `if stop is not None` could solve this:

```
# python getop.py.py 0
a.history() returned 1 ops
a.history_reverse() returned 1 ops
a.get_account_history() returned 1 ops

# python getop.py.py 1
a.history() returned 1 ops
a.history_reverse() returned 1 ops
a.get_account_history() returned 1 ops
```

A PR has been created for these changes: https://github.com/holgern/beem/pull/19
However, please review these carefully, I'm not sure I covered all cases. The PR includes changes also to `account_history_reverse()`, which does not fail with the test above.


#### GitHub Account
https://github.com/crokkon
A Github issue has been created: https://github.com/holgern/beem/issues/18
👍  , , , , , , , , , , , , ,
properties (23)
authorstmdev
permlinkbeem-unable-to-get-only-the-first-op-via-account-history-and-account-getaccounthistory
categoryutopian-io
json_metadata{"tags":["utopian-io","bug-hunting","beem","python","steemdev"],"users":["holger80"],"links":["https://github.com/holgern/beem","https://github.com/holgern/beem/pull/19","https://github.com/crokkon","https://github.com/holgern/beem/issues/18"],"app":"steemit/0.1","format":"markdown"}
created2018-06-01 13:53:00
last_update2018-06-01 13:53:00
depth0
children2
last_payout2018-06-08 13:53:00
cashout_time1969-12-31 23:59:59
total_payout_value27.829 HBD
curator_payout_value9.008 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,438
author_reputation10,427,398,400,460
root_title"Beem: unable to get only the first op via account.history() and account.get_account_history()"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id58,761,124
net_rshares9,818,181,021,651
author_curate_reward""
vote details (14)
@holger80 ·
Thank you again for your contribution! I can confirm the found bug and accepted the [PR](https://github.com/holgern/beem/pull/19). Thanks for creating a github issue and a PR. 


Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/5/2131113).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
properties (22)
authorholger80
permlinkre-stmdev-beem-unable-to-get-only-the-first-op-via-account-history-and-account-getaccounthistory-20180602t085653810z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://github.com/holgern/beem/pull/19","https://join.utopian.io/guidelines","https://review.utopian.io/result/5/2131113","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-06-02 08:57:03
last_update2018-06-02 08:57:03
depth1
children0
last_payout2018-06-09 08:57:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length668
author_reputation358,857,509,568,825
root_title"Beem: unable to get only the first op via account.history() and account.get_account_history()"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id58,880,743
net_rshares0
@utopian-io ·
Hey @stmdev
**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Contributing on Utopian**
Learn how to contribute on <a href='https://join.utopian.io'>our website</a> or by watching <a href='https://www.youtube.com/watch?v=8S1AtrzYY1Q'>this tutorial</a> on Youtube.

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-beem-unable-to-get-only-the-first-op-via-account-history-and-account-getaccounthistory-20180602t142008z
categoryutopian-io
json_metadata"{"app": "beem/0.19.29"}"
created2018-06-02 14:20:09
last_update2018-06-02 14:20:09
depth1
children0
last_payout2018-06-09 14:20:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length503
author_reputation152,955,367,999,756
root_title"Beem: unable to get only the first op via account.history() and account.get_account_history()"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id58,913,570
net_rshares0