def test_postprocess_card(): provider = Explorer(network="peercoin-testnet") deck = find_deck( provider, "643dccd585211766fc03f71e92fbf299cfc2bdbf3f2cae0ad85adec3141069f3", 1) raw_tx = provider.getrawtransaction( '809c506bc3add9e46a4d3a65348426688545213da5fb5b524acd380f2cdaf3cc', 1) vout = raw_tx["vout"] blockseq = tx_serialization_order(provider, raw_tx["blockhash"], raw_tx["txid"]) blocknum = provider.getblock(raw_tx["blockhash"])["height"] sender = 'moQzpzzcCYZMnAz224EY4att5A9psxN8X2' card_transfer = CardTransfer( deck=deck, receiver=["n4KuTR5CzyQTbrpwbAKEdTfJERKmtHWWgr"], amount=[1], version=1, ) card = postprocess_card(card_metainfo=card_transfer.metainfo_to_dict, raw_tx=raw_tx, sender=sender, vout=vout, blockseq=blockseq, blocknum=blocknum, tx_confirmations=raw_tx['confirmations'], deck=deck) assert isinstance(card, list)
def test_explorer_getblock(): provider = Explorer(network="ppc") assert isinstance( provider.getblock( '00000000000da9a26b4f4ce3f1f286438ec2198e5f60d108fafa700061b486e7' ), dict)
def test_validate_deckspawn_p2th(): '''test deckspawn p2th validation''' provider = Explorer(network="peercoin-testnet") p2th = param_query('peercoin-testnet').P2TH_addr raw_tx = provider.getrawtransaction('643dccd585211766fc03f71e92fbf299cfc2bdbf3f2cae0ad85adec3141069f3', 1,) assert validate_deckspawn_p2th(provider, raw_tx, p2th)
def test_find_tx_sender(prov): if prov == "explorer": provider = Explorer(network="peercoin") rawtx = provider.getrawtransaction("397bda2f5e6608c872a663b2e5482d95db8ecfad00757823f0f12caa45a213a6", 1) assert find_tx_sender(provider, rawtx) == 'PNHGzKupyvo2YZVb1CTdRxtCGBB5ykgiug' if prov == "cryptoid": provider = Cryptoid(network="peercoin") rawtx = provider.getrawtransaction("397bda2f5e6608c872a663b2e5482d95db8ecfad00757823f0f12caa45a213a6", 1) assert find_tx_sender(provider, rawtx) == 'PNHGzKupyvo2YZVb1CTdRxtCGBB5ykgiug'
def test_tx_serialization_order(prov): if prov == "explorer": provider = Explorer(network="peercoin-testnet") assert tx_serialization_order( provider, txid= "f968702bcedc107959aae2c2b1a1becdccbfe7e5a32b460b2c13c1adaa33d541", blockhash= "e234d2ef69f7cd1e7ee489546b39314cc838763b4e32438106cba657d9749f2f" ) == 1 if prov == "mintr": provider = Mintr() assert tx_serialization_order( provider, txid= "6f9c76f5e2d188c8d4e8411a89dd152ca94e6b1756aec6c4d12fcbf0450970f7", blockhash= "13ea431cb818628d762f224fb3fa957ecdbab661d190d28aedef8449e007f207" ) == 0 try: if prov == "rpc": provider = RpcNode(testnet=True) assert tx_serialization_order( provider, txid= "f968702bcedc107959aae2c2b1a1becdccbfe7e5a32b460b2c13c1adaa33d541", blockhash= "e234d2ef69f7cd1e7ee489546b39314cc838763b4e32438106cba657d9749f2f" ) == 1 except: print("No RpcNode avaliable.")
def test_find_deck_spawns(prov): if prov == "explorer": provider = Explorer(network="peercoin") if prov == "cryptoid": provider = Cryptoid(network="peercoin") assert isinstance(find_deck_spawns(provider), Generator)
def test_tx_serialization_order(prov): if prov == "explorer": provider = Explorer(network="peercoin-testnet") assert tx_serialization_order(provider, txid="f968702bcedc107959aae2c2b1a1becdccbfe7e5a32b460b2c13c1adaa33d541", blockhash="e234d2ef69f7cd1e7ee489546b39314cc838763b4e32438106cba657d9749f2f") == 1 try: if prov == "rpc": provider = RpcNode(testnet=True) assert tx_serialization_order(provider, txid="f968702bcedc107959aae2c2b1a1becdccbfe7e5a32b460b2c13c1adaa33d541", blockhash="e234d2ef69f7cd1e7ee489546b39314cc838763b4e32438106cba657d9749f2f") == 1 except: print("No RpcNode avaliable.")
def test_explorer_listtransactions(): assert isinstance( Explorer(network="ppc").listtransactions( 'PHvDhfz1dGyPbZZ3Qnp56y92zmy98sncZT'), list)
def test_explorer_getrawtransaction(): assert isinstance( Explorer(network="ppc").getrawtransaction( '34d19bf5a5c757d5bcbf83a91ad9bc04365c58a035a6bf728bce8013ad04c173' ), dict)
def test_explorer_network(): assert Explorer(network="ppc").network == "peercoin"
def test_explorer_getreceivedbyaddress(): assert isinstance( Explorer(network="ppc").getreceivedbyaddress( 'PHvDhfz1dGyPbZZ3Qnp56y92zmy98sncZT'), Decimal)
def test_explorer_getbalance(): assert isinstance( Explorer( network="ppc").getbalance('PHvDhfz1dGyPbZZ3Qnp56y92zmy98sncZT'), Decimal)
def test_explorer_getdifficulty(): assert isinstance(Explorer(network="ppc").getdifficulty(), dict)
def test_explorer_get_block_hash(): assert isinstance(Explorer(network="ppc").getblockhash(3378), str)
def test_explorer_getblockcount(): assert isinstance(Explorer(network="ppc").getblockcount(), int)
def test_explorer_listunspent(): assert isinstance( Explorer( network="ppc").listunspent('PAdonateFczhZuKLkKHozrcyMJW7Y6TKvw'), list)
def test_explorer_is_testnet(): explorer = Explorer(network="ppc") assert isinstance(explorer.is_testnet, bool) assert explorer.is_testnet is False