Tests Cases for JSON RPC Methods and Minor Tweaks

Changes:
    1. Added test cases for the JSON_RPC methods (not the old RPC methods)
    2. Tweaked a couple of the methods to make input and output more intuitive
pull/90/head
Jeffrey Ryan 3 years ago
parent ac43a16292
commit 27b3c4b54c

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import binascii
from datetime import datetime
from decimal import Decimal
import ipaddress
import json
import logging
import requests
@ -587,13 +588,13 @@ class JSONRPCDaemon(object):
return self.raw_jsonrpc_request('hard_fork_info')
def set_bans(self, ip, ban, seconds):
def set_bans(self, ip, ban, seconds=None):
"""
Ban (or unban) other nodes by IP for a certain length of time.
:param ip: ip address of node to ban in two forms: 'a.b.c.d' str or 32-bit unsigned integer
:param bool ban: Whether to ban (True) or unban (False)
:param int seconds: Number of seconds to ban
:param int seconds: Number of seconds to ban. Optional if "ban" is False
Notes:
* Params "ip", "ban", and "seconds" can be single elements or they can be iterables of the same length. For example:
@ -611,21 +612,6 @@ class JSONRPCDaemon(object):
}
"""
def is_valid_ip(ip):
if isinstance(ip, (int)):
return 0 <= ip < 2 ** 32
else:
if len(ip.split('.')) != 4:
return False
for ip_part in ip.split('.'):
try:
ip_part_num = int(ip_part)
if ip_part_num < 0 or ip_part_num >= 256:
return False
except:
return False
return True
if isinstance(ip, (str, int)): # If single element paramters
user_bans = [{
'ip': ip,
@ -649,9 +635,10 @@ class JSONRPCDaemon(object):
curr_ban = bool(ban_entry['ban'])
curr_seconds = ban_entry['seconds']
if not is_valid_ip(curr_ip):
raise ValueError('"{}" is not a valid IP address'.format(ip))
elif curr_ban and curr_seconds is None:
# validate IP
ipaddress.IPv4Address(curr_ip)
if curr_ban and curr_seconds is None:
raise ValueError('Whenever "ban" is True, "seconds" must not be None')
elif curr_seconds is not None and curr_seconds < 0:
raise ValueError('"seconds" can not be less than zero')
@ -708,7 +695,12 @@ class JSONRPCDaemon(object):
txids = self._validate_hashlist(txids)
return self.raw_jsonrpc_request('flush_txpool', params={'txids': txids})
resp = self.raw_jsonrpc_request('flush_txpool', params={'txids': txids})
if 'transactions' not in resp:
resp['transactions'] = []
return resp
def get_output_histogram(self, amounts, min_count=None, max_count=None, unlocked=None, recent_cutoff=None):
"""
@ -716,10 +708,10 @@ class JSONRPCDaemon(object):
of outputs on the chain for that amount. RingCT outputs counts as 0 amount.
:param list amounts: list of unsigned ints in atomic units, or Decimals as full monero amounts
:min_count: unsigned int lower bound for output number
:min_count: unsigned int upper bound for output number
:unlocked: boolean for whether to count only unlocked
:recent_cutoff: unsigned int
:param int min_count: lower bound for output number
:param int max_count: upper bound for output number
:param bool unlocked: whether to count only unlocked
:pramrm int recent_cutoff: unsigned int
Output:
@ -735,12 +727,12 @@ class JSONRPCDaemon(object):
"untrusted": bool; True for bootstrap mode, False for full sync mode.
}
"""
# Coerce amounts paramter
if isinstance(amounts, (int, Decimal)):
amounts = [to_atomic(amounts) if isinstance(amounts, Decimal) else amounts]
elif not amounts:
raise ValueError('amounts must have at least one element')
amounts = list(map(lambda a: to_atomic(a) if isinstance(a, Decimal) else int(a), amounts))
elif amounts is None:
raise ValueError('amounts is None')
# Construct RPC parameters
params = {'amounts': amounts}
@ -805,7 +797,12 @@ class JSONRPCDaemon(object):
}
"""
params = None if not grace_blocks else {'grace_blocks': grace_blocks}
if not isinstance(grace_blocks, (int, type(None))):
raise TypeError("grace_blocks is not an int")
elif grace_blocks is not None and grace_blocks < 0:
raise ValueError("grace_blocks < 0")
params = {'grace_blocks': grace_blocks} if grace_blocks else None
return self.raw_jsonrpc_request('get_fee_estimate', params=params)
def get_alternate_chains(self):
@ -826,6 +823,7 @@ class JSONRPCDaemon(object):
}
"""
return self.raw_jsonrpc_request('get_alternate_chains')
def relay_tx(self, txids):
@ -919,7 +917,6 @@ class JSONRPCDaemon(object):
amounts = [to_atomic(amounts) if isinstance(amounts, Decimal) else amounts]
elif not amounts:
raise ValueError('amounts must have at least one element')
amounts = list(map(lambda a: to_atomic(a) if isinstance(a, Decimal) else int(a), amounts))
return self.raw_jsonrpc_request('get_output_distribution', params={
'amounts': amounts,
@ -1507,7 +1504,7 @@ class JSONRPCDaemon(object):
def _is_valid_256_hex(self, hexhash):
try:
bytes.fromhex(hexhash)
bytearray.fromhex(hexhash)
return len(hexhash) == 64
except ValueError:

@ -1,3 +1,4 @@
pysha3
requests
six>=1.12.0
ipaddress

@ -0,0 +1,8 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"status": "OK",
"untrusted": false
}
}

@ -0,0 +1,13 @@
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"chains": [{
"block_hash": "697cf03c89a9b118f7bdf11b1b3a6a028d7b3617d2d0ed91322c5709acf75625",
"difficulty": 14114729638300280,
"height": 1562062,
"length": 2
}],
"status": "OK"
}
}

@ -0,0 +1,35 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"bans": [
{
"host": "145.239.118.5",
"ip": 91680657,
"seconds": 72260
},
{
"host": "146.59.156.116",
"ip": 1956395922,
"seconds": 69397
},
{
"host": "213.32.121.162",
"ip": 2725847253,
"seconds": 3564
},
{
"host": "51.83.81.237",
"ip": 3981529907,
"seconds": 70687
},
{
"host": "54.39.75.54",
"ip": 910894902,
"seconds": 80571
}
],
"status": "OK",
"untrusted": false
}
}

@ -0,0 +1,56 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"blob": "0e0efef0e880066d78ace422007a2cefb423553b39f8b58f6067698eac8162b25732d0b99988d37dc2002302bfd78b0101ff83d78b0101d58aa8aaa02202e90b5189598861b8dc3250b05847efd4ddb31d33b667037ae75572f4fef176c43401d3edb9548f1f68cb3de38f597e087e7514e8533ad2911480c4afffde217cb0dc02110000041b31710e950000000000000000000011b6b1fe267ec2a0f4c6937ebbe2e94969341d293293f148b2fe4e6f1c618b57a86c769da02b54ecac61d85f19b359401dd5595eebaaf488875e8165542e9eef522072a2929728e4e316744588f108b258c449072c19656b57ce1b9ba1a34e534d95619c252275642a394396ece0e218f6f4003e58bf307a02e03f09a59d53e5637dbb101aa4d3c6c58b484f7e580d89b52d70b0a9e67471e64ada3930bdae66c8bb4531547be88cd8601f8490688b5461889c4ca78977000844e015aac51698cf922df5547d43de3e260cb9a87342498fffa89f3cc31564b6a41cef61320b85695d454ac941ac2f7ca00e673a019066e7874b9d1f9055f0d6c7b6c47bc3efc52de13150199cb907b06d0c5fe009b64258662e29bdcc58f53d88be4cb044a50352f9c8c3549e9df079cd0b75f87937152ec5bdb9c8b68695ec80a129f9770ad80b05dbd5c025270fc38366f06d037a43ee0db46892ac471a61328d9733d197c6c1ecfdf344bac1a2795a179e10d15cffe66701c3f53d9410b2f63998a1fbab3332c471f2f16e24ab9475d0cd656aa49a0bce7fb38f82795ce6935b4602b03f0d0cddba5bd9abcb5ae50698e5f735e31ae2c10a673b763434594beea09a5990c02f3e82c4eafb438223df4022cd146bfcadd8e3c1da70b8113c626a7bc4d8780ca6009a0f3043c1eccf3519e26137a618a446844105f0e3a87f60104a4c2244212aed1c72b4f4b442d4f4b562c153b438711ae9069aa2bdf3426a4209ba91db2dec",
"block_header": {
"block_size": 33101,
"block_weight": 33101,
"cumulative_difficulty": 86655943855900269,
"cumulative_difficulty_top64": 0,
"depth": 13,
"difficulty": 239419211907,
"difficulty_top64": 0,
"hash": "1c68300646dda11a89cc9ca4001100745fcbd192e0e6efb6b06bd4d25851662b",
"height": 2288515,
"long_term_weight": 33101,
"major_version": 14,
"miner_tx_hash": "e31c38097769b1c49d31e7b041823da00915cdba77b9794d63ccb3d6571f2565",
"minor_version": 14,
"nonce": 587252349,
"num_txes": 17,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "6d78ace422007a2cefb423553b39f8b58f6067698eac8162b25732d0b99988d3",
"reward": 1176909776213,
"timestamp": 1612331134,
"wide_cumulative_difficulty": "0x133dd1f2f35066d",
"wide_difficulty": "0x37be7f4083"
},
"credits": 0,
"json": "{\n \"major_version\": 14, \n \"minor_version\": 14, \n \"timestamp\": 1612331134, \n \"prev_id\": \"6d78ace422007a2cefb423553b39f8b58f6067698eac8162b25732d0b99988d3\", \n \"nonce\": 587252349, \n \"miner_tx\": {\n \"version\": 2, \n \"unlock_time\": 2288575, \n \"vin\": [ {\n \"gen\": {\n \"height\": 2288515\n }\n }\n ], \n \"vout\": [ {\n \"amount\": 1176909776213, \n \"target\": {\n \"key\": \"e90b5189598861b8dc3250b05847efd4ddb31d33b667037ae75572f4fef176c4\"\n }\n }\n ], \n \"extra\": [ 1, 211, 237, 185, 84, 143, 31, 104, 203, 61, 227, 143, 89, 126, 8, 126, 117, 20, 232, 83, 58, 210, 145, 20, 128, 196, 175, 255, 222, 33, 124, 176, 220, 2, 17, 0, 0, 4, 27, 49, 113, 14, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0\n ], \n \"rct_signatures\": {\n \"type\": 0\n }\n }, \n \"tx_hashes\": [ \"b6b1fe267ec2a0f4c6937ebbe2e94969341d293293f148b2fe4e6f1c618b57a8\", \"6c769da02b54ecac61d85f19b359401dd5595eebaaf488875e8165542e9eef52\", \"2072a2929728e4e316744588f108b258c449072c19656b57ce1b9ba1a34e534d\", \"95619c252275642a394396ece0e218f6f4003e58bf307a02e03f09a59d53e563\", \"7dbb101aa4d3c6c58b484f7e580d89b52d70b0a9e67471e64ada3930bdae66c8\", \"bb4531547be88cd8601f8490688b5461889c4ca78977000844e015aac51698cf\", \"922df5547d43de3e260cb9a87342498fffa89f3cc31564b6a41cef61320b8569\", \"5d454ac941ac2f7ca00e673a019066e7874b9d1f9055f0d6c7b6c47bc3efc52d\", \"e13150199cb907b06d0c5fe009b64258662e29bdcc58f53d88be4cb044a50352\", \"f9c8c3549e9df079cd0b75f87937152ec5bdb9c8b68695ec80a129f9770ad80b\", \"05dbd5c025270fc38366f06d037a43ee0db46892ac471a61328d9733d197c6c1\", \"ecfdf344bac1a2795a179e10d15cffe66701c3f53d9410b2f63998a1fbab3332\", \"c471f2f16e24ab9475d0cd656aa49a0bce7fb38f82795ce6935b4602b03f0d0c\", \"ddba5bd9abcb5ae50698e5f735e31ae2c10a673b763434594beea09a5990c02f\", \"3e82c4eafb438223df4022cd146bfcadd8e3c1da70b8113c626a7bc4d8780ca6\", \"009a0f3043c1eccf3519e26137a618a446844105f0e3a87f60104a4c2244212a\", \"ed1c72b4f4b442d4f4b562c153b438711ae9069aa2bdf3426a4209ba91db2dec\"\n ]\n}",
"miner_tx_hash": "e31c38097769b1c49d31e7b041823da00915cdba77b9794d63ccb3d6571f2565",
"status": "OK",
"top_hash": "",
"tx_hashes": [
"b6b1fe267ec2a0f4c6937ebbe2e94969341d293293f148b2fe4e6f1c618b57a8",
"6c769da02b54ecac61d85f19b359401dd5595eebaaf488875e8165542e9eef52",
"2072a2929728e4e316744588f108b258c449072c19656b57ce1b9ba1a34e534d",
"95619c252275642a394396ece0e218f6f4003e58bf307a02e03f09a59d53e563",
"7dbb101aa4d3c6c58b484f7e580d89b52d70b0a9e67471e64ada3930bdae66c8",
"bb4531547be88cd8601f8490688b5461889c4ca78977000844e015aac51698cf",
"922df5547d43de3e260cb9a87342498fffa89f3cc31564b6a41cef61320b8569",
"5d454ac941ac2f7ca00e673a019066e7874b9d1f9055f0d6c7b6c47bc3efc52d",
"e13150199cb907b06d0c5fe009b64258662e29bdcc58f53d88be4cb044a50352",
"f9c8c3549e9df079cd0b75f87937152ec5bdb9c8b68695ec80a129f9770ad80b",
"05dbd5c025270fc38366f06d037a43ee0db46892ac471a61328d9733d197c6c1",
"ecfdf344bac1a2795a179e10d15cffe66701c3f53d9410b2f63998a1fbab3332",
"c471f2f16e24ab9475d0cd656aa49a0bce7fb38f82795ce6935b4602b03f0d0c",
"ddba5bd9abcb5ae50698e5f735e31ae2c10a673b763434594beea09a5990c02f",
"3e82c4eafb438223df4022cd146bfcadd8e3c1da70b8113c626a7bc4d8780ca6",
"009a0f3043c1eccf3519e26137a618a446844105f0e3a87f60104a4c2244212a",
"ed1c72b4f4b442d4f4b562c153b438711ae9069aa2bdf3426a4209ba91db2dec"
],
"untrusted": false
}
}

@ -0,0 +1,9 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"count": 2287024,
"status": "OK",
"untrusted": false
}
}

@ -0,0 +1,34 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 17130,
"block_weight": 17130,
"cumulative_difficulty": 86641187797059581,
"cumulative_difficulty_top64": 0,
"depth": 4,
"difficulty": 239025076303,
"difficulty_top64": 0,
"hash": "90f6fd3fe29c7518f15afd2da31734e890cc24247b5da10dc9ac2ea215ae844b",
"height": 2288453,
"long_term_weight": 17130,
"major_version": 14,
"miner_tx_hash": "5e8d9531ae078ef5630e3c9950eb768b87b31481652c2b8dafca25d57e9c0c3f",
"minor_version": 14,
"nonce": 1040830456,
"num_txes": 11,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "a78d9e631f743806b0b8d3a70bb85758db466633eb3b4620737dd29b0548eb21",
"reward": 1176972120146,
"timestamp": 1612323209,
"wide_cumulative_difficulty": "0x133cfb3858fc7fd",
"wide_difficulty": "0x37a701384f"
},
"credits": 0,
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,34 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 8415,
"block_weight": 8415,
"cumulative_difficulty": 86651164421641270,
"cumulative_difficulty_top64": 0,
"depth": 3,
"difficulty": 238154836806,
"difficulty_top64": 0,
"hash": "966c1a70358ce998e7d5fb243b155971f9bffe06030c92dbd70486d398c40c05",
"height": 2288495,
"long_term_weight": 8415,
"major_version": 14,
"miner_tx_hash": "408dd52531cab37e51db5a9a581bf25691b5534d8d0037b38e68061691b976e1",
"minor_version": 14,
"nonce": 1275098057,
"num_txes": 5,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "47751e6eb31230e92a5ee98242aa34d79bfd48657f2727c9a9b3cbad6aee88bb",
"reward": 1176760892780,
"timestamp": 1612328193,
"wide_cumulative_difficulty": "0x133d8c662b9d436",
"wide_difficulty": "0x3773226b46"
},
"credits": 0,
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,252 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"headers": [
{
"block_size": 49559,
"block_weight": 49559,
"cumulative_difficulty": 86650214633914049,
"cumulative_difficulty_top64": 0,
"depth": 19,
"difficulty": 236253710852,
"difficulty_top64": 0,
"hash": "01a5a129515e752055af9883ac98cdbd9eb90db16ab69ea187a1eb24eb7d0c66",
"height": 2288491,
"long_term_weight": 49559,
"major_version": 14,
"miner_tx_hash": "22c3dd706931fe0606e086147dcb8a984b504a5bd0eabd1cf7dabb9456154cd4",
"minor_version": 14,
"nonce": 922780730,
"num_txes": 26,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "6bd071b487be697128142b9b132be8d2c3e4ee9660f73d811c3d23e4526e56ac",
"reward": 1178084560299,
"timestamp": 1612327847,
"wide_cumulative_difficulty": "0x133d7e93ef73ec1",
"wide_difficulty": "0x3701d18a04"
},
{
"block_size": 48848,
"block_weight": 48848,
"cumulative_difficulty": 86650451549481310,
"cumulative_difficulty_top64": 0,
"depth": 18,
"difficulty": 236915567261,
"difficulty_top64": 0,
"hash": "b2b91f81acec7fac2918cdee624f98df32c6b161160b4728ade336526a4ff51a",
"height": 2288492,
"long_term_weight": 48848,
"major_version": 14,
"miner_tx_hash": "9f74f1ff0e6cda328c07449fd1329d23a711cb1a65abc518d186ff152bb02dd9",
"minor_version": 14,
"nonce": 69257,
"num_txes": 21,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "01a5a129515e752055af9883ac98cdbd9eb90db16ab69ea187a1eb24eb7d0c66",
"reward": 1178167575913,
"timestamp": 1612328034,
"wide_cumulative_difficulty": "0x133d820683be95e",
"wide_difficulty": "0x372944aa9d"
},
{
"block_size": 6013,
"block_weight": 6013,
"cumulative_difficulty": 86650688345313996,
"cumulative_difficulty_top64": 0,
"depth": 17,
"difficulty": 236795832686,
"difficulty_top64": 0,
"hash": "c85bfe6255447d117d68f90aa0cd2719542e92ee3bffed43b6109efbd87456cf",
"height": 2288493,
"long_term_weight": 6013,
"major_version": 14,
"miner_tx_hash": "7b7fb7509f54139b96434c351d855377a18d44304143cc7ed2eb93a940dd06ee",
"minor_version": 14,
"nonce": 2164859383,
"num_txes": 3,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "b2b91f81acec7fac2918cdee624f98df32c6b161160b4728ade336526a4ff51a",
"reward": 1176808541531,
"timestamp": 1612328052,
"wide_cumulative_difficulty": "0x133d8578a5d92cc",
"wide_difficulty": "0x372221a96e"
},
{
"block_size": 25305,
"block_weight": 25305,
"cumulative_difficulty": 86650926266804464,
"cumulative_difficulty_top64": 0,
"depth": 16,
"difficulty": 237921490468,
"difficulty_top64": 0,
"hash": "47751e6eb31230e92a5ee98242aa34d79bfd48657f2727c9a9b3cbad6aee88bb",
"height": 2288494,
"long_term_weight": 25305,
"major_version": 14,
"miner_tx_hash": "c3146d227b3ec5288ee97fe48d7ab75dd172d038851e70f66ee3c2e2bd2299ba",
"minor_version": 14,
"nonce": 493060,
"num_txes": 12,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "c85bfe6255447d117d68f90aa0cd2719542e92ee3bffed43b6109efbd87456cf",
"reward": 1177608932154,
"timestamp": 1612328162,
"wide_cumulative_difficulty": "0x133d88eef9768f0",
"wide_difficulty": "0x376539d624"
},
{
"block_size": 8415,
"block_weight": 8415,
"cumulative_difficulty": 86651164421641270,
"cumulative_difficulty_top64": 0,
"depth": 15,
"difficulty": 238154836806,
"difficulty_top64": 0,
"hash": "966c1a70358ce998e7d5fb243b155971f9bffe06030c92dbd70486d398c40c05",
"height": 2288495,
"long_term_weight": 8415,
"major_version": 14,
"miner_tx_hash": "408dd52531cab37e51db5a9a581bf25691b5534d8d0037b38e68061691b976e1",
"minor_version": 14,
"nonce": 1275098057,
"num_txes": 5,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "47751e6eb31230e92a5ee98242aa34d79bfd48657f2727c9a9b3cbad6aee88bb",
"reward": 1176760892780,
"timestamp": 1612328193,
"wide_cumulative_difficulty": "0x133d8c662b9d436",
"wide_difficulty": "0x3773226b46"
},
{
"block_size": 116231,
"block_weight": 116231,
"cumulative_difficulty": 86651402586533952,
"cumulative_difficulty_top64": 0,
"depth": 14,
"difficulty": 238164892682,
"difficulty_top64": 0,
"hash": "b13413f9072dc7d64bfb7fd41468de816896bb003cd1f2b83650f50c3b7cb181",
"height": 2288496,
"long_term_weight": 116231,
"major_version": 14,
"miner_tx_hash": "086f9403f409146cfe3f42ad92656215c3528c6467bf2249969cbd8c8959e566",
"minor_version": 14,
"nonce": 248137,
"num_txes": 47,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "966c1a70358ce998e7d5fb243b155971f9bffe06030c92dbd70486d398c40c05",
"reward": 1179976778411,
"timestamp": 1612328551,
"wide_cumulative_difficulty": "0x133d8fdd675b040",
"wide_difficulty": "0x3773bbdc0a"
},
{
"block_size": 16270,
"block_weight": 16270,
"cumulative_difficulty": 86651640852406342,
"cumulative_difficulty_top64": 0,
"depth": 13,
"difficulty": 238265872390,
"difficulty_top64": 0,
"hash": "2abd2e1f66237274e2c81ae9b399c35fb276256a2f74bb7417f46b1df9bef05c",
"height": 2288497,
"long_term_weight": 16270,
"major_version": 14,
"miner_tx_hash": "00f859466dc3d2a640139f11fa651ceb6505def6087b0b70481abc6bdaff46bb",
"minor_version": 14,
"nonce": 72020,
"num_txes": 9,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "b13413f9072dc7d64bfb7fd41468de816896bb003cd1f2b83650f50c3b7cb181",
"reward": 1177235044047,
"timestamp": 1612328631,
"wide_cumulative_difficulty": "0x133d93550366046",
"wide_difficulty": "0x3779c0b006"
},
{
"block_size": 114710,
"block_weight": 114710,
"cumulative_difficulty": 86651878958176077,
"cumulative_difficulty_top64": 0,
"depth": 12,
"difficulty": 238105769735,
"difficulty_top64": 0,
"hash": "85b650768a99d15b10dd2b3e3b0a2783fd4f328a09051234eeb502df53a466ef",
"height": 2288498,
"long_term_weight": 114710,
"major_version": 14,
"miner_tx_hash": "2ae0f790f203ef5f68a705cb9328b20bf281b0a28b4f87ce1cdf4c1d14632db8",
"minor_version": 14,
"nonce": 3255005723,
"num_txes": 50,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "2abd2e1f66237274e2c81ae9b399c35fb276256a2f74bb7417f46b1df9bef05c",
"reward": 1205727544686,
"timestamp": 1612329017,
"wide_cumulative_difficulty": "0x133d96cc06c174d",
"wide_difficulty": "0x377035b707"
},
{
"block_size": 18142,
"block_weight": 18142,
"cumulative_difficulty": 86652117438434601,
"cumulative_difficulty_top64": 0,
"depth": 11,
"difficulty": 238480258524,
"difficulty_top64": 0,
"hash": "d7a49b741aaedb95fbcc4c8d2033268a411f8de535d4abb7099b16d442dcfee6",
"height": 2288499,
"long_term_weight": 18142,
"major_version": 14,
"miner_tx_hash": "d0a4fe27cc361006a3a8677677d5f0cda200d57d263e2169f79cd1d3d7f96cfc",
"minor_version": 14,
"nonce": 4043900084,
"num_txes": 11,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "85b650768a99d15b10dd2b3e3b0a2783fd4f328a09051234eeb502df53a466ef",
"reward": 1198576000330,
"timestamp": 1612329127,
"wide_cumulative_difficulty": "0x133d9a446f40d29",
"wide_difficulty": "0x378687f5dc"
},
{
"block_size": 64084,
"block_weight": 64084,
"cumulative_difficulty": 86652355952824805,
"cumulative_difficulty_top64": 0,
"depth": 10,
"difficulty": 238514390204,
"difficulty_top64": 0,
"hash": "3fd48fc38c69e63e274a7340f3cb1de82ffde0abfe85fc417789a06e16528d5d",
"height": 2288500,
"long_term_weight": 64084,
"major_version": 14,
"miner_tx_hash": "56d8ab6a4e7826d63020adf3e3d6ebe3364da645a3be016ef912d9b2401b0866",
"minor_version": 14,
"nonce": 134273718,
"num_txes": 32,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "d7a49b741aaedb95fbcc4c8d2033268a411f8de535d4abb7099b16d442dcfee6",
"reward": 1188932565978,
"timestamp": 1612329382,
"wide_cumulative_difficulty": "0x133d9dbcf84d1e5",
"wide_difficulty": "0x378890c4bc"
}
],
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,20 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"blockhashing_blob": "0e0ec890de8006fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd270000000067ec6d160094c242a6e4aee48103c5c80f100e8a7055ed5ff7964216f8fc47561c",
"blocktemplate_blob": "0e0ec890de8006fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd270000000002fecb8b0101ffc2cb8b0101d5fea9bbae220232e3df54fbf87eb29983853b3a4c6e3505949b011459334647ef459d304f6b53630102aeb562f6095dddf3ddd07d7703e047c274639bdaab3df83ac366d471db1d14024000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b313357d05b6bede5aa4797627a17e728f6577438bbd616f763efc06f6f09535a2c0ea18d5cda3019cef79db816e4a7e1b18d49385b44a77fb8e6b4d22762190b6c54d1d099d7d4179601a792f38c0aa14df8e40685215a53f92b9a4b54d2a2c8b69e0ded589859e3f1e310e99a754612c331052aec895950948eadf2a4e98d597f252fba93b2bd7c77b4e2a826a8e0fd6f11e96bfc16e0c7e390affc4a22032064099c83439afcd9f3805deb15407582dccdb2ffd62af8f0ed55a1fa6c4fff4e8e492e36cad4bf5481b57e37137df5c097a26f28c16b9e563d7291feebd9775e207e205f533853fdeacc33da212567dff2ebcb235cb046c0ccc39c59ba6a98b97732ce2a27332a397344a7a40b452d23c999a06497731a3289a7470281f8725e7f3d14f62b05156db38d190c1391e3c3e17e277375c4ce4f5a8bed6d4f0bd472021de649597df2eabf40badaeee8e66e56fdf9d345b4731fed35f8ba601c1373a4dbba49ee4fec380fe3616ca53341f8c9f2aa89e6715ff774bc8e24af78d851a5a88deed42f90de59115db74841b6e90cf6bfb1671cd7ff843b4918c0601dea4dc63d9beca34d6e76c4544c98a9e6c68c3b9cd0a43b371832b4a086755c81d5b415f618f4d69209b99472b4e14d07b05299bf2700de70d7680be47a97922adeda28495ac40d74a0f01d282d85832ccbfb880d6a3031ab13326f784c0ddcc625bfcfba2f95a71450c1c66ed558ecdf131ccf98085831e3e48c4b92f60b4ca7040b977717abe4a3ef1b030fd7c51e9182ec6829f104e5ee8e9f5ec3049634524162798328af418467129946357b26debaefa4b4b29676c199a7b120cb97f91b186c5d9d5c1c68b0ac6c188ded8993f893a9feee37afc5a8113c1de57a07a5df1046e9065b3e0a0f894e18b00d73ea5850998feadf31dc3278bf438350aba7b43f06311b60dfe9948d58012598626fbdb4058764198f6d4e44a4599b62cf826e6ec530f056f44b1cc6f5886472f68a70c2af78d2e2651d427fb292daa3bcbe18c255ebc7e7f82e97d948ced5998c661555bcf72225a8e97dbea7ec85f09f2200034119572300475d4ec4a0ede8ea7a8f6a7362865c34b797967592a3562df6e745bc63c240589509757e217ac7c42e93614dc99bd0462a7cabb9deda505f5ce83c96f0a14cd80e0dd485a1d6671ee0845fa0bc56b3e294975d878f05733505564b",
"difficulty": 232871166515,
"difficulty_top64": 0,
"expected_reward": 1180703555413,
"height": 2287042,
"next_seed_hash": "",
"prev_hash": "fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd27",
"reserved_offset": 130,
"seed_hash": "d432f499205150873b2572b5f033c9c6e4b7c6f3394bd2dd93822cd7085e7307",
"seed_height": 2285568,
"status": "OK",
"untrusted": false,
"wide_difficulty": "0x3638340233"
}
}

@ -0,0 +1,16 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"emission_amount": 139291580971286,
"emission_amount_top64": 0,
"fee_amount": 505668215000,
"fee_amount_top64": 0,
"status": "OK",
"top_hash": "",
"untrusted": false,
"wide_emission_amount": "0x7eaf59343916",
"wide_fee_amount": "0x75bc2ca0d8"
}
}

@ -0,0 +1,334 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"connections": [
{
"address": "193.70.78.196:12497",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "0f359103657e4a7bb8fb8c2a70139224",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "193.70.78.196",
"incoming": false,
"ip": "193.70.78.196",
"live_time": 145,
"local_ip": false,
"localhost": false,
"peer_id": "aa41b836feea9fb7",
"port": "12497",
"pruning_seed": 0,
"recv_count": 66396,
"recv_idle_time": 2,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 111307,
"send_idle_time": 2,
"state": "synchronizing",
"support_flags": 1
},
{
"address": "52.60.218.210:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "9c52aa37e83c4c16a18d410aef473a8d",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "52.60.218.210",
"incoming": false,
"ip": "52.60.218.210",
"live_time": 257,
"local_ip": false,
"localhost": false,
"peer_id": "08135737091b21ce",
"port": "18080",
"pruning_seed": 0,
"recv_count": 138613,
"recv_idle_time": 4,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 110233,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "24.101.115.189:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "6f77a8afc5144a2ea4a0634d7a9fcaf7",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "24.101.115.189",
"incoming": false,
"ip": "24.101.115.189",
"live_time": 351,
"local_ip": false,
"localhost": false,
"peer_id": "845cfad73a20ea83",
"port": "18080",
"pruning_seed": 390,
"recv_count": 188693,
"recv_idle_time": 8,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 178782,
"send_idle_time": 7,
"state": "normal",
"support_flags": 1
},
{
"address": "97.91.211.35:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 30,
"connection_id": "76085153221a4ea2a39ad92125842aa0",
"current_download": 0,
"current_upload": 44,
"height": 2265888,
"host": "97.91.211.35",
"incoming": false,
"ip": "97.91.211.35",
"live_time": 505,
"local_ip": false,
"localhost": false,
"peer_id": "6fb43c7e734dd1d7",
"port": "18080",
"pruning_seed": 0,
"recv_count": 55316,
"recv_idle_time": 6,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 15975280,
"send_idle_time": 4,
"state": "normal",
"support_flags": 1
},
{
"address": "54.180.125.82:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "982f50cefae94991b4dd2857cc1ad9fd",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "54.180.125.82",
"incoming": false,
"ip": "54.180.125.82",
"live_time": 457,
"local_ip": false,
"localhost": false,
"peer_id": "84050758addac752",
"port": "18080",
"pruning_seed": 0,
"recv_count": 327996,
"recv_idle_time": 3,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 218244,
"send_idle_time": 6,
"state": "normal",
"support_flags": 1
},
{
"address": "158.69.245.223:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "e0bebcf53db74a5a884ba403450a3b49",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "158.69.245.223",
"incoming": false,
"ip": "158.69.245.223",
"live_time": 548,
"local_ip": false,
"localhost": false,
"peer_id": "a45f3600853895a7",
"port": "18080",
"pruning_seed": 0,
"recv_count": 288659,
"recv_idle_time": 7,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 270778,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "47.100.185.97:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "6ca6e860bbc94d5a81a758ef37dffd0b",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "47.100.185.97",
"incoming": false,
"ip": "47.100.185.97",
"live_time": 596,
"local_ip": false,
"localhost": false,
"peer_id": "67aa8c69d30b6a61",
"port": "18080",
"pruning_seed": 0,
"recv_count": 314165,
"recv_idle_time": 5,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 287678,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "94.2.65.190:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "148d6af9c1c246b58947511c9530023a",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "94.2.65.190",
"incoming": false,
"ip": "94.2.65.190",
"live_time": 598,
"local_ip": false,
"localhost": false,
"peer_id": "8dfddb88ee5e7c67",
"port": "18080",
"pruning_seed": 0,
"recv_count": 312873,
"recv_idle_time": 2,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 288696,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "80.241.217.144:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "da26125daf9345919e497adf204bb640",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "80.241.217.144",
"incoming": false,
"ip": "80.241.217.144",
"live_time": 565,
"local_ip": false,
"localhost": false,
"peer_id": "bd1d992806bb8927",
"port": "18080",
"pruning_seed": 0,
"recv_count": 299445,
"recv_idle_time": 5,
"rpc_credits_per_hash": 1677721,
"rpc_port": 18081,
"send_count": 261093,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "148.251.85.3:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "ec3ca1222f5d462a8df762ccbf3f38bf",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "148.251.85.3",
"incoming": false,
"ip": "148.251.85.3",
"live_time": 598,
"local_ip": false,
"localhost": false,
"peer_id": "2d62a098dde2d88a",
"port": "18080",
"pruning_seed": 0,
"recv_count": 314075,
"recv_idle_time": 5,
"rpc_credits_per_hash": 0,
"rpc_port": 18088,
"send_count": 308837,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "197.245.222.218:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "68b7957705be42c9a6e11e53d85e5932",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "197.245.222.218",
"incoming": false,
"ip": "197.245.222.218",
"live_time": 45,
"local_ip": false,
"localhost": false,
"peer_id": "12763cc92ac5bb37",
"port": "18080",
"pruning_seed": 0,
"recv_count": 32941,
"recv_idle_time": 4,
"rpc_credits_per_hash": 0,
"rpc_port": 18089,
"send_count": 21562,
"send_idle_time": 5,
"state": "normal",
"support_flags": 1
},
{
"address": "112.215.205.229:18080",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "bc14510a700943dba892b38d858e786b",
"current_download": 0,
"current_upload": 0,
"height": 2288915,
"host": "112.215.205.229",
"incoming": false,
"ip": "112.215.205.229",
"live_time": 592,
"local_ip": false,
"localhost": false,
"peer_id": "2ade87c2d76672f0",
"port": "18080",
"pruning_seed": 0,
"recv_count": 313614,
"recv_idle_time": 2,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 297173,
"send_idle_time": 7,
"state": "normal",
"support_flags": 1
}
],
"status": "OK",
"untrusted": false
}
}

@ -0,0 +1,12 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"fee": 7790,
"quantization_mask": 10000,
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,48 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"adjusted_time": 1612377295,
"alt_blocks_count": 0,
"block_size_limit": 600000,
"block_size_median": 300000,
"block_weight_limit": 600000,
"block_weight_median": 300000,
"bootstrap_daemon_address": "",
"busy_syncing": false,
"credits": 0,
"cumulative_difficulty": 86754859378339639,
"cumulative_difficulty_top64": 0,
"database_size": 120378499072,
"difficulty": 258886688222,
"difficulty_top64": 0,
"free_space": 275984478208,
"grey_peerlist_size": 5000,
"height": 2288923,
"height_without_bootstrap": 2288923,
"incoming_connections_count": 0,
"mainnet": true,
"nettype": "mainnet",
"offline": false,
"outgoing_connections_count": 12,
"rpc_connections_count": 1,
"stagenet": false,
"start_time": 1612375367,
"status": "OK",
"synchronized": true,
"target": 120,
"target_height": 2288923,
"testnet": false,
"top_block_hash": "d41401b43220e54ec2567a889e0ad65196ba28d98e61b24d20491ddd060317a1",
"top_hash": "",
"tx_count": 11295065,
"tx_pool_size": 21,
"untrusted": false,
"update_available": false,
"version": "0.17.1.9-release",
"was_bootstrap_ever_used": false,
"white_peerlist_size": 1000,
"wide_cumulative_difficulty": "0x1343715bfc8ef37",
"wide_difficulty": "0x3c46d95dde"
}
}

@ -0,0 +1,32 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 0,
"cumulative_difficulty": 0,
"cumulative_difficulty_top64": 0,
"depth": 0,
"difficulty": 0,
"difficulty_top64": 0,
"hash": "",
"height": 0,
"major_version": 0,
"miner_tx_hash": "",
"minor_version": 0,
"nonce": 0,
"num_txes": 0,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "",
"reward": 0,
"timestamp": 0,
"wide_cumulative_difficulty": "",
"wide_difficulty": ""
},
"credits": 0,
"status": "BUSY",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,34 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 65605,
"block_weight": 65605,
"cumulative_difficulty": 86426998743673801,
"cumulative_difficulty_top64": 0,
"depth": 0,
"difficulty": 253652891944,
"difficulty_top64": 0,
"hash": "a55ec867052340715c4b8b4dcd2de53bc2a195e666058d10a224037932ccdc40",
"height": 2287573,
"long_term_weight": 65605,
"major_version": 14,
"miner_tx_hash": "42219818a7f30910a89e0d0d9fc479950137b93820e5955fc071fa8f4e3c2400",
"minor_version": 14,
"nonce": 37920,
"num_txes": 34,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "7ca630666d7040f0cadbaaf9da92db4797ef67b60ca8f15324b94236ffe0b3a8",
"reward": 1181081601887,
"timestamp": 1612215053,
"wide_cumulative_difficulty": "0x1330ce5bf1eabc9",
"wide_difficulty": "0x3b0ee3f928"
},
"credits": 0,
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,24 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"histogram": [
{
"amount": 1000000000000,
"recent_instances": 874619,
"total_instances": 874619,
"unlocked_instances": 874619
},
{
"amount": 5000000000000,
"recent_instances": 255089,
"total_instances": 255089,
"unlocked_instances": 255089
}
],
"status": "OK",
"top_hash": "",
"untrusted": false
}
}

@ -0,0 +1,10 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"release": true,
"status": "OK",
"untrusted": false,
"version": 196613
}
}

@ -0,0 +1,18 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"earliest_height": 2210720,
"enabled": true,
"state": 2,
"status": "OK",
"threshold": 0,
"top_hash": "",
"untrusted": false,
"version": 14,
"votes": 10080,
"voting": 14,
"window": 10080
}
}

@ -0,0 +1,8 @@
{
"error": {
"code": -32601,
"message": "Method not found"
},
"id": "",
"jsonrpc": "2.0"
}

@ -0,0 +1,5 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": "dc2ef85b049311814742f543469e3ec1b8d589e68434d9f220ce41072c69c39e"
}

@ -0,0 +1,7 @@
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"status": "OK"
}
}

@ -0,0 +1,8 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"status": "OK",
"untrusted": false
}
}

@ -0,0 +1,8 @@
{
"id": "0",
"jsonrpc": "2.0",
"error": {
"code": -7,
"message": "Block not accepted"
}
}

@ -0,0 +1,288 @@
{
"id": 0,
"jsonrpc": "2.0",
"result": {
"credits": 0,
"height": 2292442,
"next_needed_pruning_seed": 0,
"overview": "[m]",
"peers": [
{
"info": {
"address": "54.39.75.54:59545",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "9bded655ad3d44eaa8b51917bdb8edbb",
"current_download": 0,
"current_upload": 0,
"height": 1,
"host": "54.39.75.54",
"incoming": true,
"ip": "54.39.75.54",
"live_time": 1,
"local_ip": false,
"localhost": false,
"peer_id": "0000000000000000",
"port": "59545",
"pruning_seed": 0,
"recv_count": 277,
"recv_idle_time": 1,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 0,
"send_idle_time": 1,
"state": "before_handshake",
"support_flags": 0
}
},
{
"info": {
"address": "71.127.156.63:18080",
"address_type": 1,
"avg_download": 2,
"avg_upload": 2,
"connection_id": "7cdec5cac0aa407d8e056060f0dce6b4",
"current_download": 2,
"current_upload": 1,
"height": 2292455,
"host": "71.127.156.63",
"incoming": false,
"ip": "71.127.156.63",
"live_time": 8,
"local_ip": false,
"localhost": false,
"peer_id": "b57c1d628236d6fb",
"port": "18080",
"pruning_seed": 0,
"recv_count": 22374,
"recv_idle_time": 0,
"rpc_credits_per_hash": 0,
"rpc_port": 18089,
"send_count": 17416,
"send_idle_time": 0,
"state": "synchronizing",
"support_flags": 1
}
},
{
"info": {
"address": "178.63.100.197:18080",
"address_type": 1,
"avg_download": 110,
"avg_upload": 1,
"connection_id": "e8076d15669c431d90b290a712760359",
"current_download": 110,
"current_upload": 1,
"height": 2292455,
"host": "178.63.100.197",
"incoming": false,
"ip": "178.63.100.197",
"live_time": 9,
"local_ip": false,
"localhost": false,
"peer_id": "449271bcfcef7f09",
"port": "18080",
"pruning_seed": 0,
"recv_count": 1021331,
"recv_idle_time": 1,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 16867,
"send_idle_time": 8,
"state": "normal",
"support_flags": 1
}
},
{
"info": {
"address": "165.22.236.24:18080",
"address_type": 1,
"avg_download": 110,
"avg_upload": 0,
"connection_id": "915185f624eb4608947634fde6b9c1fe",
"current_download": 110,
"current_upload": 0,
"height": 2292455,
"host": "165.22.236.24",
"incoming": false,
"ip": "165.22.236.24",
"live_time": 9,
"local_ip": false,
"localhost": false,
"peer_id": "7c7aa2074c6a751b",
"port": "18080",
"pruning_seed": 0,
"recv_count": 1018291,
"recv_idle_time": 8,
"rpc_credits_per_hash": 0,
"rpc_port": 18089,
"send_count": 1930,
"send_idle_time": 9,
"state": "synchronizing",
"support_flags": 1
}
},
{
"info": {
"address": "91.134.195.240:6841",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "ae10ae80001644cbaa5d11c89b438ef1",
"current_download": 0,
"current_upload": 0,
"height": 0,
"host": "91.134.195.240",
"incoming": false,
"ip": "91.134.195.240",
"live_time": 8,
"local_ip": false,
"localhost": false,
"peer_id": "0000000000000000",
"port": "6841",
"pruning_seed": 0,
"recv_count": 0,
"recv_idle_time": 8,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 276,
"send_idle_time": 0,
"state": "before_handshake",
"support_flags": 0
}
},
{
"info": {
"address": "54.37.179.243:9614",
"address_type": 1,
"avg_download": 1,
"avg_upload": 0,
"connection_id": "d3fded162175437da399925605ca3518",
"current_download": 1,
"current_upload": 0,
"height": 2292442,
"host": "54.37.179.243",
"incoming": false,
"ip": "54.37.179.243",
"live_time": 10,
"local_ip": false,
"localhost": false,
"peer_id": "722e7a576324d872",
"port": "9614",
"pruning_seed": 0,
"recv_count": 15409,
"recv_idle_time": 8,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 390,
"send_idle_time": 8,
"state": "normal",
"support_flags": 1
}
},
{
"info": {
"address": "51.79.58.93:37237",
"address_type": 1,
"avg_download": 0,
"avg_upload": 0,
"connection_id": "34a5137c68974507b765e86ef6adf101",
"current_download": 0,
"current_upload": 0,
"height": 1,
"host": "51.79.58.93",
"incoming": true,
"ip": "51.79.58.93",
"live_time": 3,
"local_ip": false,
"localhost": false,
"peer_id": "f872089bd28ee6d8",
"port": "37237",
"pruning_seed": 0,
"recv_count": 277,
"recv_idle_time": 3,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 0,
"send_idle_time": 3,
"state": "normal",
"support_flags": 0
}
},
{
"info": {
"address": "51.255.233.156:12189",
"address_type": 1,
"avg_download": 1,
"avg_upload": 0,
"connection_id": "c4b780395a10482dbfbb72e4da1943fc",
"current_download": 1,
"current_upload": 0,
"height": 2292442,
"host": "51.255.233.156",
"incoming": false,
"ip": "51.255.233.156",
"live_time": 10,
"local_ip": false,
"localhost": false,
"peer_id": "47da23ee4994e50e",
"port": "12189",
"pruning_seed": 0,
"recv_count": 15305,
"recv_idle_time": 9,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 1275,
"send_idle_time": 9,
"state": "normal",
"support_flags": 1
}
},
{
"info": {
"address": "51.91.33.156:60567",
"address_type": 1,
"avg_download": 1,
"avg_upload": 1,
"connection_id": "0f6283f1d61b4095a95c4dccff7f150f",
"current_download": 0,
"current_upload": 1,
"height": 2292442,
"host": "51.91.33.156",
"incoming": true,
"ip": "51.91.33.156",
"live_time": 11,
"local_ip": false,
"localhost": false,
"peer_id": "9ef7bdcee2a6fa22",
"port": "60567",
"pruning_seed": 0,
"recv_count": 15513,
"recv_idle_time": 0,
"rpc_credits_per_hash": 0,
"rpc_port": 0,
"send_count": 15218,
"send_idle_time": 10,
"state": "normal",
"support_flags": 1
}
}
],
"spans": [
{
"connection_id": "e8076d15669c431d90b290a712760359",
"nblocks": 13,
"rate": 982529,
"remote_address": "178.63.100.197:18080",
"size": 998309,
"speed": 100,
"start_block_height": 2292442
}
],
"status": "OK",
"target_height": 2292455,
"top_hash": "",
"untrusted": false
}
}

@ -1,4 +1,5 @@
import decimal
import json
import logging
import os
import responses
@ -6,7 +7,7 @@ import responses
from monero.const import NET_STAGE
from monero.daemon import Daemon
from monero.backends.jsonrpc import JSONRPCDaemon, RPCError
from monero.exceptions import TransactionWithoutBlob
from monero.exceptions import TransactionWithoutBlob, DaemonIsBusy
from monero.transaction import Transaction
from .base import JSONTestCase
@ -20,6 +21,7 @@ class JSONRPCDaemonTestCase(JSONTestCase):
def setUp(self):
self.daemon = Daemon(JSONRPCDaemon())
self.backend = self.daemon._backend
# this is disabled b/c raw_request logs errors
logging.getLogger('monero.backends.jsonrpc.daemon').disabled = True
@ -212,3 +214,578 @@ class JSONRPCDaemonTestCase(JSONTestCase):
with self.assertRaises(ValueError):
daemon3 = Daemon(backend=JSONRPCDaemon(), port=18089)
@responses.activate
def test_busy_daemon(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_last_block_header_BUSY.json'),
status=200)
with self.assertRaises(DaemonIsBusy):
self.backend.get_last_block_header()
# Start testing all JSONRPC commands
@responses.activate
def test_get_block_count(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_count_2287024.json'),
status=200)
resp = self.backend.get_block_count()
self.assertEqual(resp['status'], 'OK')
self.assertEqual(resp['count'], 2287024)
@responses.activate
def test_on_get_block_hash(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_on_get_block_hash_2000000.json'),
status=200)
self.assertEqual(
self.backend.on_get_block_hash(2000000),
'dc2ef85b049311814742f543469e3ec1b8d589e68434d9f220ce41072c69c39e')
with self.assertRaises(ValueError):
self.backend.on_get_block_hash(-2023)
@responses.activate
def test_get_block_template(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_template_481SgRxo_64.json'),
status=200)
resp = self.backend.get_block_template(
'481SgRxo8hwBCY4z6r88JrN5X8JFCJYuJUDuJXGybTwaVKyoJPKoGj3hQRAEGgQTdmV1xH1URdnHkJv6He5WkEbq6iKhr94',
reserve_size=64)
self.assertTrue(resp['blocktemplate_blob'].startswith(
'0e0ec890de8006fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd27'))
self.assertTrue(resp['blockhashing_blob'].startswith(
'0e0ec890de8006fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd27'))
self.assertEqual(resp['difficulty'], 232871166515)
self.assertEqual(resp['difficulty_top64'], 0)
self.assertEqual(resp['expected_reward'], 1180703555413)
self.assertEqual(resp['height'], 2287042)
self.assertEqual(resp['prev_hash'], 'fbe94dbaf09e5fc4431460ede46c0e7c3db4adf1f0a6f34c5a0f5144e6d9dd27')
self.assertEqual(resp['reserved_offset'], 130)
self.assertEqual(resp['seed_hash'], 'd432f499205150873b2572b5f033c9c6e4b7c6f3394bd2dd93822cd7085e7307')
self.assertEqual(resp['seed_height'], 2285568)
self.assertEqual(resp['status'], 'OK')
self.assertEqual(resp['untrusted'], False)
self.assertEqual(resp['wide_difficulty'], '0x3638340233')
with self.assertRaises(ValueError):
self.backend.get_block_template(
'481SgRxo8hwBCY4z6r88JrN5X8JFCJYuJUDuJXGybTwaVKyoJPKoGj3hQRAEGgQTdmV1xH1URdnHkJv6He5WkEbq6iKhr94',
-49)
with self.assertRaises(ValueError):
self.backend.get_block_template(
'ThisIsAnInvalidWalletAddressSoThisShouldThrowAnError',
30)
@responses.activate
def test_submit_block(self):
# @TODO I need a more thorough test for this routine, but I do have have an example of a response for a successfully
# mined block, sadly. Maybe we can use the project donations to purchase an AMD EPYC 7742 for "research" ;)
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_submit_block_failure.json'),
status=200)
with self.assertRaises(RPCError):
self.backend.submit_block(b'this is not a block and should not work')
@responses.activate
def test_get_last_block_header(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_last_block_header_success.json'),
status=200)
resp = self.backend.get_last_block_header()
self.assertEqual(resp['status'], 'OK')
block_header = resp['block_header']
self.assertEqual(block_header['block_size'], 65605)
self.assertEqual(block_header['block_weight'], 65605)
self.assertEqual(block_header['cumulative_difficulty'], 86426998743673801)
self.assertEqual(block_header['cumulative_difficulty_top64'], 0)
self.assertEqual(block_header['wide_cumulative_difficulty'], "0x1330ce5bf1eabc9")
self.assertEqual(block_header['depth'], 0)
self.assertEqual(block_header['difficulty'], 253652891944)
self.assertEqual(block_header['difficulty_top64'], 0)
self.assertEqual(block_header['wide_difficulty'], "0x3b0ee3f928")
self.assertEqual(block_header['hash'], "a55ec867052340715c4b8b4dcd2de53bc2a195e666058d10a224037932ccdc40")
self.assertEqual(block_header['height'], 2287573)
self.assertEqual(block_header['long_term_weight'], 65605)
self.assertEqual(block_header['major_version'], 14)
self.assertEqual(block_header['minor_version'], 14)
self.assertEqual(block_header['miner_tx_hash'], "42219818a7f30910a89e0d0d9fc479950137b93820e5955fc071fa8f4e3c2400")
self.assertEqual(block_header['nonce'], 37920)
self.assertEqual(block_header['num_txes'], 34)
self.assertEqual(block_header['orphan_status'], False)
self.assertEqual(block_header['pow_hash'], "")
self.assertEqual(block_header['prev_hash'], "7ca630666d7040f0cadbaaf9da92db4797ef67b60ca8f15324b94236ffe0b3a8")
self.assertEqual(block_header['reward'], 1181081601887)
self.assertEqual(block_header['timestamp'], 1612215053)
@responses.activate
def test_get_block_header_by_hash(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_header_by_hash_90f6fd3f.json'),
status=200)
resp = self.backend.get_block_header_by_hash('90f6fd3fe29c7518f15afd2da31734e890cc24247b5da10dc9ac2ea215ae844b')
self.assertIn('block_header', resp)
self.assertIn('status', resp)
self.assertIn('untrusted', resp)
block_header = resp['block_header']
self.assertEqual(block_header['block_size'], 17130)
self.assertEqual(block_header['block_weight'], 17130)
self.assertEqual(block_header['cumulative_difficulty'], 86641187797059581)
self.assertEqual(block_header['cumulative_difficulty_top64'], 0)
self.assertEqual(block_header['wide_cumulative_difficulty'], "0x133cfb3858fc7fd")
self.assertEqual(block_header['depth'], 4)
self.assertEqual(block_header['difficulty'], 239025076303)
self.assertEqual(block_header['difficulty_top64'], 0)
self.assertEqual(block_header['wide_difficulty'], "0x37a701384f")
self.assertEqual(block_header['hash'], "90f6fd3fe29c7518f15afd2da31734e890cc24247b5da10dc9ac2ea215ae844b")
self.assertEqual(block_header['height'], 2288453)
self.assertEqual(block_header['long_term_weight'], 17130)
self.assertEqual(block_header['major_version'], 14)
self.assertEqual(block_header['minor_version'], 14)
self.assertEqual(block_header['miner_tx_hash'], "5e8d9531ae078ef5630e3c9950eb768b87b31481652c2b8dafca25d57e9c0c3f")
self.assertEqual(block_header['nonce'], 1040830456)
self.assertEqual(block_header['num_txes'], 11)
self.assertEqual(block_header['orphan_status'], False)
self.assertEqual(block_header['pow_hash'], "")
self.assertEqual(block_header['prev_hash'], "a78d9e631f743806b0b8d3a70bb85758db466633eb3b4620737dd29b0548eb21")
self.assertEqual(block_header['reward'], 1176972120146)
self.assertEqual(block_header['timestamp'], 1612323209)
with self.assertRaises(ValueError):
self.backend.get_block_header_by_hash('HeyWaitAMinuteThisIsntAHashYouLiedToMeHowCouldYouDoThisToMeITrustedYou')
@responses.activate
def test_get_block_header_by_height(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_header_by_height_2288495.json'),
status=200)
resp = self.backend.get_block_header_by_height(2288495)
self.assertIn('block_header', resp)
self.assertIn('status', resp)
self.assertIn('untrusted', resp)
block_header = resp['block_header']
self.assertEqual(block_header['block_size'], 8415)
self.assertEqual(block_header['block_weight'], 8415)
self.assertEqual(block_header['cumulative_difficulty'], 86651164421641270)
self.assertEqual(block_header['cumulative_difficulty_top64'], 0)
self.assertEqual(block_header['wide_cumulative_difficulty'], "0x133d8c662b9d436")
self.assertEqual(block_header['depth'], 3)
self.assertEqual(block_header['difficulty'], 238154836806)
self.assertEqual(block_header['difficulty_top64'], 0)
self.assertEqual(block_header['wide_difficulty'], "0x3773226b46")
self.assertEqual(block_header['hash'], "966c1a70358ce998e7d5fb243b155971f9bffe06030c92dbd70486d398c40c05")
self.assertEqual(block_header['height'], 2288495)
self.assertEqual(block_header['long_term_weight'], 8415)
self.assertEqual(block_header['major_version'], 14)
self.assertEqual(block_header['minor_version'], 14)
self.assertEqual(block_header['miner_tx_hash'], "408dd52531cab37e51db5a9a581bf25691b5534d8d0037b38e68061691b976e1")
self.assertEqual(block_header['nonce'], 1275098057)
self.assertEqual(block_header['num_txes'], 5)
self.assertEqual(block_header['orphan_status'], False)
self.assertEqual(block_header['pow_hash'], "")
self.assertEqual(block_header['prev_hash'], "47751e6eb31230e92a5ee98242aa34d79bfd48657f2727c9a9b3cbad6aee88bb")
self.assertEqual(block_header['reward'], 1176760892780)
self.assertEqual(block_header['timestamp'], 1612328193)
with self.assertRaises(ValueError):
self.backend.get_block_header_by_height(-69420)
@responses.activate
def test_get_block_headers_range(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_headers_range_2288491_2288500.json'),
status=200)
resp = self.backend.get_block_header_by_height(2288495)
self.assertIn('headers', resp)
self.assertIn('status', resp)
self.assertIn('untrusted', resp)
headers = resp['headers']
self.assertEqual(len(headers), 10)
block_header_0 = headers[0]
self.assertEqual(block_header_0['block_size'], 49559)
self.assertEqual(block_header_0['block_weight'], 49559)
self.assertEqual(block_header_0['cumulative_difficulty'], 86650214633914049)
self.assertEqual(block_header_0['cumulative_difficulty_top64'], 0)
self.assertEqual(block_header_0['wide_cumulative_difficulty'], "0x133d7e93ef73ec1")
self.assertEqual(block_header_0['depth'], 19)
self.assertEqual(block_header_0['difficulty'], 236253710852)
self.assertEqual(block_header_0['difficulty_top64'], 0)
self.assertEqual(block_header_0['wide_difficulty'], "0x3701d18a04")
self.assertEqual(block_header_0['hash'], "01a5a129515e752055af9883ac98cdbd9eb90db16ab69ea187a1eb24eb7d0c66")
self.assertEqual(block_header_0['height'], 2288491)
self.assertEqual(block_header_0['long_term_weight'], 49559)
self.assertEqual(block_header_0['major_version'], 14)
self.assertEqual(block_header_0['minor_version'], 14)
self.assertEqual(block_header_0['miner_tx_hash'], "22c3dd706931fe0606e086147dcb8a984b504a5bd0eabd1cf7dabb9456154cd4")
self.assertEqual(block_header_0['nonce'], 922780730)
self.assertEqual(block_header_0['num_txes'], 26)
self.assertEqual(block_header_0['orphan_status'], False)
self.assertEqual(block_header_0['pow_hash'], "")
self.assertEqual(block_header_0['prev_hash'], "6bd071b487be697128142b9b132be8d2c3e4ee9660f73d811c3d23e4526e56ac")
self.assertEqual(block_header_0['reward'], 1178084560299)
self.assertEqual(block_header_0['timestamp'], 1612327847)
with self.assertRaises(ValueError):
self.backend.get_block_headers_range(-1, 10)
with self.assertRaises(ValueError):
self.backend.get_block_headers_range(70, 25)
@responses.activate
def test_get_block_with_height(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_2288515.json'),
status=200)
resp = self.backend.get_block(height=2288515)
resp_fields = ['blob', 'block_header', 'credits', 'json', 'miner_tx_hash', 'status', 'tx_hashes', 'untrusted']
for field in resp_fields:
self.assertIn(field, resp)
self.assertTrue(resp['blob'].startswith('0e0efef0e880066d78ace422007a2cefb423553b3'))
self.assertEqual(len(resp['tx_hashes']), 17)
self.assertEqual(resp['status'], 'OK')
self.assertTrue(type(resp['block_header']), dict)
json.loads(resp['json'])
with self.assertRaises(ValueError):
self.backend.get_block()
with self.assertRaises(ValueError):
self.backend.get_block(height=2288515, hash='1c68300646dda11a89cc9ca4001100745fcbd192e0e6efb6b06bd4d25851662b')
with self.assertRaises(ValueError):
self.backend.get_block(height=-5)
@responses.activate
def test_get_block_with_hash(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_block_2288515.json'),
status=200)
resp = self.backend.get_block(hash='1c68300646dda11a89cc9ca4001100745fcbd192e0e6efb6b06bd4d25851662b')
resp_fields = ['blob', 'block_header', 'credits', 'json', 'miner_tx_hash', 'status', 'tx_hashes', 'untrusted']
for field in resp_fields:
self.assertIn(field, resp)
self.assertTrue(resp['blob'].startswith('0e0efef0e880066d78ace422007a2cefb423553b3'))
self.assertEqual(len(resp['tx_hashes']), 17)
self.assertEqual(resp['status'], 'OK')
self.assertTrue(type(resp['block_header']), dict)
json.loads(resp['json'])
with self.assertRaises(ValueError):
self.backend.get_block(hash='STUPIDHECKINGBADHASH')
@responses.activate
def test_get_connections(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_connections.json'),
status=200)
resp = self.backend.get_connections()
self.assertIn('connections', resp)
connections = resp['connections']
self.assertNotEqual(len(connections), 0)
connection0 = connections[0]
for conn_field in ['address', 'address_type', 'avg_download', 'avg_upload', 'connection_id', 'current_download', 'current_upload',
'height', 'host', 'incoming', 'ip', 'live_time', 'local_ip', 'localhost', 'peer_id', 'port', 'pruning_seed', 'recv_count', 'recv_idle_time',
'rpc_credits_per_hash', 'rpc_port', 'send_count', 'send_idle_time', 'state', 'support_flags']:
self.assertIn(conn_field, connection0)
@responses.activate
def test_get_info(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_info.json'),
status=200)
resp = self.backend.get_info()
for info_field in ['adjusted_time', 'alt_blocks_count', 'block_size_limit', 'block_size_median', 'block_weight_limit', 'block_weight_median',
'bootstrap_daemon_address', 'busy_syncing', 'credits', 'cumulative_difficulty', 'cumulative_difficulty_top64', 'database_size', 'difficulty',
'difficulty_top64', 'free_space', 'grey_peerlist_size', 'height', 'height_without_bootstrap', 'incoming_connections_count', 'mainnet', 'nettype',
'offline', 'outgoing_connections_count', 'rpc_connections_count', 'stagenet', 'start_time', 'status', 'synchronized', 'target', 'target_height',
'testnet', 'top_block_hash', 'top_hash', 'tx_count', 'tx_pool_size', 'untrusted', 'update_available', 'version', 'was_bootstrap_ever_used',
'white_peerlist_size', 'wide_cumulative_difficulty', 'wide_difficulty']:
self.assertIn(info_field, resp)
@responses.activate
def test_hard_fork_info(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_hard_fork_info.json'),
status=200)
resp = self.backend.hard_fork_info()
for fork_field in ["earliest_height", "enabled", "state", "status", "threshold", "version", "votes", "voting", "window"]:
self.assertIn(fork_field, resp)
@responses.activate
def test_set_bans_single(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_set_bans.json'),
status=200)
resp = self.backend.set_bans('188.165.17.204', True, 3600)
self.assertEqual(resp['status'], 'OK')
@responses.activate
def test_set_bans_multiple(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_set_bans.json'),
status=200)
ips = ['188.165.17.204', 1466097787, '87.98.224.124']
bans = [True, True, False]
seconds = [3600, 500, 7200]
self.backend.set_bans(ips, bans, seconds)
def test_set_bans_errors(self):
bad_ips = [-1, 99999999999, 69420, '300.1.1.1', '125.124.123', '8.8.8.8']
bad_bans = [False, False, True, False, True, True]
bad_seconds = [0, None, None, 60, 4000, None]
for i in range(len(bad_ips)):
with self.assertRaises(ValueError):
self.backend.set_bans(bad_ips[i], bad_bans[i], bad_seconds[i])
@responses.activate
def test_get_bans(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_bans.json'),
status=200)
resp = self.backend.get_bans()
self.assertIn('bans', resp) # Should always be true bc I insert bans field when not given
bans = resp['bans']
ban0 = bans[0]
self.assertEqual(ban0['host'], '145.239.118.5')
self.assertEqual(ban0['ip'], 91680657)
self.assertEqual(ban0['seconds'], 72260)
@responses.activate
def test_flush_txpool_all(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_flush_txpool.json'),
status=200)
self.backend.flush_txpool()
@responses.activate
def test_flush_txpool_single(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_flush_txpool.json'),
status=200)
self.backend.flush_txpool('65971f85ee13782f1f664cc8034a10b361b8b71ef821b323405ee0f698adb702')
@responses.activate
def test_flush_txpool_multiple(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_flush_txpool.json'),
status=200)
txs_to_flush = ['51bd0eebbb32392d4b4646e8b398432b9f42dee0e41f4939305e13e9f9a28e08',
'ae9f8cbfdbae825e61c2745dc77c533fb9811e42ab9b3810d9529794c5bc9404']
self.backend.flush_txpool(txs_to_flush)
@responses.activate
def test_get_output_histogram(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_output_histogram_1and5.json'),
status=200)
resp = self.backend.get_output_histogram([1e12, 5e12], 10, 100000000, True, 10)
histogram = resp['histogram']
self.assertEqual(histogram[0]['amount'], 1e12)
self.assertEqual(histogram[0]['recent_instances'], 874619)
self.assertEqual(histogram[0]['total_instances'], 874619)
self.assertEqual(histogram[0]['unlocked_instances'], 874619)
@responses.activate
def test_get_coinbase_tx_sum(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_coinbase_tx_sum_2200000.json'),
status=200)
resp = self.backend.get_coinbase_tx_sum(2200000, 100)
self.assertEqual(resp['emission_amount'], 139291580971286)
self.assertEqual(resp['emission_amount_top64'], 0)
self.assertEqual(resp['wide_emission_amount'], '0x7eaf59343916')
self.assertEqual(resp['fee_amount'], 505668215000)
self.assertEqual(resp['fee_amount_top64'], 0)
self.assertEqual(resp['wide_fee_amount'], '0x75bc2ca0d8')
@responses.activate
def test_get_version(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_version.json'),
status=200)
resp = self.backend.get_version()
self.assertEqual(resp['release'], True)
self.assertEqual(resp['status'], 'OK')
self.assertEqual(resp['untrusted'], False)
self.assertEqual(resp['version'], 196613)
@responses.activate
def test_get_fee_estimate(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_fee_estimate.json'),
status=200)
resp = self.backend.get_fee_estimate()
self.assertEqual(resp['fee'], 7790)
self.assertEqual(resp['quantization_mask'], 10000)
self.assertEqual(resp['status'], 'OK')
self.assertEqual(resp['untrusted'], False)
@responses.activate
def test_get_fee_estimate_with_grace(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_fee_estimate.json'),
status=200)
resp = self.backend.get_fee_estimate(grace_blocks=10)
self.assertEqual(resp['fee'], 7790)
self.assertEqual(resp['quantization_mask'], 10000)
self.assertEqual(resp['status'], 'OK')
self.assertEqual(resp['untrusted'], False)
def test_get_fee_estimate_errors(self):
with self.assertRaises(TypeError):
self.backend.get_fee_estimate(5.5)
with self.assertRaises(ValueError):
self.backend.get_fee_estimate(-100)
@responses.activate
def test_get_alternate_chains(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_get_alternate_chains.json'),
status=200)
resp = self.backend.get_alternate_chains()
chains = resp['chains']
chain0 = chains[0]
self.assertEqual(chain0['block_hash'], '697cf03c89a9b118f7bdf11b1b3a6a028d7b3617d2d0ed91322c5709acf75625')
self.assertEqual(chain0['difficulty'], 14114729638300280)
self.assertEqual(chain0['height'], 1562062)
self.assertEqual(chain0['length'], 2)
@responses.activate
def test_relay_tx_single(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_relay_tx.json'),
status=200)
resp = self.backend.relay_tx('9fd75c429cbe52da9a52f2ffc5fbd107fe7fd2099c0d8de274dc8a67e0c98613')
self.assertEqual(resp['status'], 'OK')
@responses.activate
def test_relay_tx_multiple(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_relay_tx.json'),
status=200)
txs = ['70ee3df366870d8ca2099b273c1ae1c909a964b053077ead5c186c8b160c9d00',
'018476f726efb2d2b5a4a3ba6c29fb4f00549b0dcef6183b2bfa38a7acb1a804']
resp = self.backend.relay_tx(txs)
self.assertEqual(resp['status'], 'OK')
@responses.activate
def test_sync_info(self):
responses.add(responses.POST, self.jsonrpc_url,
json=self._read('test_sync_info.json'),
status=200)
resp = self.backend.sync_info()
height = resp['height']
peers = resp['peers']
spans = resp['spans']
pinfo0 = peers[0]['info']
self.assertEqual(height, 2292442)
self.assertEqual(pinfo0['address'], '54.39.75.54:59545')
self.assertEqual(pinfo0['connection_id'], '9bded655ad3d44eaa8b51917bdb8edbb')
self.assertEqual(pinfo0['host'], '54.39.75.54')
self.assertEqual(pinfo0['port'], '59545')
self.assertEqual(pinfo0['recv_count'], 277)
self.assertEqual(pinfo0['incoming'], True)
span0 = spans[0]
self.assertEqual(span0, {
"connection_id": "e8076d15669c431d90b290a712760359",
"nblocks": 13,
"rate": 982529,
"remote_address": "178.63.100.197:18080",
"size": 998309,
"speed": 100,
"start_block_height": 2292442
})
@responses.activate
def test_get_txpool_backlog(self):
pass
@responses.activate
def test_get_output_distribution(self):
pass
Loading…
Cancel
Save