steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 100 forks source link

Testing with `no_broadcast=True` does not work with a `Post` #155

Open SmokinCaterpillar opened 6 years ago

SmokinCaterpillar commented 6 years ago

Hi, the no_broadcast=True option does not work with a Post. I figured this out by making an unwanted comment on steemit by accident :-D

This becomes immediately clear if we look into the constructors of Steem as well as Post.

In the Steem constructor the no_broadcast option is directly passed to the Commit:

def __init__(self, nodes=None, no_broadcast=False, **kwargs):
    self.steemd = Steemd(
        nodes=nodes,
        **kwargs
    )
    self.commit = Commit(
        steemd_instance=self.steemd,
        no_broadcast=no_broadcast,
        **kwargs
    )

However, the Post constructor does not know about no_broadcast and creates a regular Commit:

def __init__(self, post, steemd_instance=None):
    self.steemd = steemd_instance or shared_steemd_instance()
    self.commit = Commit(steemd_instance=self.steemd)
    ...

Why does the Post need to create a new Commit object? Could it simply use the commit of the Steem object? Alternatively, the Post constructor could also simply take no_broadcast as an argument. Let me know which solution you prefer and I'll make a pull request.

SmokinCaterpillar commented 5 years ago

I stumbled over this again, have you made up your mind what solution you prefer? I'll do a PR in this case :-)