How to use beem - 10 common examples

To help you get started, we’ve selected a few beem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holgern / beem / tests / beem / test_amount.py View on Github external
# blockchain dict init
        amount = Amount({
            "amount": 1 * 10 ** precision,
            "asset_id": asset["id"]
        }, steem_instance=stm)
        self.dotest(amount, 1, symbol)

        # API dict init
        amount = Amount({
            "amount": 1.3 * 10 ** precision,
            "asset": asset["id"]
        }, steem_instance=stm)
        self.dotest(amount, 1.3, symbol)

        # Asset as symbol
        amount = Amount(1.3, Asset("SBD"), steem_instance=stm)
        self.dotest(amount, 1.3, symbol)

        # Asset as symbol
        amount = Amount(1.3, symbol, steem_instance=stm)
        self.dotest(amount, 1.3, symbol)

        # keyword inits
        amount = Amount(amount=1.3, asset=Asset("SBD", steem_instance=stm), steem_instance=stm)
        self.dotest(amount, 1.3, symbol)
        
        amount = Amount(amount=1.3001, asset=Asset("SBD", steem_instance=stm), steem_instance=stm)
        self.dotest(amount, 1.3001, symbol)        

        amount = Amount(amount=1.3001, asset=Asset("SBD", steem_instance=stm), fixed_point_arithmetic=True, steem_instance=stm)
        self.dotest(amount, 1.3, symbol)
github holgern / beem / tests / beem / test_amount.py View on Github external
def test_init(self):
        stm = self.bts
        # String init
        asset = Asset("SBD", steem_instance=stm)
        symbol = asset["symbol"]
        precision = asset["precision"]
        amount = Amount("1 {}".format(symbol), steem_instance=stm)
        self.dotest(amount, 1, symbol)

        # Amount init
        amount = Amount(amount, steem_instance=stm)
        self.dotest(amount, 1, symbol)

        # blockchain dict init
        amount = Amount({
            "amount": 1 * 10 ** precision,
            "asset_id": asset["id"]
        }, steem_instance=stm)
        self.dotest(amount, 1, symbol)

        # API dict init
        amount = Amount({
            "amount": 1.3 * 10 ** precision,
            "asset": asset["id"]
        }, steem_instance=stm)
        self.dotest(amount, 1.3, symbol)
github holgern / beem / tests / beem / test_testnet.py View on Github external
def test_Transfer_broadcast(self):
        nodelist = NodeList()
        stm = Steem(node=self.nodes,
                    keys=[self.active_key],
                    nobroadcast=True,
                    expiration=120,
                    num_retries=10)

        tx = TransactionBuilder(use_condenser_api=True, expiration=10, steem_instance=stm)
        tx.appendOps(Transfer(**{"from": "beem",
                                 "to": "beem1",
                                 "amount": Amount("1 STEEM", steem_instance=stm),
                                 "memo": ""}))
        tx.appendSigner("beem", "active")
        tx.sign()
        tx.broadcast()
github holgern / beem / tests / beem / test_price.py View on Github external
def test_order(self):
        order = Order(Amount("2 SBD"), Amount("1 STEEM"))
        self.assertTrue(repr(order) is not None)
github holgern / beem / tests / beem / test_instance.py View on Github external
def test_amount(self, node_param):
        if node_param == "instance":
            stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1)
            set_shared_steem_instance(self.bts)
            o = Amount("1 SBD")
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Amount("1 SBD", steem_instance=stm)
        else:
            set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
            stm = self.bts
            o = Amount("1 SBD", steem_instance=stm)
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Amount("1 SBD")
github holgern / beem / tests / beem / test_account.py View on Github external
def test_blog_history(self):
        account = Account("holger80", steem_instance=self.bts)
        posts = []
        for p in account.blog_history(limit=5):
            if p["author"] != account["name"]:
                continue
            posts.append(p)
        self.assertTrue(len(posts) >= 1)
        self.assertEqual(posts[0]["author"], account["name"])
        self.assertTrue(posts[0].is_main_post())
        self.assertTrue(posts[0].depth == 0)
github holgern / beem / tests / beem / test_testnet.py View on Github external
def test_appendSigner(self):
        nodelist = NodeList()
        stm = Steem(node=self.nodes,
                    keys=[self.active_key],
                    nobroadcast=True,
                    expiration=120,
                    num_retries=10)
        tx = TransactionBuilder(use_condenser_api=True, steem_instance=stm)
        tx.appendOps(Transfer(**{"from": "beem",
                                 "to": "beem1",
                                 "amount": Amount("1 STEEM", steem_instance=stm),
                                 "memo": ""}))
        account = Account("beem", steem_instance=stm)
        with self.assertRaises(
            AssertionError
        ):
            tx.appendSigner(account, "abcdefg")
        tx.appendSigner(account, "active")
        self.assertTrue(len(tx.wifs) > 0)
github holgern / beem / tests / beem / test_instance.py View on Github external
def test_price(self, node_param):
        if node_param == "instance":
            set_shared_steem_instance(self.bts)
            o = Price(10.0, "STEEM/SBD")
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Price(10.0, "STEEM/SBD", steem_instance=Steem(node="https://abc.d", autoconnect=False, num_retries=1))
        else:
            set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
            stm = self.bts
            o = Price(10.0, "STEEM/SBD", steem_instance=stm)
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Price(10.0, "STEEM/SBD")
github holgern / beem / tests / beem / test_instance.py View on Github external
def test_amount(self, node_param):
        if node_param == "instance":
            stm = Steem(node="https://abc.d", autoconnect=False, num_retries=1)
            set_shared_steem_instance(self.bts)
            o = Amount("1 SBD")
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Amount("1 SBD", steem_instance=stm)
        else:
            set_shared_steem_instance(Steem(node="https://abc.d", autoconnect=False, num_retries=1))
            stm = self.bts
            o = Amount("1 SBD", steem_instance=stm)
            self.assertIn(o.steem.rpc.url, self.urls)
            with self.assertRaises(
                RPCConnection
            ):
                Amount("1 SBD")
github holgern / beem / tests / beem / test_comment.py View on Github external
def setUpClass(cls):
        nodelist = NodeList()
        nodelist.update_nodes(steem_instance=Steem(node=nodelist.get_nodes(exclude_limited=False), num_retries=10))
        node_list = nodelist.get_nodes(exclude_limited=True)

        cls.bts = Steem(
            node=node_list,
            use_condenser=True,
            nobroadcast=True,
            unsigned=True,
            keys={"active": wif},
            num_retries=10
        )
        cls.steemit = Steem(
            node="https://api.steemit.com",
            nobroadcast=True,
            unsigned=True,
            keys={"active": wif},
            num_retries=10