Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 7767d90

Browse files
committed
Update unit tests with new Chain Controller params
Signed-off-by: Peter Schwarz <peterx.schwarz@intel.com>
1 parent 1baa084 commit 7767d90

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

validator/tests/test_journal/tests.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
# pylint: disable=unbalanced-tuple-unpacking
2020

2121
import logging
22+
import os
2223
import shutil
2324
import tempfile
2425
from threading import RLock
2526
import unittest
2627
from unittest.mock import patch
2728

2829
from sawtooth_validator.database.dict_database import DictDatabase
30+
from sawtooth_validator.database.native_lmdb import NativeLmdbDatabase
2931

3032
from sawtooth_validator.journal.block_cache import BlockCache
3133
from sawtooth_validator.journal.block_wrapper import BlockStatus
@@ -65,6 +67,7 @@
6567
from sawtooth_validator.protobuf.events_pb2 import Event
6668
from sawtooth_validator.protobuf.events_pb2 import EventFilter
6769

70+
from sawtooth_validator.state.merkle import MerkleDatabase
6871
from sawtooth_validator.state.settings_view import SettingsViewFactory
6972
from sawtooth_validator.state.settings_cache import SettingsCache
7073

@@ -896,6 +899,11 @@ class TestChainController(unittest.TestCase):
896899
def setUp(self):
897900
self.dir = tempfile.mkdtemp()
898901

902+
self.state_database = NativeLmdbDatabase(
903+
os.path.join(self.dir, 'merkle.lmdb'),
904+
indexes=MerkleDatabase.create_index_configuration(),
905+
_size=120 * 1024 * 1024)
906+
899907
self.block_tree_manager = BlockTreeManager()
900908
self.gossip = MockNetwork()
901909
self.txn_executor = MockTransactionExecutor()
@@ -925,6 +933,7 @@ def chain_updated(head, committed_batches=None,
925933
self.block_tree_manager.block_store,
926934
self.block_tree_manager.block_cache,
927935
self.block_validator,
936+
self.state_database,
928937
self._chain_head_lock,
929938
chain_updated,
930939
data_dir=self.dir,
@@ -1228,6 +1237,11 @@ def setUp(self):
12281237
batch_execution_result=None)
12291238
self.executor = SynchronousExecutor()
12301239

1240+
self.state_database = NativeLmdbDatabase(
1241+
os.path.join(self.dir, 'merkle.lmdb'),
1242+
indexes=MerkleDatabase.create_index_configuration(),
1243+
_size=120 * 1024 * 1024)
1244+
12311245
self.block_validator = None
12321246
self.chain_ctrl = None
12331247

@@ -1251,6 +1265,7 @@ def chain_updated(head, committed_batches=None,
12511265
self.block_tree_manager.block_store,
12521266
self.block_tree_manager.block_cache,
12531267
self.block_validator,
1268+
self.state_database,
12541269
self.chain_head_lock,
12551270
chain_updated,
12561271
data_dir=self.dir,
@@ -1319,12 +1334,16 @@ def test_invalid_genesis_block_matches_block_chain_id(self):
13191334

13201335
class TestJournal(unittest.TestCase):
13211336
def setUp(self):
1337+
self.dir = tempfile.mkdtemp()
13221338
self.gossip = MockNetwork()
13231339
self.txn_executor = MockTransactionExecutor()
13241340
self.block_sender = MockBlockSender()
13251341
self.batch_sender = MockBatchSender()
13261342
self.permission_verifier = MockPermissionVerifier()
13271343

1344+
def tearDown(self):
1345+
shutil.rmtree(self.dir)
1346+
13281347
def test_publish_block(self):
13291348
"""
13301349
Test that the Journal will produce blocks and consume those blocks
@@ -1369,10 +1388,16 @@ def test_publish_block(self):
13691388
config_dir=None,
13701389
permission_verifier=self.permission_verifier)
13711390

1391+
state_database = NativeLmdbDatabase(
1392+
os.path.join(self.dir, 'merkle.lmdb'),
1393+
indexes=MerkleDatabase.create_index_configuration(),
1394+
_size=120 * 1024 * 1024)
1395+
13721396
chain_controller = ChainController(
13731397
btm.block_store,
13741398
btm.block_cache,
13751399
block_validator,
1400+
state_database,
13761401
block_publisher.chain_head_lock,
13771402
block_publisher.on_chain_updated,
13781403
data_dir=None,

0 commit comments

Comments
 (0)