comment.upvote doesn't work on some cases at Beem

in #utopian-io6 years ago (edited)

Project Information

Expected behavior

Comment class in beem.comment has a helper method to initiate upvotes called as .upvote.

This should work as expected on all cases.

Actual behavior

Beem fails to create an upvote transaction if the comment will be upvoted doesn't have any vote before. This is happening because of this check on the library.

How to reproduce

Here is a little python script to reproduce the issue:

from beem.comment import Comment
from beem.steem import Steem

ACCOUNT = "<upvoter_account_username>"


def reproduce(s):
    main_comment = Comment("@beemtutorials/test-case-for-beem-upvote", steem_instance=s)
    reply = main_comment.reply("test-comment", author=ACCOUNT)
    reply_comment = Comment(reply["operations"][0][1])
    reply_comment.upvote(+50, voter=ACCOUNT)


def main():
    s = Steem(
        node=["https://rpc.buildteam.io"],
        keys=["<posting_wif>"]
    )
    reproduce(s)


if __name__ == '__main__':
    main()


Stacktrace:

/Users/emre/Environments/beemtutorials/bin/python /Users/emre/Projects/beem_tutorials/repro_bug.py
Traceback (most recent call last):
  File "/Users/emre/Projects/beem_tutorials/repro_bug.py", line 23, in <module>
    main()
  File "/Users/emre/Projects/beem_tutorials/repro_bug.py", line 19, in main
    reproduce(s)
  File "/Users/emre/Projects/beem_tutorials/repro_bug.py", line 11, in reproduce
    reply_comment.upvote(+50, voter=ACCOUNT)
  File "/Users/emre/Environments/beemtutorials/lib/python3.6/site-packages/beem/comment.py", line 555, in upvote
    raise VotingInvalidOnArchivedPost
beem.exceptions.VotingInvalidOnArchivedPost
  • Browser/App version: N/A, beem-0.19.47
  • Operating system: N/A

My GitHub Account

https://github.com/emre

Sort:  

Hello @emrebeyler, Great Work!!
Your post has earned the badge of Staff-picks from Bug-hunting.

Congratulations.
This is to show appreciation that we love your work and Encourage you to keep Contributing.

  • I liked especially how you provided the script to specially test for this bug, that helped thanks.

He fixed it via changing the Checks and instead of checking the net_shares he went with checking the timestamps. IDK if that's a Good approach or not. but If your bug helped the project to move in a better direction and PO is happy. I'm happy

Thank you so much for contributing to the Project via Utopian.

Your contribution has been evaluated according to Utopian policies and 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.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

ah, you got me excited there for a while. :)
I tried to reproduce it but failed to do so on a random comment with 0 in upvote. Then I tested your snippet above and got the same result as you...

reply = main_comment.reply("test-comment", author=ACCOUNT)
reply will not hold a post identifier, but instead a post summary looking like this:
{'expiration': '2018-07-10T21:22:20', 'ref_block_num': 12194, 'ref_block_prefix': 472120501, 'operations': [['comment', {'parent_author': 'danielsaori', 'parent_permlink': 're-alimamasstory-re-danielsaori-steemit-comment-challenge-33-usd5-sbd-2-x-200-sp-1-weeks-delegation-comment-like-a-champ-grow-your-blog-like-a-champ-20180628t195834418z', 'author': 'dorabot', 'permlink': 're-re-alimamasstory-re-danielsaori-steemit-comment-challenge-33-usd5-sbd-2-x-200-sp-1-weeks-delegation-comment-like-a-champ-grow-your-blog-like-a-champ-20180628t195834418z-20180710t212150z', 'title': '', 'body': 'test-comment', 'json_metadata': '{"app": "beem/0.19.47"}'}]], 'extensions': [], 'signatures': ['207b644f450c33697703ffae1a880831aec9f99344e73771a03b0537971885cef755de32b98f48942896747110ef31e773e09fe7475ca5fbcf09bdcfbf03d77b92']}

And using this in Comment(reply) will return None of class Comment.
Preferably this should raise an exception instead

Then using this None Comment, stored in reply_comment with the .upvote method, will raise VotingInvalidOnArchivedPost.
Preferably it should raise a different exception

My reply with two potential bugs... 😀

Somehow I forgot updating the reproduce script here, updated now.

    reply_comment = Comment(reply["operations"][0][1])

works fine. Comment class can also work with op data.

holger already fixed the issue. :)

Btw, it's a deterministic bug, any chance you're using .vote instead of upvote?

ah, I checked github now. I see Holger fixed it, and I see it was only reproducable on a newly created Comments.

The problem I've seen is completely random. Could be 1 in a 1000 upvotes that just silently fails. Actually the .upvote method returns a valid vote, so no error, but it is not added to the blockchain. Few users talked about it on Discord.
It doesn't necessarily need to be linked to Beem, but I had users complaining just after switching to beem. Need some more time to try to debug that one... :)

Hey @emrebeyler
Thanks for contributing on Utopian.
Congratulations! Your contribution was Staff Picked to receive a maximum vote for the bug-hunting category on Utopian for being of significant value to the project and the open source community.

We’re already looking forward to your next contribution!

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

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.25
TRX 0.11
JST 0.032
BTC 63706.21
ETH 3073.80
USDT 1.00
SBD 3.76