当前位置: 首页>>代码示例>>Python>>正文


Python BtcTxStore.get_address方法代码示例

本文整理汇总了Python中btctxstore.BtcTxStore.get_address方法的典型用法代码示例。如果您正苦于以下问题:Python BtcTxStore.get_address方法的具体用法?Python BtcTxStore.get_address怎么用?Python BtcTxStore.get_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在btctxstore.BtcTxStore的用法示例。


在下文中一共展示了BtcTxStore.get_address方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestGetAddress

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestGetAddress(unittest.TestCase):

    def setUp(self):
        self.api = BtcTxStore(dryrun=True, testnet=True)

    def test_standard(self):
        wif = self.api.create_key()
        address = self.api.get_address(wif)
        self.assertTrue(validate.is_address_valid(address, allowable_netcodes=['XTN']))

    def test_input_validation(self):

        # test correct types
        a = self.api.get_address(S_WIF)
        b = self.api.get_address(B_WIF)
        c = self.api.get_address(U_WIF)
        self.assertEqual(a, b, c)

        # TODO invalid types
        # TODO invalid input data

    def test_standards_compliant(self):
        wif = self.api.create_key()
        address = self.api.get_address(S_WIF)
        self.assertEqual(address, EXPECTED)
开发者ID:F483,项目名称:btctxstore,代码行数:27,代码来源:get_address.py

示例2: test_authenticate_headers_provide

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def test_authenticate_headers_provide(self):
        """
        Test of preparing and providing credential headers when ``sender_key``
        and ``btctx_api`` are provided.
        """
        btctx_api = BtcTxStore(testnet=True, dryrun=True)
        sender_key = btctx_api.create_key()
        signature = btctx_api.sign_unicode(sender_key, self.file_hash)
        sender_address = btctx_api.get_address(sender_key)
        self.mock_get.return_value = Response()
        self.test_data_for_requests['headers'] = {
                'sender-address': sender_address,
                'signature': signature,
            }
        download_call_result = core.download(
            self.test_url_address,
            self.file_hash,
            sender_key=sender_key,
            btctx_api=btctx_api
        )
        expected_mock_calls = [call(
            urljoin(self.test_url_address, '/api/files/' + self.file_hash),
            **self.test_data_for_requests
        )]

        self.assertListEqual(
            self.mock_get.call_args_list,
            expected_mock_calls,
            'In the download() function requests.get() calls are unexpected'
        )
        self.assertIsInstance(download_call_result, Response,
                              'Must return a response object')
开发者ID:StorjOld,项目名称:metatool,代码行数:34,代码来源:test_metatool_core_unit.py

示例3: _setup_data_transfer_client

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def _setup_data_transfer_client(self, store_config, passive_port,
                                    passive_bind, node_type, nat_type, wan_ip):
        # Setup handlers for callbacks registered via the API.
        handlers = {
            "complete": self._transfer_complete_handlers,
            "accept": self._transfer_request_handlers
        }

        wallet = BtcTxStore(testnet=False, dryrun=True)
        wif = self.get_key()
        node_id = address_to_node_id(wallet.get_address(wif))
        #dht_node = SimDHT(node_id=node_id)
        dht_node = self

        self._data_transfer = FileTransfer(
            net=Net(
                net_type="direct",
                node_type=node_type,
                nat_type=nat_type,
                dht_node=dht_node,
                debug=1,
                passive_port=passive_port,
                passive_bind=passive_bind,
                wan_ip=wan_ip
            ),
            wif=wif,
            store_config=store_config,
            handlers=handlers
        )

        # Setup success callback values.
        self._data_transfer.success_value = (self.sync_get_wan_ip(), self.port)
        self.process_data_transfers()
开发者ID:robertsdotpm,项目名称:storjnode,代码行数:35,代码来源:api.py

示例4: test_fail

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def test_fail(self):
        # register without auth headres fails
        rv = self.app.get('/api/register/{0}'.format(addresses["eta"]))
        self.assertEqual(rv.status_code, 401)

        # register first because ping is lazy
        blockchain = BtcTxStore()
        wif = blockchain.create_key()
        address = blockchain.get_address(wif)
        header_date = formatdate(timeval=mktime(datetime.now().timetuple()),
                                 localtime=True, usegmt=True)
        message = app.config["ADDRESS"] + " " + header_date
        header_authorization = blockchain.sign_unicode(wif, message)
        headers = {"Date": header_date, "Authorization": header_authorization}
        url = '/api/register/{0}'.format(address)
        rv = self.app.get(url, headers=headers)
        self.assertEqual(rv.status_code, 200)

        # ping without auth headres fails
        time.sleep(app.config["MAX_PING"])
        rv = self.app.get('/api/ping/{0}'.format(address))
        self.assertEqual(rv.status_code, 401)

        # set height without auth headres fails
        rv = self.app.get('/api/height/{0}/10'.format(addresses["eta"]))
        self.assertEqual(rv.status_code, 401)
开发者ID:StorjOld,项目名称:dataserv,代码行数:28,代码来源:test_App.py

示例5: test_core_audit

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def test_core_audit(self):
        """
        Test of providing correct arguments to the ``requests.post()``
        and returning gotten response object.
        """
        test_url_address = 'http://test.url.com'
        file_hash = sha256(b'some test data').hexdigest()
        seed = sha256(b'some test challenge seed').hexdigest()
        btctx_api = BtcTxStore(testnet=True, dryrun=True)
        sender_key = btctx_api.create_key()
        audit_call_result = core.audit(test_url_address, sender_key,
                                       btctx_api, file_hash, seed)

        expected_calls = [call(
                urljoin(test_url_address, '/api/audit/'),
                data={
                    'data_hash': file_hash,
                    'challenge_seed': seed,
                },
                headers={
                    'sender-address': btctx_api.get_address(sender_key),
                    'signature': btctx_api.sign_unicode(sender_key, file_hash),
                }
        )]
        self.assertListEqual(
            self.mock_post.call_args_list,
            expected_calls,
            'In the audit() function requests.post() calls are unexpected'
        )
        self.assertIs(
            self.mock_post.return_value,
            audit_call_result,
            'Returned value must be the object returned by the '
            '``requests.post()``'
        )
开发者ID:StorjOld,项目名称:metatool,代码行数:37,代码来源:test_metatool_core_unit.py

示例6: callback

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
        def callback():
            blockchain = BtcTxStore()
            wif = blockchain.create_key()
            address = blockchain.get_address(wif)
            farmer = Farmer(address)

            header_date = formatdate(timeval=mktime(datetime.now().timetuple()),
                                     localtime=True, usegmt=True)
            header_authorization = blockchain.sign_unicode(wif, "lalala-wrong")
            farmer.authenticate(header_authorization, header_date)
开发者ID:jorgebonilla,项目名称:dataserv,代码行数:12,代码来源:test_Farmer.py

示例7: TestAuth

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestAuth(unittest.TestCase):

    def setUp(self):
        self.btctxstore = BtcTxStore()
        self.sender_wif = self.btctxstore.create_key()
        self.sender = self.btctxstore.get_address(self.sender_wif)
        recipient_wif = self.btctxstore.create_key()
        self.recipient = self.btctxstore.get_address(recipient_wif)

    def test_self_validates(self):
        headers = storjcore.auth.create_headers(self.btctxstore,
                                                self.recipient,
                                                self.sender_wif)

        self.assertTrue(storjcore.auth.verify_headers(self.btctxstore,
                                                      headers,
                                                      5, self.sender,
                                                      self.recipient))

    def test_invalid_signature(self):
        def callback():
            headers = storjcore.auth.create_headers(self.btctxstore,
                                                    self.recipient,
                                                    self.sender_wif)
            headers["Authorization"] = base64.b64encode(65 * b"x")
            storjcore.auth.verify_headers(self.btctxstore, headers,
                                          5, self.sender, self.recipient)
        self.assertRaises(storjcore.auth.AuthError, callback)

    def test_timeout_to_old(self):
        def callback():
            headers = storjcore.auth.create_headers(self.btctxstore,
                                                    self.recipient,
                                                    self.sender_wif)
            time.sleep(5)
            storjcore.auth.verify_headers(self.btctxstore, headers,
                                          5, self.sender, self.recipient)
        self.assertRaises(storjcore.auth.AuthError, callback)

    @unittest.skip("TODO implement")
    def test_timeout_to_young(self):
        pass  # FIXME how to test this?
开发者ID:cloud-school,项目名称:storjcore,代码行数:44,代码来源:test_auth.py

示例8: test_authentication_success

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def test_authentication_success(self):
        blockchain = BtcTxStore()
        wif = blockchain.create_key()
        address = blockchain.get_address(wif)
        farmer = Farmer(address)

        header_date = formatdate(timeval=mktime(datetime.now().timetuple()),
                                 localtime=True, usegmt=True)
        message = farmer.get_server_address() + " " + header_date
        header_authorization = blockchain.sign_unicode(wif, message)
        self.assertTrue(farmer.authenticate(header_authorization, header_date))
开发者ID:F483,项目名称:dataserv,代码行数:13,代码来源:test_Farmer.py

示例9: TestSignUnicode

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestSignUnicode(unittest.TestCase):

    def setUp(self):
        self.api = BtcTxStore(dryrun=True, testnet=True)

    def test_sign_a(self):
        wif = fixtures["wallet"]["wif"]
        message = u"üöä"
        address = self.api.get_address(wif)
        sig = self.api.sign_unicode(wif, message)
        valid = self.api.verify_signature_unicode(address, sig, message)
        self.assertEqual(valid, True)

    def test_sign_b(self):
        wif = "cSuT2J14dYbe1zvB5z5WTXeRcMbj4tnoKssAK1ZQbnX5HtHfW3bi"
        message = u"üöä"
        address = self.api.get_address(wif)
        sig = self.api.sign_unicode(wif, message)
        valid = self.api.verify_signature_unicode(address, sig, message)
        self.assertEqual(valid, True)
开发者ID:F483,项目名称:btctxstore,代码行数:22,代码来源:other.py

示例10: TestSignData

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestSignData(unittest.TestCase):

    def setUp(self):
        self.api = BtcTxStore(dryrun=True, testnet=True)

    def test_sign_a(self):
        wif = fixtures["wallet"]["wif"]
        data = binascii.hexlify(b"testmessage")
        address = self.api.get_address(wif)
        sig = self.api.sign_data(wif, data)
        valid = self.api.verify_signature(address, sig, data)
        self.assertEqual(valid, True)

    def test_sign_b(self):
        wif = "cSuT2J14dYbe1zvB5z5WTXeRcMbj4tnoKssAK1ZQbnX5HtHfW3bi"
        data = binascii.hexlify(b"testmessage")
        address = self.api.get_address(wif)
        sig = self.api.sign_data(wif, data)
        valid = self.api.verify_signature(address, sig, data)
        self.assertEqual(valid, True)
开发者ID:F483,项目名称:btctxstore,代码行数:22,代码来源:other.py

示例11: callback

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
        def callback():
            blockchain = BtcTxStore()
            wif = blockchain.create_key()
            address = blockchain.get_address(wif)
            farmer = Farmer(address)

            header_date = formatdate(timeval=mktime(datetime.now().timetuple())
                                     , localtime=True, usegmt=True)
            message = farmer.get_server_address() + " " + header_date
            header_authorization = blockchain.sign_unicode(wif, message)
            headers = {"Date": None, "Authorization": header_authorization}
            farmer.authenticate(headers)
开发者ID:StorjOld,项目名称:dataserv,代码行数:14,代码来源:test_Farmer.py

示例12: callback

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
        def callback():
            blockchain = BtcTxStore()
            wif = blockchain.create_key()
            address = blockchain.get_address(wif)
            farmer = Farmer(address)

            timeout = farmer.get_server_authentication_timeout()

            date = datetime.now() - timedelta(seconds=timeout)
            header_date = formatdate(timeval=mktime(date.timetuple()),
                                     localtime=True, usegmt=True)
            message = farmer.get_server_address() + " " + header_date
            header_authorization = blockchain.sign_unicode(wif, message)
            farmer.authenticate(header_authorization, header_date)
开发者ID:F483,项目名称:dataserv,代码行数:16,代码来源:test_Farmer.py

示例13: TestValidateAddressMainnet

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestValidateAddressMainnet(unittest.TestCase):

    def setUp(self):
        self.testnet_api = BtcTxStore(dryrun=True, testnet=True)
        self.mainnet_api = BtcTxStore(dryrun=True, testnet=False)

    def test_valid_string(self):
        address = '191GVvAaTRxLmz3rW3nU5jAV1rF186VxQc'
        self.assertTrue(self.mainnet_api.validate_address(address))

    def test_valid_network(self):
        address = self.mainnet_api.get_address(self.mainnet_api.create_key())
        self.assertTrue(self.mainnet_api.validate_address(address))

    def test_invalid_network(self):
        address = self.testnet_api.get_address(self.testnet_api.create_key())
        self.assertFalse(self.mainnet_api.validate_address(address))

    def test_invalid_data(self):
        self.assertFalse(self.mainnet_api.validate_address("f483"))

    def test_invalid_type(self):
        self.assertFalse(self.mainnet_api.validate_address(None))
开发者ID:F483,项目名称:btctxstore,代码行数:25,代码来源:other.py

示例14: TestValidateAddressTestnet

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
class TestValidateAddressTestnet(unittest.TestCase):

    def setUp(self):
        self.testnet_api = BtcTxStore(dryrun=True, testnet=True)
        self.mainnet_api = BtcTxStore(dryrun=True, testnet=False)

    def test_valid_string(self):
        address = 'migiScBNvVKYwEiCFhgBNGtZ87cdygtuSQ'
        self.assertTrue(self.testnet_api.validate_address(address))

    def test_valid_network(self):
        address = self.testnet_api.get_address(self.testnet_api.create_key())
        self.assertTrue(self.testnet_api.validate_address(address))

    def test_invalid_network(self):
        address = self.mainnet_api.get_address(self.mainnet_api.create_key())
        self.assertFalse(self.testnet_api.validate_address(address))

    def test_invalid_data(self):
        self.assertFalse(self.testnet_api.validate_address("f483"))

    def test_invalid_type(self):
        self.assertFalse(self.testnet_api.validate_address(None))
开发者ID:F483,项目名称:btctxstore,代码行数:25,代码来源:other.py

示例15: test_authentication_timeout_future_success

# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import get_address [as 别名]
    def test_authentication_timeout_future_success(self):
        blockchain = BtcTxStore()
        wif = blockchain.create_key()
        address = blockchain.get_address(wif)
        farmer = Farmer(address)

        timeout = farmer.get_server_authentication_timeout() - 5

        date = datetime.now() + timedelta(seconds=timeout)
        header_date = formatdate(timeval=mktime(date.timetuple()),
                                 localtime=True, usegmt=True)
        message = farmer.get_server_address() + " " + header_date
        header_authorization = blockchain.sign_unicode(wif, message)
        headers = {"Date": header_date, "Authorization": header_authorization}
        self.assertTrue(farmer.authenticate(headers))
开发者ID:StorjOld,项目名称:dataserv,代码行数:17,代码来源:test_Farmer.py


注:本文中的btctxstore.BtcTxStore.get_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。