mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-22 17:58:53 +00:00
functional_tests: add get_transaction_pool_stats
Also fix part of the RPC results being returned as binary. This makes the RPC backward incompatible.
This commit is contained in:
parent
51bd45c352
commit
d53a55204f
@ -86,8 +86,8 @@ namespace cryptonote
|
||||
// whether they can talk to a given daemon without having to know in
|
||||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define CORE_RPC_VERSION_MAJOR 2
|
||||
#define CORE_RPC_VERSION_MINOR 10
|
||||
#define CORE_RPC_VERSION_MAJOR 3
|
||||
#define CORE_RPC_VERSION_MINOR 0
|
||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||
|
||||
@ -1516,7 +1516,7 @@ namespace cryptonote
|
||||
KV_SERIALIZE(num_10m)
|
||||
KV_SERIALIZE(num_not_relayed)
|
||||
KV_SERIALIZE(histo_98pc)
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(histo)
|
||||
KV_SERIALIZE(histo)
|
||||
KV_SERIALIZE(num_double_spends)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
@ -81,6 +81,26 @@ class TransferTest():
|
||||
|
||||
return txes
|
||||
|
||||
def check_empty_pool(self):
|
||||
daemon = Daemon()
|
||||
|
||||
res = daemon.get_transaction_pool_hashes()
|
||||
assert not 'tx_hashes' in res or len(res.tx_hashes) == 0
|
||||
res = daemon.get_transaction_pool_stats()
|
||||
assert res.pool_stats.bytes_total == 0
|
||||
assert res.pool_stats.bytes_min == 0
|
||||
assert res.pool_stats.bytes_max == 0
|
||||
assert res.pool_stats.bytes_med == 0
|
||||
assert res.pool_stats.fee_total == 0
|
||||
assert res.pool_stats.oldest == 0
|
||||
assert res.pool_stats.txs_total == 0
|
||||
assert res.pool_stats.num_failing == 0
|
||||
assert res.pool_stats.num_10m == 0
|
||||
assert res.pool_stats.num_not_relayed == 0
|
||||
assert res.pool_stats.histo_98pc == 0
|
||||
assert not 'histo' in res.pool_stats or len(res.pool_stats.histo) == 0
|
||||
assert res.pool_stats.num_double_spends == 0
|
||||
|
||||
def check_txpool(self):
|
||||
daemon = Daemon()
|
||||
wallet = Wallet()
|
||||
@ -89,6 +109,8 @@ class TransferTest():
|
||||
height = res.height
|
||||
txpool_size = res.tx_pool_size
|
||||
|
||||
self.check_empty_pool()
|
||||
|
||||
txes = self.create_txes('46r4nYSevkfBUMhuykdK3gQ98XDqDTYW1hNLaXNvjpsJaSbNtdXh1sKMsdVgqkaihChAzEy29zEDPMR3NHQvGoZCLGwTerK', 5)
|
||||
|
||||
res = daemon.get_info()
|
||||
@ -97,6 +119,10 @@ class TransferTest():
|
||||
|
||||
res = daemon.get_transaction_pool()
|
||||
assert len(res.transactions) == txpool_size
|
||||
total_bytes = 0
|
||||
total_fee = 0
|
||||
min_bytes = 99999999999999
|
||||
max_bytes = 0
|
||||
for txid in txes.keys():
|
||||
x = [x for x in res.transactions if x.id_hash == txid]
|
||||
assert len(x) == 1
|
||||
@ -110,9 +136,26 @@ class TransferTest():
|
||||
assert x.fee == txes[txid].fee
|
||||
assert x.tx_blob == txes[txid].tx_blob
|
||||
|
||||
total_bytes += x.blob_size
|
||||
total_fee += x.fee
|
||||
min_bytes = min(min_bytes, x.blob_size)
|
||||
max_bytes = max(max_bytes, x.blob_size)
|
||||
|
||||
res = daemon.get_transaction_pool_hashes()
|
||||
assert sorted(res.tx_hashes) == sorted(txes.keys())
|
||||
|
||||
res = daemon.get_transaction_pool_stats()
|
||||
assert res.pool_stats.bytes_total == total_bytes
|
||||
assert res.pool_stats.bytes_min == min_bytes
|
||||
assert res.pool_stats.bytes_max == max_bytes
|
||||
assert res.pool_stats.bytes_med >= min_bytes and res.pool_stats.bytes_med <= max_bytes
|
||||
assert res.pool_stats.fee_total == total_fee
|
||||
assert res.pool_stats.txs_total == len(txes)
|
||||
assert res.pool_stats.num_failing == 0
|
||||
assert res.pool_stats.num_10m == 0
|
||||
assert res.pool_stats.num_not_relayed == 0
|
||||
assert res.pool_stats.num_double_spends == 0
|
||||
|
||||
print('Flushing 2 transactions')
|
||||
txes_keys = list(txes.keys())
|
||||
daemon.flush_txpool([txes_keys[1], txes_keys[3]])
|
||||
@ -127,6 +170,42 @@ class TransferTest():
|
||||
res = daemon.get_transaction_pool_hashes()
|
||||
assert sorted(res.tx_hashes) == sorted(new_keys)
|
||||
|
||||
res = daemon.get_transaction_pool()
|
||||
assert len(res.transactions) == len(new_keys)
|
||||
total_bytes = 0
|
||||
total_fee = 0
|
||||
min_bytes = 99999999999999
|
||||
max_bytes = 0
|
||||
for txid in new_keys:
|
||||
x = [x for x in res.transactions if x.id_hash == txid]
|
||||
assert len(x) == 1
|
||||
x = x[0]
|
||||
assert x.kept_by_block == False
|
||||
assert x.last_failed_id_hash == '0'*64
|
||||
assert x.double_spend_seen == False
|
||||
assert x.weight >= x.blob_size
|
||||
|
||||
assert x.blob_size * 2 == len(txes[txid].tx_blob)
|
||||
assert x.fee == txes[txid].fee
|
||||
assert x.tx_blob == txes[txid].tx_blob
|
||||
|
||||
total_bytes += x.blob_size
|
||||
total_fee += x.fee
|
||||
min_bytes = min(min_bytes, x.blob_size)
|
||||
max_bytes = max(max_bytes, x.blob_size)
|
||||
|
||||
res = daemon.get_transaction_pool_stats()
|
||||
assert res.pool_stats.bytes_total == total_bytes
|
||||
assert res.pool_stats.bytes_min == min_bytes
|
||||
assert res.pool_stats.bytes_max == max_bytes
|
||||
assert res.pool_stats.bytes_med >= min_bytes and res.pool_stats.bytes_med <= max_bytes
|
||||
assert res.pool_stats.fee_total == total_fee
|
||||
assert res.pool_stats.txs_total == len(new_keys)
|
||||
assert res.pool_stats.num_failing == 0
|
||||
assert res.pool_stats.num_10m == 0
|
||||
assert res.pool_stats.num_not_relayed == 0
|
||||
assert res.pool_stats.num_double_spends == 0
|
||||
|
||||
print('Flushing unknown transactions')
|
||||
unknown_txids = ['1'*64, '2'*64, '3'*64]
|
||||
daemon.flush_txpool(unknown_txids)
|
||||
@ -140,6 +219,8 @@ class TransferTest():
|
||||
res = daemon.get_transaction_pool_hashes()
|
||||
assert not 'tx_hashes' in res or len(res.tx_hashes) == 0
|
||||
|
||||
self.check_empty_pool()
|
||||
|
||||
print('Popping block')
|
||||
daemon.pop_blocks(1)
|
||||
res = daemon.get_transaction_pool_hashes()
|
||||
@ -159,6 +240,9 @@ class TransferTest():
|
||||
assert x.fee == txes[txid].fee
|
||||
assert x.tx_blob == txes[txid].tx_blob
|
||||
|
||||
daemon.flush_txpool()
|
||||
self.check_empty_pool()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
TransferTest().run_test()
|
||||
|
@ -208,6 +208,11 @@ class Daemon(object):
|
||||
}
|
||||
return self.rpc.send_request('/get_transaction_pool_hashes', get_transaction_pool_hashes)
|
||||
|
||||
def get_transaction_pool_stats(self):
|
||||
get_transaction_pool_stats = {
|
||||
}
|
||||
return self.rpc.send_request('/get_transaction_pool_stats', get_transaction_pool_stats)
|
||||
|
||||
def flush_txpool(self, txids = []):
|
||||
flush_txpool = {
|
||||
'method': 'flush_txpool',
|
||||
|
Loading…
Reference in New Issue
Block a user