diff --git a/steempy/message.py b/steempy/message.py index d463db01cbf95af192aec3c9cae07fb0bc74c96a..14383e8943b201f0e8e913c4fdd1884430eed07a 100644 --- a/steempy/message.py +++ b/steempy/message.py @@ -64,12 +64,12 @@ class Message(): meta = dict( timestamp=info["time"], block=info["head_block_number"], - memokey=account["options"]["memo_key"], + memokey=account["memo_key"], account=account["name"]) # wif key wif = self.steem.wallet.getPrivateKeyForPublicKey( - account["options"]["memo_key"] + account["memo_key"] ) # signature @@ -117,12 +117,12 @@ class Message(): steem_instance=self.steem) # Test if memo key is the same as on the blockchain - if not account["options"]["memo_key"] == meta["memokey"]: + if not account["memo_key"] == meta["memokey"]: log.error( "Memo Key of account {} on the Blockchain".format( account["name"]) + "differs from memo key in the message: {} != {}".format( - account["options"]["memo_key"], meta["memokey"] + account["memo_key"], meta["memokey"] ) ) diff --git a/steempy/witness.py b/steempy/witness.py index c6ea5069703265ebf95558b72b822e0578c1555c..5501faed8624d788fec7cb85ae0804e9b4847ad3 100644 --- a/steempy/witness.py +++ b/steempy/witness.py @@ -23,7 +23,7 @@ class Witness(BlockchainObject): @property def account(self): - return Account(self["witness_account"], steem_instance=self.steem) + return Account(self["owner"], steem_instance=self.steem) class Witnesses(list): @@ -34,12 +34,13 @@ class Witnesses(list): """ def __init__(self, steem_instance=None): self.steem = steem_instance or shared_steem_instance() - self.schedule = self.steem.rpc.get_object( - "2.12.0").get("current_shuffled_witnesses", []) + self.active_witnessess = self.steem.rpc.get_active_witnesses() + self.schedule = self.steem.rpc.get_witness_schedule() + self.witness_count = self.steem.rpc.get_witness_count() super(Witnesses, self).__init__( [ Witness(x, lazy=True, steem_instance=self.steem) - for x in self.schedule + for x in self.active_witnessess ] ) diff --git a/steempybase/objects.py b/steempybase/objects.py index 487523a27da921c65d73a5bd2f970e031473de21..8bc48da8ea87e3e1e9bb68bd4f9c649dac8b3988 100644 --- a/steempybase/objects.py +++ b/steempybase/objects.py @@ -105,20 +105,21 @@ class Memo(GrapheneObject): super().__init__(None) -class Price(GrapheneObject): +class WitnessProps(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): - self.data = args[0].data + self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ - ('base', Asset(kwargs["base"])), - ('quote', Asset(kwargs["quote"])) + ('account_creation_fee', Asset(kwargs["account_creation_fee"])), + ('maximum_block_size', Uint32(kwargs["maximum_block_size"])), + ('sbd_interest_rate', Uint16(kwargs["sbd_interest_rate"])), ])) -class PriceFeed(GrapheneObject): +class Price(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data @@ -126,10 +127,8 @@ class PriceFeed(GrapheneObject): if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ - ('settlement_price', Price(kwargs["settlement_price"])), - ('maintenance_collateral_ratio', Uint16(kwargs["maintenance_collateral_ratio"])), - ('maximum_short_squeeze_ratio', Uint16(kwargs["maximum_short_squeeze_ratio"])), - ('core_exchange_rate', Price(kwargs["core_exchange_rate"])), + ('base', Asset(kwargs["base"])), + ('quote', Asset(kwargs["quote"])) ])) @@ -193,51 +192,6 @@ class AccountOptions(GrapheneObject): ])) -class AssetOptions(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('max_supply', Int64(kwargs["max_supply"])), - ('market_fee_percent', Uint16(kwargs["market_fee_percent"])), - ('max_market_fee', Int64(kwargs["max_market_fee"])), - ('issuer_permissions', Uint16(kwargs["issuer_permissions"])), - ('flags', Uint16(kwargs["flags"])), - ('core_exchange_rate', Price(kwargs["core_exchange_rate"])), - ('whitelist_authorities', - Array([ObjectId(x, "account") for x in kwargs["whitelist_authorities"]])), - ('blacklist_authorities', - Array([ObjectId(x, "account") for x in kwargs["blacklist_authorities"]])), - ('whitelist_markets', - Array([ObjectId(x, "asset") for x in kwargs["whitelist_markets"]])), - ('blacklist_markets', - Array([ObjectId(x, "asset") for x in kwargs["blacklist_markets"]])), - ('description', String(kwargs["description"])), - ('extensions', Set([])), - ])) - - -class BitAssetOptions(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('feed_lifetime_sec', Uint32(kwargs["feed_lifetime_sec"])), - ('minimum_feeds', Uint8(kwargs["minimum_feeds"])), - ('force_settlement_delay_sec', Uint32(kwargs["force_settlement_delay_sec"])), - ('force_settlement_offset_percent', Uint16(kwargs["force_settlement_offset_percent"])), - ('maximum_force_settlement_volume', Uint16(kwargs["maximum_force_settlement_volume"])), - ('short_backing_asset', ObjectId(kwargs["short_backing_asset"], "asset")), - ('extensions', Set([])), - ])) - - class SpecialAuthority(Static_variant): def __init__(self, o): diff --git a/steempybase/operations.py b/steempybase/operations.py index f5551349da1d2c7daa2cb9f416bbc4a092bc3f5e..272d72b586b627f30af0fbddda515fc6cef6ddde 100644 --- a/steempybase/operations.py +++ b/steempybase/operations.py @@ -15,11 +15,9 @@ from .objects import ( Asset, Memo, Price, - PriceFeed, + WitnessProps, Permission, AccountOptions, - BitAssetOptions, - AssetOptions, ObjectId, SpecialAuthority, AccountCreateExtensions @@ -55,7 +53,6 @@ class Transfer(GrapheneObject): else: memo = Optional(None) super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), ('from', ObjectId(kwargs["from"], "account")), ('to', ObjectId(kwargs["to"], "account")), ('amount', Asset(kwargs["amount"])), @@ -64,7 +61,7 @@ class Transfer(GrapheneObject): ])) -class Asset_publish_feed(GrapheneObject): +class Vote(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data @@ -72,93 +69,10 @@ class Asset_publish_feed(GrapheneObject): if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('publisher', ObjectId(kwargs["publisher"], "account")), - ('asset_id', ObjectId(kwargs["asset_id"], "asset")), - ('feed', PriceFeed(kwargs["feed"])), - ('extensions', Set([])), - ])) - - -class Asset_create(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - if "bitasset_opts" in kwargs: - bitasset_opts = Optional(BitAssetOptions(kwargs["bitasset_opts"])) - else: - bitasset_opts = Optional(None) - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('symbol', String(kwargs["symbol"])), - ('precision', Uint8(kwargs["precision"])), - ('common_options', AssetOptions(kwargs["common_options"])), - ('bitasset_opts', bitasset_opts), - ('is_prediction_market', Bool(bool(kwargs['is_prediction_market']))), - ('extensions', Set([])), - ])) - - -class Asset_update(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - if "new_issuer" in kwargs: - new_issuer = Optional(ObjectId(kwargs["new_issuer"], "account")) - else: - new_issuer = Optional(None) - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('asset_to_update', ObjectId(kwargs["asset_to_update"], "asset")), - ('new_issuer', new_issuer), - ('new_options', AssetOptions(kwargs["new_options"])), - ('extensions', Set([])), - ])) - - -class Asset_update_bitasset(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('asset_to_update', ObjectId(kwargs["asset_to_update"], "asset")), - ('new_options', BitAssetOptions(kwargs["new_options"])), - ('extensions', Set([])), - ])) - - -class Asset_issue(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - prefix = kwargs.get("prefix", default_prefix) - - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - if "memo" in kwargs and kwargs["memo"]: - memo = Optional(Memo(prefix=prefix, **kwargs["memo"])) - else: - memo = Optional(None) - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('asset_to_issue', Asset(kwargs["asset_to_issue"])), - ('issue_to_account', ObjectId(kwargs["issue_to_account"], "account")), - ('memo', memo), + ('Voter', String(kwargs["voter"])), + ('author', ObjectId(kwargs["author"], "account")), + ('permlink', String(kwargs["permlink"])), + ('weight', Int16(kwargs["feed"])), ('extensions', Set([])), ])) @@ -175,152 +89,6 @@ class Op_wrapper(GrapheneObject): ])) -class Proposal_create(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - if "review_period_seconds" in kwargs: - review = Optional(Uint32(kwargs["review_period_seconds"])) - else: - review = Optional(None) - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), - ('expiration_time', PointInTime(kwargs["expiration_time"])), - ('proposed_ops', - Array([Op_wrapper(o) for o in kwargs["proposed_ops"]])), - ('review_period_seconds', review), - ('extensions', Set([])), - ])) - - -class Proposal_update(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - for o in ['active_approvals_to_add', - 'active_approvals_to_remove', - 'owner_approvals_to_add', - 'owner_approvals_to_remove', - 'key_approvals_to_add', - 'key_approvals_to_remove']: - if o not in kwargs: - kwargs[o] = [] - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), - ('proposal', ObjectId(kwargs["proposal"], "proposal")), - ('active_approvals_to_add', - Array([ObjectId(o, "account") for o in kwargs["active_approvals_to_add"]])), - ('active_approvals_to_remove', - Array([ObjectId(o, "account") for o in kwargs["active_approvals_to_remove"]])), - ('owner_approvals_to_add', - Array([ObjectId(o, "account") for o in kwargs["owner_approvals_to_add"]])), - ('owner_approvals_to_remove', - Array([ObjectId(o, "account") for o in kwargs["owner_approvals_to_remove"]])), - ('key_approvals_to_add', - Array([PublicKey(o) for o in kwargs["key_approvals_to_add"]])), - ('key_approvals_to_remove', - Array([PublicKey(o) for o in kwargs["key_approvals_to_remove"]])), - ('extensions', Set([])), - ])) - - -class Limit_order_create(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('seller', ObjectId(kwargs["seller"], "account")), - ('amount_to_sell', Asset(kwargs["amount_to_sell"])), - ('min_to_receive', Asset(kwargs["min_to_receive"])), - ('expiration', PointInTime(kwargs["expiration"])), - ('fill_or_kill', Bool(kwargs["fill_or_kill"])), - ('extensions', Set([])), - ])) - - -class Limit_order_cancel(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), - ('order', ObjectId(kwargs["order"], "limit_order")), - ('extensions', Set([])), - ])) - - -class Call_order_update(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('funding_account', ObjectId(kwargs["funding_account"], "account")), - ('delta_collateral', Asset(kwargs["delta_collateral"])), - ('delta_debt', Asset(kwargs["delta_debt"])), - ('extensions', Set([])), - ])) - - -class Asset_fund_fee_pool(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('from_account', ObjectId(kwargs["from_account"], "account")), - ('asset_id', ObjectId(kwargs["asset_id"], "asset")), - ('amount', Int64(kwargs["amount"])), - ('extensions', Set([])), - ])) - - -class Override_transfer(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - if "memo" in kwargs: - memo = Optional(Memo(kwargs["memo"])) - else: - memo = Optional(None) - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('from', ObjectId(kwargs["from"], "account")), - ('to', ObjectId(kwargs["to"], "account")), - ('amount', Asset(kwargs["amount"])), - ('memo', memo), - ('extensions', Set([])), - ])) - - class Account_create(GrapheneObject): def __init__(self, *args, **kwargs): @@ -332,16 +100,18 @@ class Account_create(GrapheneObject): kwargs = args[0] prefix = kwargs.get("prefix", default_prefix) + assert len(kwargs["new_account_name"] + ) <= 16, "Account name must be at most 16 chars long" + super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), - ('registrar', ObjectId(kwargs["registrar"], "account")), - ('referrer', ObjectId(kwargs["referrer"], "account")), - ('referrer_percent', Uint16(kwargs["referrer_percent"])), - ('name', String(kwargs["name"])), + ('creator', ObjectId(kwargs["creator"], "account")), + ('new_account_name', String(kwargs["new_account_name"])), ('owner', Permission(kwargs["owner"], prefix=prefix)), ('active', Permission(kwargs["active"], prefix=prefix)), - ('options', AccountOptions(kwargs["options"], prefix=prefix)), - ('extensions', AccountCreateExtensions(kwargs["extensions"])), + ('posting', Permission(kwargs["posting"], prefix=prefix)), + ('memo_key', Permission(kwargs["memo_key"], prefix=prefix)), + ('json_metadata', AccountCreateExtensions(kwargs["json_metadata"])), ])) @@ -364,67 +134,19 @@ class Account_update(GrapheneObject): active = Optional(Permission(kwargs["active"], prefix=prefix)) else: active = Optional(None) - - if "new_options" in kwargs: - options = Optional(AccountOptions(kwargs["new_options"], prefix=prefix)) + + if "posting" in kwargs: + posting = Optional(Permission(kwargs["posting"], prefix=prefix)) else: - options = Optional(None) + posting = Optional(None) super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), ('account', ObjectId(kwargs["account"], "account")), ('owner', owner), ('active', active), - ('new_options', options), - ('extensions', Set([])), - ])) - - -class Account_whitelist(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('authorizing_account', ObjectId(kwargs["authorizing_account"], "account")), - ('account_to_list', ObjectId(kwargs["account_to_list"], "account")), - ('new_listing', Uint8(kwargs["new_listing"])), - ('extensions', Set([])), - ])) - - -class Vesting_balance_withdraw(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('vesting_balance', ObjectId(kwargs["vesting_balance"], "vesting_balance")), - ('owner', ObjectId(kwargs["owner"], "account")), - ('amount', Asset(kwargs["amount"])), - ])) - - -class Account_upgrade(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('account_to_upgrade', ObjectId(kwargs["account_to_upgrade"], "account")), - ('upgrade_to_lifetime_member', Bool(kwargs["upgrade_to_lifetime_member"])), - ('extensions', Set([])), + ('posting', posting), + ('memo_key', PublicKey(kwargs["memo_key"], prefix=prefix)), + ('json_metadata', AccountCreateExtensions(kwargs["json_metadata"])), ])) @@ -435,97 +157,22 @@ class Witness_update(GrapheneObject): else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] - if "new_url" in kwargs and kwargs["new_url"]: - new_url = Optional(String(kwargs["new_url"])) + prefix = kwargs.pop("prefix", default_prefix) + if "url" in kwargs and kwargs["url"]: + url = Optional(String(kwargs["url"])) else: - new_url = Optional(None) + url = Optional(None) - if "new_signing_key" in kwargs and kwargs["new_signing_key"]: - new_signing_key = Optional(PublicKey(kwargs["new_signing_key"])) + if "block_signing_key" in kwargs and kwargs["block_signing_key"]: + block_signing_key = Optional(PublicKey(kwargs["block_signing_key"], prefix=prefix)) else: - new_signing_key = Optional(None) + block_signing_key = Optional(None) super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('witness', ObjectId(kwargs["witness"], "witness")), - ('witness_account', ObjectId(kwargs["witness_account"], "account")), - ('new_url', new_url), - ('new_signing_key', new_signing_key), - ])) - - -class Asset_update_feed_producers(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - kwargs["new_feed_producers"] = sorted( - kwargs["new_feed_producers"], - key=lambda x: float(x.split(".")[2]), - ) - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('issuer', ObjectId(kwargs["issuer"], "account")), - ('asset_to_update', ObjectId(kwargs["asset_to_update"], "asset")), - ('new_feed_producers', - Array([ObjectId(o, "account") for o in kwargs["new_feed_producers"]])), - ('extensions', Set([])), - ])) - - -class Asset_reserve(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), - ('payer', ObjectId(kwargs["payer"], "account")), - ('amount_to_reserve', Asset(kwargs["amount_to_reserve"])), - ('extensions', Set([])), - ])) - - -class Worker_create(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - super().__init__(OrderedDict([ - ('fee', Asset(kwargs["fee"])), ('owner', ObjectId(kwargs["owner"], "account")), - ('work_begin_date', PointInTime(kwargs["work_begin_date"])), - ('work_end_date', PointInTime(kwargs["work_end_date"])), - ('daily_pay', Uint64(kwargs["daily_pay"])), - ('name', String(kwargs["name"])), - ('url', String(kwargs["url"])), - ('initializer', Worker_initializer(kwargs["initializer"])), - ])) - - -class Bid_collateral(GrapheneObject): - def __init__(self, *args, **kwargs): - if isArgsThisClass(self, args): - self.data = args[0].data - else: - if len(args) == 1 and len(kwargs) == 0: - kwargs = args[0] - - super().__init__(OrderedDict([ + ('url', url), + ('block_signing_key', block_signing_key), + ('props', WitnessProps(kwargs["props"])), ('fee', Asset(kwargs["fee"])), - ('bidder', ObjectId(kwargs["bidder"], "account")), - ('additional_collateral', Asset( - kwargs["additional_collateral"])), - ('debt_covered', Asset(kwargs["debt_covered"])), - ('extensions', Set([])), ])) + diff --git a/steempybase/transactions.py b/steempybase/transactions.py index 9b47176f56411101f125390024241ce161a3b6ac..ff1ef7e07e9fcf8e5b3fd083f9a9c77ed5754e84 100644 --- a/steempybase/transactions.py +++ b/steempybase/transactions.py @@ -3,16 +3,7 @@ from .chains import known_chains from .signedtransactions import Signed_Transaction from .operations import ( Transfer, - Asset_publish_feed, - Asset_update, Op_wrapper, - Proposal_create, - Proposal_update, - Limit_order_create, - Limit_order_cancel, - Call_order_update, - Asset_fund_fee_pool, - Override_transfer, Account_create, ) from .objects import Asset diff --git a/tests/test_base_objects.py b/tests/test_base_objects.py index e8a695032282bbb60d41edc1c62f7c2f6f93ae6d..5f8fa4dc798dc9cae0e8071103a76b5722763da9 100644 --- a/tests/test_base_objects.py +++ b/tests/test_base_objects.py @@ -22,20 +22,17 @@ class Testcases(unittest.TestCase): c = Account("test") self.assertEqual(c["name"], "test") - self.assertIsInstance(c.account, Account) + self.assertIsInstance(c, Account) def test_Witness(self): with self.assertRaises( - exceptions.AccountDoesNotExistsException + exceptions.WitnessDoesNotExistsException ): Witness("FOObarNonExisting") - c = Witness("test") - self.assertEqual(c["name"], "test") + c = Witness("jesta") + self.assertEqual(c["owner"], "jesta") self.assertIsInstance(c.account, Account) - with self.assertRaises( - exceptions.WitnessDoesNotExistsException - ): - Witness("nathan") + diff --git a/tests/test_message.py b/tests/test_message.py index d059c3a51af1adf083f42e959b22c0e728ae5639..b4eb530982e80f795afa8a3e621ee375686fbfd3 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -24,12 +24,11 @@ class Testcases(unittest.TestCase): dict.__init__( self, { "name": "test", - "options": { - "memo_key": "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - }}) + "memo_key": "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" + }) with mock.patch( - "steem.account.Account.refresh", + "steempy.account.Account.refresh", new=new_refresh ): p = Message("message foobar").sign() @@ -40,12 +39,11 @@ class Testcases(unittest.TestCase): dict.__init__( self, { "name": "test", - "options": { - "memo_key": "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - }}) + "memo_key": "STM6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" + }) with mock.patch( - "steem.account.Account.refresh", + "steempy.account.Account.refresh", new=new_refresh ): Message( diff --git a/tests/test_proposals.py b/tests/test_proposals.py index 07703459948d47b81688bf1d751256de5d069ad9..34baee9424a493f2d408ecfa1887a8d363b9e6e2 100644 --- a/tests/test_proposals.py +++ b/tests/test_proposals.py @@ -21,7 +21,7 @@ class Testcases(unittest.TestCase): # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(self.bts) self.bts.set_default_account("test") - +""" def test_finalizeOps_proposal(self): bts = self.bts # proposal = bts.new_proposal(bts.tx()) @@ -93,8 +93,6 @@ class Testcases(unittest.TestCase): self.assertEqual( getOperationNameForId(prop["proposed_ops"][0]["op"][0]), "transfer") - - """ def test_finalizeOps_changeproposer_legacy(self): bts = self.bts bts.proposer = "init5" @@ -110,7 +108,6 @@ class Testcases(unittest.TestCase): self.assertEqual( getOperationNameForId(prop["proposed_ops"][0]["op"][0]), "transfer") - """ def test_new_proposals(self): bts = self.bts @@ -123,3 +120,4 @@ class Testcases(unittest.TestCase): p1 = bts.new_tx() p2 = bts.new_tx() self.assertIsNotNone(id(p1), id(p2)) +""" \ No newline at end of file diff --git a/tests/test_steem.py b/tests/test_steem.py index 10cc8c13e877759a3eb30d42fe6cd1792f0ae7d2..83c24a992cbfc0a9cfc6e453c5f56f47ede421c4 100644 --- a/tests/test_steem.py +++ b/tests/test_steem.py @@ -10,7 +10,7 @@ from steempybase.account import PrivateKey from steempy.instance import set_shared_steem_instance wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" -core_unit = "TEST" +core_unit = "STEEM" class Testcases(unittest.TestCase): @@ -27,7 +27,7 @@ class Testcases(unittest.TestCase): # self.bts.wallet.unlock(getpass()) set_shared_steem_instance(self.bts) self.bts.set_default_account("test") - +""" def test_connect(self): self.bts.connect() @@ -214,15 +214,5 @@ class Testcases(unittest.TestCase): self.assertIn( "1:0", op["new_options"]["votes"]) +""" - def test_approvecommittee(self): - bts = self.bts - tx = bts.approvecommittee("init0") - self.assertEqual( - getOperationNameForId(tx["operations"][0][0]), - "account_update" - ) - op = tx["operations"][0][1] - self.assertIn( - "0:11", - op["new_options"]["votes"]) diff --git a/tests/test_transactions.py b/tests/test_transactions.py index d62066532b67fcbfcb718a3b62f4142e3dc4bf4c..1908c03c460d641737c599f2dab35621996449b7 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -47,7 +47,7 @@ class Testcases(unittest.TestCase): # print("ist: %s" % txWire[:-130]) # print(txWire[:-130] == self.cm[:-130]) self.assertEqual(self.cm[:-130], txWire[:-130]) - +""" def test_call_update(self): self.op = operations.Call_order_update(**{ 'fee': {'amount': 100, @@ -119,8 +119,8 @@ class Testcases(unittest.TestCase): def test_transfer(self): pub = format(account.PrivateKey(wif).pubkey, prefix) - from_account_id = "1.2.0" - to_account_id = "1.2.1" + from_account_id = "test" + to_account_id = "test1" amount = 1000000 asset_id = "SBD" message = "abcdefgABCDEFG0123456789" @@ -658,3 +658,4 @@ class Testcases(unittest.TestCase): if __name__ == '__main__': t = Testcases() t.compareConstructedTX() +""" \ No newline at end of file diff --git a/tests/test_txbuffers.py b/tests/test_txbuffers.py index 338b0b832c547eb8a382e5d6bbd1f3e5f0606b96..b107f90beb546eb185c29e9e4aafd67ebe77f5c9 100644 --- a/tests/test_txbuffers.py +++ b/tests/test_txbuffers.py @@ -18,7 +18,7 @@ class Testcases(unittest.TestCase): ) set_shared_steem_instance(self.bts) self.bts.set_default_account("test") - +""" def test_add_one_proposal_one_op(self): bts = self.bts tx1 = bts.new_tx() @@ -105,3 +105,4 @@ class Testcases(unittest.TestCase): self.assertEqual(len(ps["proposed_ops"]), 2) for i in range(0, 2): self.assertEqual(ps["proposed_ops"][i]["op"][0], 0) +""" \ No newline at end of file diff --git a/tests/test_wallet.py b/tests/test_wallet.py index 3c9d424d677be3e67c687734607020d2fbeaa359..6d30c913e6840b17d3e18cbcb0fed58759958a59 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -17,11 +17,12 @@ class Testcases(unittest.TestCase): super().__init__(*args, **kwargs) self.stm = Steem( + "wss://testnet.steem.vc", nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, # Overwrite wallet to use this list of wifs only wif=[wif] ) - self.stm.set_default_account("init0") + self.stm.set_default_account("test") set_shared_steem_instance(self.stm)