Skip to content

Commit

Permalink
Fix for appbase
Browse files Browse the repository at this point in the history
Fix transactionbuild broadcast aoutput for appbase
Fix market unit tests
  • Loading branch information
holgern committed Apr 6, 2018
1 parent 2011b8e commit 56cb5dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
9 changes: 5 additions & 4 deletions beem/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ def broadcast(self, max_block_age=-1):

if "operations" not in self or not self["operations"]:
return
ret = self.json()
if not self.steem.offline and self.steem.rpc.get_use_appbase():
ret = {'trx': self.json(), 'max_block_age': max_block_age}
args = {'trx': self.json(), 'max_block_age': max_block_age}
else:
ret = self.json()
args = self.json()

if self.steem.nobroadcast:
log.warning("Not broadcasting anything!")
Expand All @@ -295,11 +296,11 @@ def broadcast(self, max_block_age=-1):
try:
if self.steem.blocking:
ret = self.steem.rpc.broadcast_transaction_synchronous(
ret, api="network_broadcast")
args, api="network_broadcast")
ret.update(**ret["trx"])
else:
self.steem.rpc.broadcast_transaction(
ret, api="network_broadcast")
args, api="network_broadcast")
except Exception as e:
self.clear()
raise e
Expand Down
34 changes: 17 additions & 17 deletions tests/beem/test_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,21 @@ def test_buy(self, node_param):
)
op = tx["operations"][0][1]
self.assertIn("test", op["owner"])
self.assertEqual(u'0.100 STEEM', op["min_to_receive"])
self.assertEqual(u'0.500 SBD', op["amount_to_sell"])
self.assertEqual(Amount('0.100 STEEM', steem_instance=bts).json(), op["min_to_receive"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["amount_to_sell"])

p = Price(5, u"SBD:STEEM")
p = Price(5, u"SBD:STEEM", steem_instance=bts)
tx = m.buy(p, 0.1, account="test")
op = tx["operations"][0][1]
self.assertEqual(u'0.100 STEEM', op["min_to_receive"])
self.assertEqual(u'0.500 SBD', op["amount_to_sell"])
self.assertEqual(Amount('0.100 STEEM', steem_instance=bts).json(), op["min_to_receive"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["amount_to_sell"])

p = Price(5, u"SBD:STEEM")
a = Amount(0.1, "STEEM")
p = Price(5, u"SBD:STEEM", steem_instance=bts)
a = Amount(0.1, "STEEM", steem_instance=bts)
tx = m.buy(p, a, account="test")
op = tx["operations"][0][1]
self.assertEqual(u'0.100 STEEM', op["min_to_receive"])
self.assertEqual(u'0.500 SBD', op["amount_to_sell"])
self.assertEqual(a.json(), op["min_to_receive"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["amount_to_sell"])

@parameterized.expand([
("non_appbase"),
Expand All @@ -202,21 +202,21 @@ def test_sell(self, node_param):
)
op = tx["operations"][0][1]
self.assertIn("test", op["owner"])
self.assertEqual(u'0.500 SBD', op["min_to_receive"])
self.assertEqual(u'0.100 STEEM', op["amount_to_sell"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["min_to_receive"])
self.assertEqual(Amount('0.100 STEEM', steem_instance=bts).json(), op["amount_to_sell"])

p = Price(5, u"SBD:STEEM")
tx = m.sell(p, 0.1, account="test")
op = tx["operations"][0][1]
self.assertEqual(u'0.500 SBD', op["min_to_receive"])
self.assertEqual(u'0.100 STEEM', op["amount_to_sell"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["min_to_receive"])
self.assertEqual(Amount('0.100 STEEM', steem_instance=bts).json(), op["amount_to_sell"])

p = Price(5, u"SBD:STEEM")
a = Amount(0.1, "STEEM")
p = Price(5, u"SBD:STEEM", steem_instance=bts)
a = Amount(0.1, "STEEM", steem_instance=bts)
tx = m.sell(p, a, account="test")
op = tx["operations"][0][1]
self.assertEqual(u'0.500 SBD', op["min_to_receive"])
self.assertEqual(u'0.100 STEEM', op["amount_to_sell"])
self.assertEqual(Amount('0.500 SBD', steem_instance=bts).json(), op["min_to_receive"])
self.assertEqual(Amount('0.100 STEEM', steem_instance=bts).json(), op["amount_to_sell"])

@parameterized.expand([
("non_appbase"),
Expand Down

0 comments on commit 56cb5dc

Please sign in to comment.