Initial Vexta Core v0.1.0 release
This commit is contained in:
commit
25c454329d
2481 changed files with 689289 additions and 0 deletions
56
test/functional/rpc_dumptxoutset.py
Executable file
56
test/functional/rpc_dumptxoutset.py
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2019-2021 The DigiByte Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test the generation of UTXO snapshots using `dumptxoutset`.
|
||||
"""
|
||||
|
||||
from test_framework.blocktools import (
|
||||
COINBASE_MATURITY,
|
||||
COINBASE_MATURITY_2,
|
||||
)
|
||||
from test_framework.test_framework import DigiByteTestFramework
|
||||
from test_framework.util import assert_equal, assert_raises_rpc_error
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class DumptxoutsetTest(DigiByteTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 1
|
||||
|
||||
def run_test(self):
|
||||
"""Test a trivial usage of the dumptxoutset RPC command."""
|
||||
node = self.nodes[0]
|
||||
mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1
|
||||
node.setmocktime(mocktime)
|
||||
self.generate(node, COINBASE_MATURITY_2)
|
||||
|
||||
FILENAME = 'txoutset.dat'
|
||||
out = node.dumptxoutset(FILENAME)
|
||||
expected_path = Path(node.datadir) / self.chain / FILENAME
|
||||
|
||||
assert expected_path.is_file()
|
||||
|
||||
assert_equal(out['coins_written'], 100)
|
||||
assert_equal(out['base_height'], 100)
|
||||
assert_equal(out['path'], str(expected_path))
|
||||
# Blockhash should be deterministic based on mocked time.
|
||||
assert_equal(
|
||||
out['base_hash'],
|
||||
'4d9497f470fcf05bdcc7f3402d5cc3070a33fa8f3effb117074ad07bb09e7f72')
|
||||
|
||||
with open(str(expected_path), 'rb') as f:
|
||||
digest = hashlib.sha256(f.read()).hexdigest()
|
||||
# UTXO snapshot hash should be deterministic based on mocked time.
|
||||
assert_equal(
|
||||
digest, 'f202ed83b2e0b29019d7090d29ec90d89014923f80f433af0a1b82ec0577c43c')
|
||||
|
||||
# Specifying a path to an existing file will fail.
|
||||
assert_raises_rpc_error(
|
||||
-8, '{} already exists'.format(FILENAME), node.dumptxoutset, FILENAME)
|
||||
|
||||
if __name__ == '__main__':
|
||||
DumptxoutsetTest().main()
|
||||
Loading…
Reference in a new issue