aboutsummaryrefslogtreecommitdiff
path: root/test/functional/rpc_getblockstats.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/rpc_getblockstats.py')
-rwxr-xr-xtest/functional/rpc_getblockstats.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py
index 1ea1ee5659..bf261befcc 100755
--- a/test/functional/rpc_getblockstats.py
+++ b/test/functional/rpc_getblockstats.py
@@ -43,6 +43,10 @@ class GetblockstatsTest(BitcoinTestFramework):
def generate_test_data(self, filename):
mocktime = 1525107225
self.nodes[0].setmocktime(mocktime)
+ self.nodes[0].createwallet(wallet_name='test')
+ privkey = self.nodes[0].get_deterministic_priv_key().key
+ self.nodes[0].importprivkey(privkey)
+
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
address = self.nodes[0].get_deterministic_priv_key().address
@@ -53,6 +57,8 @@ class GetblockstatsTest(BitcoinTestFramework):
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=False)
self.nodes[0].settxfee(amount=0.003)
self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True)
+ # Send to OP_RETURN output to test its exclusion from statistics
+ self.nodes[0].send(outputs={"data": "21"})
self.sync_all()
self.generate(self.nodes[0], 1)
@@ -161,6 +167,20 @@ class GetblockstatsTest(BitcoinTestFramework):
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats, '00', 1, 2)
assert_raises_rpc_error(-1, 'getblockstats hash_or_height ( stats )', self.nodes[0].getblockstats)
+ self.log.info('Test block height 0')
+ genesis_stats = self.nodes[0].getblockstats(0)
+ assert_equal(genesis_stats["blockhash"], "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")
+ assert_equal(genesis_stats["utxo_increase"], 1)
+ assert_equal(genesis_stats["utxo_size_inc"], 117)
+ assert_equal(genesis_stats["utxo_increase_actual"], 0)
+ assert_equal(genesis_stats["utxo_size_inc_actual"], 0)
+
+ self.log.info('Test tip including OP_RETURN')
+ tip_stats = self.nodes[0].getblockstats(tip)
+ assert_equal(tip_stats["utxo_increase"], 6)
+ assert_equal(tip_stats["utxo_size_inc"], 441)
+ assert_equal(tip_stats["utxo_increase_actual"], 4)
+ assert_equal(tip_stats["utxo_size_inc_actual"], 300)
if __name__ == '__main__':
GetblockstatsTest().main()