mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Fix minor bugs in JSONRPC daemon backend and offline wallet, add tests
This commit is contained in:
parent
3478e24d33
commit
64149f6323
8 changed files with 173 additions and 7 deletions
|
@ -53,7 +53,8 @@ class JSONRPCDaemon(object):
|
|||
txs.append(Transaction(
|
||||
hash=tx['id_hash'],
|
||||
fee=from_atomic(tx['fee']),
|
||||
timestamp=datetime.fromtimestamp(tx['receive_time'])))
|
||||
timestamp=datetime.fromtimestamp(tx['receive_time']),
|
||||
confirmations=0))
|
||||
return txs
|
||||
|
||||
def raw_request(self, path, data):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from .. import exceptions
|
||||
from ..account import Account
|
||||
from ..address import Address
|
||||
from ..numbers import EMPTY_KEY
|
||||
from ..seed import Seed
|
||||
|
||||
|
||||
|
@ -14,7 +15,7 @@ class OfflineWallet(object):
|
|||
"""
|
||||
_address = None
|
||||
_svk = None
|
||||
_ssk = None
|
||||
_ssk = EMPTY_KEY
|
||||
|
||||
def __init__(self, address, view_key=None, spend_key=None):
|
||||
self._address = Address(address)
|
||||
|
@ -42,7 +43,7 @@ class OfflineWallet(object):
|
|||
def addresses(self, account=0):
|
||||
if account == 0:
|
||||
return [self._address]
|
||||
raise WalletIsOffline()
|
||||
raise WalletIsOffline() # pragma: no cover (this should never happen)
|
||||
|
||||
def new_address(self, account=0, label=None):
|
||||
raise WalletIsOffline()
|
||||
|
|
|
@ -2,6 +2,7 @@ from decimal import Decimal
|
|||
import sys
|
||||
|
||||
PICONERO = Decimal('0.000000000001')
|
||||
EMPTY_KEY = '0' * 64
|
||||
|
||||
if sys.version_info < (3,): # pragma: no cover
|
||||
_integer_types = (int, long,)
|
||||
|
|
|
@ -5,6 +5,7 @@ import struct
|
|||
from . import address
|
||||
from . import base58
|
||||
from . import ed25519
|
||||
from . import numbers
|
||||
from . import prio
|
||||
from .transaction import Payment, PaymentManager
|
||||
|
||||
|
@ -68,7 +69,7 @@ class Wallet(object):
|
|||
:rtype: str or None
|
||||
"""
|
||||
key = self._backend.spend_key()
|
||||
if key.strip('0') == '':
|
||||
if key == numbers.EMPTY_KEY:
|
||||
return None
|
||||
return key
|
||||
|
||||
|
|
38
tests/data/test_jsonrpcdaemon/test_basic_info-get_info.json
Normal file
38
tests/data/test_jsonrpcdaemon/test_basic_info-get_info.json
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"id": 0,
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"alt_blocks_count": 188,
|
||||
"block_size_limit": 600000,
|
||||
"block_size_median": 300000,
|
||||
"block_weight_limit": 600000,
|
||||
"block_weight_median": 300000,
|
||||
"bootstrap_daemon_address": "",
|
||||
"cumulative_difficulty": 11208345440,
|
||||
"database_size": 4434726912,
|
||||
"difficulty": 8068,
|
||||
"free_space": 18446744073709551615,
|
||||
"grey_peerlist_size": 580,
|
||||
"height": 294993,
|
||||
"height_without_bootstrap": 294993,
|
||||
"incoming_connections_count": 22,
|
||||
"mainnet": false,
|
||||
"nettype": "stagenet",
|
||||
"offline": false,
|
||||
"outgoing_connections_count": 5,
|
||||
"rpc_connections_count": 1,
|
||||
"stagenet": true,
|
||||
"start_time": 1552341929,
|
||||
"status": "OK",
|
||||
"target": 120,
|
||||
"target_height": 294919,
|
||||
"testnet": false,
|
||||
"top_block_hash": "e93984090c86b3b97b8a73c3fa0688acb3ea46603274e69cdbeef94b4b62fd78",
|
||||
"tx_count": 102229,
|
||||
"tx_pool_size": 2,
|
||||
"untrusted": false,
|
||||
"update_available": false,
|
||||
"was_bootstrap_ever_used": false,
|
||||
"white_peerlist_size": 110
|
||||
}
|
||||
}
|
56
tests/data/test_jsonrpcdaemon/test_mempool-transactions.json
Normal file
56
tests/data/test_jsonrpcdaemon/test_mempool-transactions.json
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"spent_key_images": [
|
||||
{
|
||||
"id_hash": "26230bfb4dfb4596ab15c2cb59829f95cef2b7dbd61b2b4d2ae8695aa34246b3",
|
||||
"txs_hashes": [
|
||||
"ee05fbf199808db8e1c2b1117907d20608ba7a84434bd48cb1674921746bfa08"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id_hash": "f2062857ac917392a703d6e699dc7c7a4ba0e72f7260acaa50e9051f4f5b17aa",
|
||||
"txs_hashes": [
|
||||
"e7423e8d427cab6e151a1860b99c6dd8cb9e44cdff56465c42f8cb8104b633e5"
|
||||
]
|
||||
}
|
||||
],
|
||||
"status": "OK",
|
||||
"transactions": [
|
||||
{
|
||||
"blob_size": 1768,
|
||||
"do_not_relay": false,
|
||||
"double_spend_seen": false,
|
||||
"fee": 245590000,
|
||||
"id_hash": "ee05fbf199808db8e1c2b1117907d20608ba7a84434bd48cb1674921746bfa08",
|
||||
"kept_by_block": true,
|
||||
"last_failed_height": 0,
|
||||
"last_failed_id_hash": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"last_relayed_time": 0,
|
||||
"max_used_block_height": 290683,
|
||||
"max_used_block_id_hash": "199da0b69826af648af8a63df3d14d27fba8f4d9a75a357c77181f3dc58e3887",
|
||||
"receive_time": 0,
|
||||
"relayed": true,
|
||||
"tx_blob": "02000102000bfcad04fdb43acf9a019971c7f104e031ab045ce9014bad0126230bfb4dfb4596ab15c2cb59829f95cef2b7dbd61b2b4d2ae8695aa34246b30200024e61a18a53d1616dfcb3c14641556db7b56a22a1d29190c620a0b8db9da15ce60002770c0106256771e00496728fce6b201537891200e2145df48e8f01187850f6672c016ea0ee6bcb7c83be9ebaa20d85fbf3d02fa4ceb441d771b2ef559451a2075fd5020901102f0c87be1e49d304f0cf8d75f2a6f5931efb6f7046185ce54667d8ab63b9a897aec882d39de2d54535bfda74f3a48b123b28e5be3c364d523f7deb27813fece8a8b18a4df7c5e19fb271576c7383abede49275a2d10bebde603ce449010b647923836972c26e0f202bfddb443add24ff752874a83488e60ebc000078cab3852b570d93019273703f71aebd23b0843dd8fedd03de9061410c57f38c25f5b92b2ffb5a0f661890295c91415347e6b1d6930e39feeebf867a281b8c8bf3cddedf7893a6df87293928432c74ebb2e141d0f28e23ce15dd3f558272b464e511a3706a5f1fc71038291b1e2c41c9ca357c67a9f3647516a9b4eabefcbc7ebe0a63bc781db41ed13c5b33f6d2d9f94df2a6e65cb93f88f4ab504e368a384cf80707989eb88483ce523cf5d0061a2fc1ba4108c5b5a34e62665a56f561435bbdb11359ff3e6b2c81356b20bbe29bdf7dd496d492aacda730f51f0b7934ae9d20aa2fe9c7958c4ff805d87a507bfea1f460c6dc004718385dd24025b86d5b28cd7e339a81f89e03366a545b69d3443d74651f38f1c3f9b9570529538dcccfe4f1b2cab41ea7edc80b3d43ecd425bd312942734960cd28f3bef12131ed7a69030915497a6e605f0afe1db144812a04e6625e921560fb4599ca358256a88fcf762b4b70175711f120dd2d3b00c6545179564b6d0c3fc04e9282b8214220a3c069f4d3b50750639e2147c86225bb2c0ad84ce42e0a4199a4e75275345cd33e050674b80c7a6b14d16cffe010fc50cdffd1cd4156ac0eb8c664d4fd607efd561ca9072021ea61c7aaecf2f73c32647b84a0a30ca5042181597457d7c57edaff905f9e3eddfd540b4e8674f718703cb146eba5ecf8ad0657465c84b237500624c41ed20724347a419bf0b54a87297424832874e32c369f209348c6791fb5a342f9d676d137d4e2a3c7c241e3c211a825c70fd0a9bfdf2d76633206574a5ccdaa11d2a403b8b2eb53a0d0832971d61b7db09c6003b9014f6ef19e74cd4bfb6ff76d6b8f33f1ec1878de026ee8e570b7c6df6b285eb168f84274d788ef057fc6fe703d3d48980ee1e31e75e972d0ec7dd9ee045261eeba6ff6b435fa85b14587b73fbe95466e0f43a7673beaa085b9acb9622713f7dc6bab7a1952062de7216e4e7ef9ee55210755c72d99720c33e17255bba339215b1d812d21f8e6ca22247d906e2baad5fe08e357b3a85844e0a8b56ed63130c80ca1418ae6330b8323c5c4bf6dc7eedd5100240cf468574fed363e6f7d686fed9b82a72c82dd6bdda6f6e4c961ccd90046045082dadc462ef1aeca97f1c19f7921afbfc9bc4900d9895987e50d3d46a5150adbf7ab290a2c02500671f5a712eba7b7935f18c553681c4b0e8dde30de673008dcf1e2089f33d9833e8bf8012ebec0b04dfc18a76146c620af872ab1dc0d4f00f873bb7a83ead6c7682bd6b311a8db08e3b99cd836d05e8bb990e60e5290e70b7170b13699b9db45319ec62426b2f91e6e5b4aec4ac1939345505bbd3ac636058290cacb203ba2214aad886f665cfa6f5cce719ff3e647e4aa4624bd7359e305198a9e6d8868387db4250a69054a65d3cfc772126be54a3579746abcac0b9400c949a3e1ed26918140ba6ac839b2faa7655067f3e9b098b32a539cee0e181502bf2cd9767dcf5d025d4f4724579417dc52e69f28c434183eb03e78c9051481080bbf12d6dc2f5b132a4ee840466278cb3771120cf24506a92c9c8890be508a0169d2d0d19206fc203f0497cd6e3bc2569e268ab13b9f3343bad29a455b59fa09e78ffff72667b32d89cf49fc53c63bce767dd2b19b90c9d561c396e7fa68760ae45f87e499ac9c1f751fd06e0471769058c595008b17fbdabd1aacd6985e53034bc3268eecb0cba2e09f13fbcb14de1387aa6a52fff220b5a801c2b7d402e00d0c6bd4c9a972c356fe289c6abad4668edff83edaa171b942f5a3b59aeead2d05e2e636a899309bec49e3d434243f60cb41c76401b1de29e59bd24cb9158c640dcb07a581b4f1c816cc7e64fcae1bceb2f1400b9e65afd0fab6c4a0d8dc928b03a4908f8a5502453368757be254cd51210e65a4722846c08bc0a76f097d0c7e00e8417f580080e8ee36230f1601612a7708045696aa453bc191e7b829f03d67018f3de005883ba2db5f038d1f1ab4cdc6741022ad4ccbd1781d52b638b6738301b9ca42d48c52579c18cabfed2bccf3673d5aad58907880f5666bd0fce78423dc",
|
||||
"tx_json": "{\n \"version\": 2, \n \"unlock_time\": 0, \n \"vin\": [ {\n \"key\": {\n \"amount\": 0, \n \"key_offsets\": [ 71420, 957053, 19791, 14489, 80071, 6368, 555, 92, 233, 75, 173\n ], \n \"k_image\": \"26230bfb4dfb4596ab15c2cb59829f95cef2b7dbd61b2b4d2ae8695aa34246b3\"\n }\n }\n ], \n \"vout\": [ {\n \"amount\": 0, \n \"target\": {\n \"key\": \"4e61a18a53d1616dfcb3c14641556db7b56a22a1d29190c620a0b8db9da15ce6\"\n }\n }, {\n \"amount\": 0, \n \"target\": {\n \"key\": \"770c0106256771e00496728fce6b201537891200e2145df48e8f01187850f667\"\n }\n }\n ], \n \"extra\": [ 1, 110, 160, 238, 107, 203, 124, 131, 190, 158, 186, 162, 13, 133, 251, 243, 208, 47, 164, 206, 180, 65, 215, 113, 178, 239, 85, 148, 81, 162, 7, 95, 213, 2, 9, 1, 16, 47, 12, 135, 190, 30, 73, 211\n ], \n \"rct_signatures\": {\n \"type\": 4, \n \"txnFee\": 245590000, \n \"ecdhInfo\": [ {\n \"amount\": \"f2a6f5931efb6f70\"\n }, {\n \"amount\": \"46185ce54667d8ab\"\n }], \n \"outPk\": [ \"63b9a897aec882d39de2d54535bfda74f3a48b123b28e5be3c364d523f7deb27\", \"813fece8a8b18a4df7c5e19fb271576c7383abede49275a2d10bebde603ce449\"]\n }, \n \"rctsig_prunable\": {\n \"nbp\": 1, \n \"bp\": [ {\n \"A\": \"0b647923836972c26e0f202bfddb443add24ff752874a83488e60ebc000078ca\", \n \"S\": \"b3852b570d93019273703f71aebd23b0843dd8fedd03de9061410c57f38c25f5\", \n \"T1\": \"b92b2ffb5a0f661890295c91415347e6b1d6930e39feeebf867a281b8c8bf3cd\", \n \"T2\": \"dedf7893a6df87293928432c74ebb2e141d0f28e23ce15dd3f558272b464e511\", \n \"taux\": \"a3706a5f1fc71038291b1e2c41c9ca357c67a9f3647516a9b4eabefcbc7ebe0a\", \n \"mu\": \"63bc781db41ed13c5b33f6d2d9f94df2a6e65cb93f88f4ab504e368a384cf807\", \n \"L\": [ \"989eb88483ce523cf5d0061a2fc1ba4108c5b5a34e62665a56f561435bbdb113\", \"59ff3e6b2c81356b20bbe29bdf7dd496d492aacda730f51f0b7934ae9d20aa2f\", \"e9c7958c4ff805d87a507bfea1f460c6dc004718385dd24025b86d5b28cd7e33\", \"9a81f89e03366a545b69d3443d74651f38f1c3f9b9570529538dcccfe4f1b2ca\", \"b41ea7edc80b3d43ecd425bd312942734960cd28f3bef12131ed7a6903091549\", \"7a6e605f0afe1db144812a04e6625e921560fb4599ca358256a88fcf762b4b70\", \"175711f120dd2d3b00c6545179564b6d0c3fc04e9282b8214220a3c069f4d3b5\"\n ], \n \"R\": [ \"50639e2147c86225bb2c0ad84ce42e0a4199a4e75275345cd33e050674b80c7a\", \"6b14d16cffe010fc50cdffd1cd4156ac0eb8c664d4fd607efd561ca9072021ea\", \"61c7aaecf2f73c32647b84a0a30ca5042181597457d7c57edaff905f9e3eddfd\", \"540b4e8674f718703cb146eba5ecf8ad0657465c84b237500624c41ed2072434\", \"7a419bf0b54a87297424832874e32c369f209348c6791fb5a342f9d676d137d4\", \"e2a3c7c241e3c211a825c70fd0a9bfdf2d76633206574a5ccdaa11d2a403b8b2\", \"eb53a0d0832971d61b7db09c6003b9014f6ef19e74cd4bfb6ff76d6b8f33f1ec\"\n ], \n \"a\": \"1878de026ee8e570b7c6df6b285eb168f84274d788ef057fc6fe703d3d48980e\", \n \"b\": \"e1e31e75e972d0ec7dd9ee045261eeba6ff6b435fa85b14587b73fbe95466e0f\", \n \"t\": \"43a7673beaa085b9acb9622713f7dc6bab7a1952062de7216e4e7ef9ee552107\"\n }\n ], \n \"MGs\": [ {\n \"ss\": [ [ \"55c72d99720c33e17255bba339215b1d812d21f8e6ca22247d906e2baad5fe08\", \"e357b3a85844e0a8b56ed63130c80ca1418ae6330b8323c5c4bf6dc7eedd5100\"], [ \"240cf468574fed363e6f7d686fed9b82a72c82dd6bdda6f6e4c961ccd9004604\", \"5082dadc462ef1aeca97f1c19f7921afbfc9bc4900d9895987e50d3d46a5150a\"], [ \"dbf7ab290a2c02500671f5a712eba7b7935f18c553681c4b0e8dde30de673008\", \"dcf1e2089f33d9833e8bf8012ebec0b04dfc18a76146c620af872ab1dc0d4f00\"], [ \"f873bb7a83ead6c7682bd6b311a8db08e3b99cd836d05e8bb990e60e5290e70b\", \"7170b13699b9db45319ec62426b2f91e6e5b4aec4ac1939345505bbd3ac63605\"], [ \"8290cacb203ba2214aad886f665cfa6f5cce719ff3e647e4aa4624bd7359e305\", \"198a9e6d8868387db4250a69054a65d3cfc772126be54a3579746abcac0b9400\"], [ \"c949a3e1ed26918140ba6ac839b2faa7655067f3e9b098b32a539cee0e181502\", \"bf2cd9767dcf5d025d4f4724579417dc52e69f28c434183eb03e78c905148108\"], [ \"0bbf12d6dc2f5b132a4ee840466278cb3771120cf24506a92c9c8890be508a01\", \"69d2d0d19206fc203f0497cd6e3bc2569e268ab13b9f3343bad29a455b59fa09\"], [ \"e78ffff72667b32d89cf49fc53c63bce767dd2b19b90c9d561c396e7fa68760a\", \"e45f87e499ac9c1f751fd06e0471769058c595008b17fbdabd1aacd6985e5303\"], [ \"4bc3268eecb0cba2e09f13fbcb14de1387aa6a52fff220b5a801c2b7d402e00d\", \"0c6bd4c9a972c356fe289c6abad4668edff83edaa171b942f5a3b59aeead2d05\"], [ \"e2e636a899309bec49e3d434243f60cb41c76401b1de29e59bd24cb9158c640d\", \"cb07a581b4f1c816cc7e64fcae1bceb2f1400b9e65afd0fab6c4a0d8dc928b03\"], [ \"a4908f8a5502453368757be254cd51210e65a4722846c08bc0a76f097d0c7e00\", \"e8417f580080e8ee36230f1601612a7708045696aa453bc191e7b829f03d6701\"]], \n \"cc\": \"8f3de005883ba2db5f038d1f1ab4cdc6741022ad4ccbd1781d52b638b6738301\"\n }], \n \"pseudoOuts\": [ \"b9ca42d48c52579c18cabfed2bccf3673d5aad58907880f5666bd0fce78423dc\"]\n }\n}",
|
||||
"weight": 1768
|
||||
},
|
||||
{
|
||||
"blob_size": 1763,
|
||||
"do_not_relay": false,
|
||||
"double_spend_seen": false,
|
||||
"fee": 245050000,
|
||||
"id_hash": "e7423e8d427cab6e151a1860b99c6dd8cb9e44cdff56465c42f8cb8104b633e5",
|
||||
"kept_by_block": true,
|
||||
"last_failed_height": 0,
|
||||
"last_failed_id_hash": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"last_relayed_time": 0,
|
||||
"max_used_block_height": 290379,
|
||||
"max_used_block_id_hash": "0c44863dfcbd7e1aed6d7a33531a22df062f5bd28d640686189e1022bba82f23",
|
||||
"receive_time": 0,
|
||||
"relayed": true,
|
||||
"tx_blob": "02030102000bffa245d250c5079209e904de083c4b36a10118f2062857ac917392a703d6e699dc7c7a4ba0e72f7260acaa50e9051f4f5b17aa0200021f1e79ce457a3d134131eb60d779fe1057b9ba0dd4a48de0007f461f99c5d9370002e52bccc36256b200c5f96ac05a6791c5944a638110efc18b16002ab12b50b4002c01e5b73cb42bae234ff15d5e458be457d320244f3cac7444a4e0ef8e83a64ade200209010a9e5820057493b80490d5ec749d339cfb8abcca1590ac2e7cbbad45443de53d9162b2663fb02f9fe30612ebb1984a0831f1f4f3cd71fa49addbce9a6e318e41c7bcc1a090e1e0d2c9f42aa6c8f2e345727d9f115856af5ce63644d145010c9b6c4aba07ebd2e64f71596fbe86f0b6f360c680be1ffe764907e0ebeeaf3004228d90ecc41833dad2d6277c444901f6bbb647652014caed4749cc00922d4eb7956ee847b4b94c1bf0897468702976f019b5689230718986e1dee0329c87ddac3e0c037ab49a1624abb91d0d294921f1f35dbfc0fa52e79f63db7689b8034d7577f062e516e4af41d139b92e0dcf440cb2706d071be0344a81cf2a22306e053ca8e486c1d9428fb7c0ab047ca83bc23d620c180b9268f2f73efede20ee520207ad2b0971314f3d2e5e1b939ec90b0961f6879fad3b6eb10b4da5d4c9c4b830d2409d7e04061390d82a5241aa45fb8a1f3439c4f9383327843179cfcacbecd5bcd2766b027baea8608fe4f5a38c4d980f6a2b7a0a60d0c1e2e5f20616b5f23d98bad5083a3d7c1c8718d7ab4718a757948668f86047b88fd9b6806e757ee2e05a2f0756c2906f83facd0e761c34bf251b2d3cac538687f994f611e91fd08691e2f137b55635e15a1dd0458a81a771caef93a5a570b61005cf9bb93cec65c2fc308761e07f736646612270055d02c81523c69cba3d002dfe69375d44006f97c854073315fb93a75f18c9b01bbf5e9cc8c568386dcde680e69e0369f4ff0234be894da4faeca1dd9fa34619d1b85c0253f35938f1787b0bdb2b9abcb02c3f074421bbeb159e190a0ced389a4a869d392a2562eada35a2da86ab1a81294a185ce5e02332822008e3915dc7f0f1a71dea6adb4b02dd9013470025d71780eee19f893382fac00f62879a475cc15af57bba837bf2771a0f028bef0e3c3f910c9ba0113a662d15fc7a15e3f926ad35fd7d15864c8798dab2158cc544d1b901624a1a1eff238f4a9d72327950f0cad5d19216b209ea7703809f58944822fc33000457802421cf598f9fe99f1eed95097a9f6940d890b217713793d18a1e4851995431a80c0cbb1726a08f45fa9f695e8740768f1e34960edb25a0e90597694e05050f9ec304a5ee860008239f27404d73c8b6bf2566888fdd9e41065d759be6273bc3f5af0fa32bddc99daf4f66601622dab43373b60e5912295c643445c9573be623dd9e0c81acd29ee9a672b993ab2b4c7d69fcaf584a2aa662131b048577a0cdff3c0c08e6e1efb4b3155067ec3b5055efd0a7b971d05169b540f25d1cda7704d302060a36964b1e3023ad079a01a6a3228a6aa0d484b952ec48f41206a659ca45e7b60075483c28bc683713bbbda0626b08b73724222bcc7015a4a00b307fdcf8cfb2099ded995889b441555eb34411f66bc170da8fc0731d994c92105e3032600bfe0a6f78fe90be7cbec2eed9dab1d1f0e6f52db2160fa9fe5d8c24c2cc7694a18f09eb4f2068121532143cab380eed5f75fa72f29bc03ea8a7ad5e47188ca080b00d351804e6610ac9841f887f36042f104150acb8d8d4fb41c7c99a6bf71d5ce60f0a5dff5780c754c1b0be7972b9b627efb73fc555d30da21939d368cf2ecff800982f3a0d9c2b03e55860800431a68eb8565e07796c361d69407863520c277b058ecd785cec646b3c2d778ae7e0ad0ec79d1e0ee1b53566865aafe747bb678807c8185d605934758224398b8d916645f9079f5fa29b59f0f7d9c925e5adfa5007fe710e4d9d1e7044b99955985dcca690dd58e3afe8077182c60d7f0712997b013a4f91cd808bb6eeeacb83451caa750c5638b990e17e6f92af327f2947d6910ccad8282afd5fbc5fe7a443dd532d0d5157f28bf9ee3a965d60ebd9b52eb9820c75b9b5a096da69131ee15ae9fbcb55b875ecfbf3eafac3930105b794690ded0fb76a1a7da2f09a9b2afeb335ae89a676609c265a02605b673967addff91be00483b8b22e578ccdf58280bde6f123362d8d1a70b4643fc8d451756a833d364c0a447c11a71c6a1c3ff393a838741055c6612871963415101a597837aea09c4401e3dd75277cebd81367a25c8c9f7eef57256a8b865487acf39026cb99e054a800711382595df75968bfd7b58dea401ec901a597aa351694980ca8a784a94d300e26d42d1aa8ef925700aca0258bf5405b59de583f97f6d00dfffec14c695a0606e838eae93ee2d370efe20fafc633b5200a6d08609bd5af9b7eafcbb6061d6297",
|
||||
"tx_json": "{\n \"version\": 2, \n \"unlock_time\": 3, \n \"vin\": [ {\n \"key\": {\n \"amount\": 0, \n \"key_offsets\": [ 1134975, 10322, 965, 1170, 617, 1118, 60, 75, 54, 161, 24\n ], \n \"k_image\": \"f2062857ac917392a703d6e699dc7c7a4ba0e72f7260acaa50e9051f4f5b17aa\"\n }\n }\n ], \n \"vout\": [ {\n \"amount\": 0, \n \"target\": {\n \"key\": \"1f1e79ce457a3d134131eb60d779fe1057b9ba0dd4a48de0007f461f99c5d937\"\n }\n }, {\n \"amount\": 0, \n \"target\": {\n \"key\": \"e52bccc36256b200c5f96ac05a6791c5944a638110efc18b16002ab12b50b400\"\n }\n }\n ], \n \"extra\": [ 1, 229, 183, 60, 180, 43, 174, 35, 79, 241, 93, 94, 69, 139, 228, 87, 211, 32, 36, 79, 60, 172, 116, 68, 164, 224, 239, 142, 131, 166, 74, 222, 32, 2, 9, 1, 10, 158, 88, 32, 5, 116, 147, 184\n ], \n \"rct_signatures\": {\n \"type\": 4, \n \"txnFee\": 245050000, \n \"ecdhInfo\": [ {\n \"amount\": \"9d339cfb8abcca15\"\n }, {\n \"amount\": \"90ac2e7cbbad4544\"\n }], \n \"outPk\": [ \"3de53d9162b2663fb02f9fe30612ebb1984a0831f1f4f3cd71fa49addbce9a6e\", \"318e41c7bcc1a090e1e0d2c9f42aa6c8f2e345727d9f115856af5ce63644d145\"]\n }, \n \"rctsig_prunable\": {\n \"nbp\": 1, \n \"bp\": [ {\n \"A\": \"0c9b6c4aba07ebd2e64f71596fbe86f0b6f360c680be1ffe764907e0ebeeaf30\", \n \"S\": \"04228d90ecc41833dad2d6277c444901f6bbb647652014caed4749cc00922d4e\", \n \"T1\": \"b7956ee847b4b94c1bf0897468702976f019b5689230718986e1dee0329c87dd\", \n \"T2\": \"ac3e0c037ab49a1624abb91d0d294921f1f35dbfc0fa52e79f63db7689b8034d\", \n \"taux\": \"7577f062e516e4af41d139b92e0dcf440cb2706d071be0344a81cf2a22306e05\", \n \"mu\": \"3ca8e486c1d9428fb7c0ab047ca83bc23d620c180b9268f2f73efede20ee5202\", \n \"L\": [ \"ad2b0971314f3d2e5e1b939ec90b0961f6879fad3b6eb10b4da5d4c9c4b830d2\", \"409d7e04061390d82a5241aa45fb8a1f3439c4f9383327843179cfcacbecd5bc\", \"d2766b027baea8608fe4f5a38c4d980f6a2b7a0a60d0c1e2e5f20616b5f23d98\", \"bad5083a3d7c1c8718d7ab4718a757948668f86047b88fd9b6806e757ee2e05a\", \"2f0756c2906f83facd0e761c34bf251b2d3cac538687f994f611e91fd08691e2\", \"f137b55635e15a1dd0458a81a771caef93a5a570b61005cf9bb93cec65c2fc30\", \"8761e07f736646612270055d02c81523c69cba3d002dfe69375d44006f97c854\"\n ], \n \"R\": [ \"3315fb93a75f18c9b01bbf5e9cc8c568386dcde680e69e0369f4ff0234be894d\", \"a4faeca1dd9fa34619d1b85c0253f35938f1787b0bdb2b9abcb02c3f074421bb\", \"eb159e190a0ced389a4a869d392a2562eada35a2da86ab1a81294a185ce5e023\", \"32822008e3915dc7f0f1a71dea6adb4b02dd9013470025d71780eee19f893382\", \"fac00f62879a475cc15af57bba837bf2771a0f028bef0e3c3f910c9ba0113a66\", \"2d15fc7a15e3f926ad35fd7d15864c8798dab2158cc544d1b901624a1a1eff23\", \"8f4a9d72327950f0cad5d19216b209ea7703809f58944822fc33000457802421\"\n ], \n \"a\": \"cf598f9fe99f1eed95097a9f6940d890b217713793d18a1e4851995431a80c0c\", \n \"b\": \"bb1726a08f45fa9f695e8740768f1e34960edb25a0e90597694e05050f9ec304\", \n \"t\": \"a5ee860008239f27404d73c8b6bf2566888fdd9e41065d759be6273bc3f5af0f\"\n }\n ], \n \"MGs\": [ {\n \"ss\": [ [ \"a32bddc99daf4f66601622dab43373b60e5912295c643445c9573be623dd9e0c\", \"81acd29ee9a672b993ab2b4c7d69fcaf584a2aa662131b048577a0cdff3c0c08\"], [ \"e6e1efb4b3155067ec3b5055efd0a7b971d05169b540f25d1cda7704d302060a\", \"36964b1e3023ad079a01a6a3228a6aa0d484b952ec48f41206a659ca45e7b600\"], [ \"75483c28bc683713bbbda0626b08b73724222bcc7015a4a00b307fdcf8cfb209\", \"9ded995889b441555eb34411f66bc170da8fc0731d994c92105e3032600bfe0a\"], [ \"6f78fe90be7cbec2eed9dab1d1f0e6f52db2160fa9fe5d8c24c2cc7694a18f09\", \"eb4f2068121532143cab380eed5f75fa72f29bc03ea8a7ad5e47188ca080b00d\"], [ \"351804e6610ac9841f887f36042f104150acb8d8d4fb41c7c99a6bf71d5ce60f\", \"0a5dff5780c754c1b0be7972b9b627efb73fc555d30da21939d368cf2ecff800\"], [ \"982f3a0d9c2b03e55860800431a68eb8565e07796c361d69407863520c277b05\", \"8ecd785cec646b3c2d778ae7e0ad0ec79d1e0ee1b53566865aafe747bb678807\"], [ \"c8185d605934758224398b8d916645f9079f5fa29b59f0f7d9c925e5adfa5007\", \"fe710e4d9d1e7044b99955985dcca690dd58e3afe8077182c60d7f0712997b01\"], [ \"3a4f91cd808bb6eeeacb83451caa750c5638b990e17e6f92af327f2947d6910c\", \"cad8282afd5fbc5fe7a443dd532d0d5157f28bf9ee3a965d60ebd9b52eb9820c\"], [ \"75b9b5a096da69131ee15ae9fbcb55b875ecfbf3eafac3930105b794690ded0f\", \"b76a1a7da2f09a9b2afeb335ae89a676609c265a02605b673967addff91be004\"], [ \"83b8b22e578ccdf58280bde6f123362d8d1a70b4643fc8d451756a833d364c0a\", \"447c11a71c6a1c3ff393a838741055c6612871963415101a597837aea09c4401\"], [ \"e3dd75277cebd81367a25c8c9f7eef57256a8b865487acf39026cb99e054a800\", \"711382595df75968bfd7b58dea401ec901a597aa351694980ca8a784a94d300e\"]], \n \"cc\": \"26d42d1aa8ef925700aca0258bf5405b59de583f97f6d00dfffec14c695a0606\"\n }], \n \"pseudoOuts\": [ \"e838eae93ee2d370efe20fafc633b5200a6d08609bd5af9b7eafcbb6061d6297\"]\n }\n}",
|
||||
"weight": 1763
|
||||
}
|
||||
],
|
||||
"untrusted": false
|
||||
}
|
39
tests/test_jsonrpcdaemon.py
Normal file
39
tests/test_jsonrpcdaemon.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from binascii import hexlify
|
||||
import responses
|
||||
|
||||
from monero.daemon import Daemon
|
||||
from monero.backends.jsonrpc import JSONRPCDaemon
|
||||
from monero.transaction import Transaction
|
||||
|
||||
from .base import JSONTestCase
|
||||
|
||||
class JSONRPCDaemonTestCase(JSONTestCase):
|
||||
jsonrpc_url = 'http://127.0.0.1:18081/json_rpc'
|
||||
mempool_url = 'http://127.0.0.1:18081/get_transaction_pool'
|
||||
data_subdir = 'test_jsonrpcdaemon'
|
||||
|
||||
def setUp(self):
|
||||
self.daemon = Daemon(JSONRPCDaemon())
|
||||
|
||||
@responses.activate
|
||||
def test_basic_info(self):
|
||||
responses.add(responses.POST, self.jsonrpc_url,
|
||||
json=self._read('test_basic_info-get_info.json'),
|
||||
status=200)
|
||||
responses.add(responses.POST, self.jsonrpc_url,
|
||||
json=self._read('test_basic_info-get_info.json'),
|
||||
status=200)
|
||||
self.assertTrue(self.daemon.info())
|
||||
self.assertEqual(self.daemon.height(), 294993)
|
||||
|
||||
@responses.activate
|
||||
def test_mempool(self):
|
||||
responses.add(responses.POST, self.mempool_url,
|
||||
json=self._read('test_mempool-transactions.json'),
|
||||
status=200)
|
||||
txs = self.daemon.mempool()
|
||||
self.assertEqual(len(txs), 2)
|
||||
self.assertEqual(txs[0].confirmations, 0)
|
||||
self.assertEqual(txs[1].confirmations, 0)
|
||||
self.assertGreater(txs[0].fee, 0)
|
||||
self.assertGreater(txs[1].fee, 0)
|
|
@ -1,14 +1,43 @@
|
|||
from monero.backends.offline import OfflineWallet
|
||||
from monero.backends.offline import OfflineWallet, WalletIsOffline
|
||||
from monero.wallet import Wallet
|
||||
import unittest
|
||||
from .base import JSONTestCase
|
||||
from .utils import classproperty
|
||||
|
||||
|
||||
class OfflineTest(unittest.TestCase):
|
||||
addr = '47ewoP19TN7JEEnFKUJHAYhGxkeTRH82sf36giEp9AcNfDBfkAtRLX7A6rZz18bbNHPNV7ex6WYbMN3aKisFRJZ8Ebsmgef'
|
||||
svk = '6d9056aa2c096bfcd2f272759555e5764ba204dd362604a983fa3e0aafd35901'
|
||||
|
||||
def setUp(self):
|
||||
self.wallet = Wallet(OfflineWallet(self.addr, view_key=self.svk))
|
||||
|
||||
def test_offline_exception(self):
|
||||
self.assertRaises(WalletIsOffline, self.wallet.height)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.new_account)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.new_address)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.export_outputs)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.import_outputs, '')
|
||||
self.assertRaises(WalletIsOffline, self.wallet.export_key_images)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.import_key_images, '')
|
||||
self.assertRaises(WalletIsOffline, self.wallet.balances)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.balance)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.incoming)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.outgoing)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.transfer, self.wallet.get_address(1,0), 1)
|
||||
self.assertRaises(WalletIsOffline, self.wallet.transfer_multiple,
|
||||
[(self.wallet.get_address(1,0), 1), (self.wallet.get_address(1,1), 2)])
|
||||
|
||||
|
||||
class SubaddrTest(object):
|
||||
data_subdir = 'test_offline'
|
||||
|
||||
def setUp(self):
|
||||
self.wallet = Wallet(OfflineWallet(self.addr, view_key=self.svk))
|
||||
self.wallet = Wallet(OfflineWallet(self.addr, view_key=self.svk, spend_key=self.ssk))
|
||||
|
||||
def test_keys(self):
|
||||
self.assertEqual(self.wallet.spend_key(), self.ssk)
|
||||
self.assertEqual(self.wallet.view_key(), self.svk)
|
||||
self.assertEqual(25, len(self.wallet.seed().phrase.split(' ')))
|
||||
|
||||
def test_subaddresses(self):
|
||||
major = 0
|
||||
|
|
Loading…
Reference in a new issue