コード例 #1
0
 def _do_test_parse_URI(self, uri, expected_address, expected_amount, expected_label, expected_message, expected_request_url, chaincode="BTC"):
     address, amount, label, message, request_url = parse_URI(uri, active_chain=chainparams.get_chain_instance(chaincode))
     self.assertEqual(expected_address, address)
     self.assertEqual(expected_amount, amount)
     self.assertEqual(expected_label, label)
     self.assertEqual(expected_message, message)
     self.assertEqual(expected_request_url, request_url)
コード例 #2
0
    def test_all_chainkey_modules(self):
        all_chains = chainparams.known_chains
        for params in all_chains:
            chain = chainparams.get_chain_instance(params.code)
            # ensure params data is correct
            self.assertEqual(params.chain_index, chain.chain_index)
            self.assertEqual(params.coin_name, chain.coin_name)
            self.assertEqual(params.code, chain.code)

            ##  sanity-test chainkey module data ##
            # constants should be non-negative
            self.assertGreaterEqual(chain.chain_index, 0)
            self.assertGreaterEqual(chain.DUST_THRESHOLD, 0)
            self.assertGreaterEqual(chain.MIN_RELAY_TX_FEE, 0)
            self.assertGreaterEqual(chain.RECOMMENDED_FEE, 0)
            self.assertGreaterEqual(chain.COINBASE_MATURITY, 0)
            # version bytes should be between 0 and 255, inclusive
            self.assertGreaterEqual(chain.p2pkh_version, 0)
            self.assertLessEqual(chain.p2pkh_version, 255)
            self.assertGreaterEqual(chain.p2sh_version, 0)
            self.assertLessEqual(chain.p2sh_version, 255)
            self.assertGreaterEqual(chain.wif_version, 0)
            self.assertLessEqual(chain.wif_version, 255)
            # collections
            self.assertGreaterEqual(len(chain.block_explorers), 1)
            # block explorers should be a dict of {Website: URL}
            for k, v in chain.block_explorers.items():
                self.assertTrue(isinstance(k, str),
                                "Block explorer website is not a string.")
                self.assertTrue(isinstance(v, str),
                                "Block explorer URL is not a string.")
            self.assertGreaterEqual(len(chain.DEFAULT_SERVERS), 1)
            # default servers should be a dict of {Server: Ports}
            for k, v in chain.DEFAULT_SERVERS.items():
                self.assertTrue(isinstance(k, str),
                                "Server name is not a string.")
                self.assertTrue(isinstance(v, dict),
                                "Server ports are not a dictionary.")
            # there must be a unit with 8 decimal places since that's the default
            self.assertGreaterEqual(len(chain.base_units), 1)
            self.assertIn(8, chain.base_units.values())
            # base units should be a dict of {Unit: DecimalPlaces}
            for k, v in chain.base_units.items():
                self.assertTrue(isinstance(k, str),
                                "Base unit is not a string.")
                self.assertTrue(isinstance(v, int),
                                "Base unit decimal point is not an int.")
            if len(chain.checkpoints) > 0:
                for k, v in chain.checkpoints.items():
                    self.assertTrue(isinstance(k, int),
                                    "Checkpoint height is not an int.")
                    self.assertTrue(
                        len(v) == 64, "Checkpoint hash is not 64 characters.")
コード例 #3
0
    def test_all_chainkey_modules(self):
        all_chains = chainparams.known_chains
        for params in all_chains:
            chain = chainparams.get_chain_instance(params.code)
            # ensure params data is correct
            self.assertEqual(params.chain_index, chain.chain_index)
            self.assertEqual(params.coin_name, chain.coin_name)
            self.assertEqual(params.code, chain.code)

            ##  sanity-test chainkey module data ##
            # constants should be non-negative
            self.assertGreaterEqual(chain.chain_index, 0)
            self.assertGreaterEqual(chain.DUST_THRESHOLD, 0)
            self.assertGreaterEqual(chain.MIN_RELAY_TX_FEE, 0)
            self.assertGreaterEqual(chain.RECOMMENDED_FEE, 0)
            self.assertGreaterEqual(chain.COINBASE_MATURITY, 0)
            # version bytes should be between 0 and 255, inclusive
            self.assertGreaterEqual(chain.p2pkh_version, 0)
            self.assertLessEqual(chain.p2pkh_version, 255)
            self.assertGreaterEqual(chain.p2sh_version, 0)
            self.assertLessEqual(chain.p2sh_version, 255)
            self.assertGreaterEqual(chain.wif_version, 0)
            self.assertLessEqual(chain.wif_version, 255)
            # collections
            self.assertGreaterEqual(len(chain.block_explorers), 1)
            # block explorers should be a dict of {Website: URL}
            for k, v in chain.block_explorers.items():
                self.assertTrue(isinstance(k, str), "Block explorer website is not a string.")
                self.assertTrue(isinstance(v, str), "Block explorer URL is not a string.")
            self.assertGreaterEqual(len(chain.DEFAULT_SERVERS), 1)
            # default servers should be a dict of {Server: Ports}
            for k, v in chain.DEFAULT_SERVERS.items():
                self.assertTrue(isinstance(k, str), "Server name is not a string.")
                self.assertTrue(isinstance(v, dict), "Server ports are not a dictionary.")
            # there must be a unit with 8 decimal places since that's the default
            self.assertGreaterEqual(len(chain.base_units), 1)
            self.assertIn(8, chain.base_units.values())
            # base units should be a dict of {Unit: DecimalPlaces}
            for k, v in chain.base_units.items():
                self.assertTrue(isinstance(k, str), "Base unit is not a string.")
                self.assertTrue(isinstance(v, int), "Base unit decimal point is not an int.")
            if len(chain.checkpoints) > 0:
                for k, v in chain.checkpoints.items():
                    self.assertTrue(isinstance(k, int), "Checkpoint height is not an int.")
                    self.assertTrue(len(v) == 64, "Checkpoint hash is not 64 characters.")