fix stateRootHash in test_create_3pc_batch_with_empty_requests()
+import types
+
import pytest
from common.exceptions import LogicError, PlenumValueError
from plenum.common.util import get_utc_epoch
-from plenum.common.messages.node_messages import Prepare
-from plenum.server.models import ThreePhaseVotes
from plenum.server.quorums import Quorums
from plenum.server.replica import Replica
from plenum.test.bls.helper import create_prepare
from plenum.test.testing_utils import FakeSomething
-
nodeCount = 4
-@pytest.fixture(scope='module')
+@pytest.fixture(scope='function')
def replica(tconf):
node_stack = FakeSomething(
name="fake stack",
@@ -24,7 +23,8 @@ def replica(tconf):
ledger_ids=[0],
viewNo=0,
quorums=Quorums(nodeCount),
- nodestack=node_stack
+ nodestack=node_stack,
+ utc_epoch=lambda *args: get_utc_epoch()
)
bls_bft_replica = FakeSomething(
gc=lambda *args: None,
@@ -158,6 +158,9 @@ def test_request_prepare_doesnt_crash_when_primary_is_not_connected(replica):
def test_create_3pc_batch_with_empty_requests(replica):
- Replica.utc_epoch = property(lambda self: get_utc_epoch())
- Replica.stateRootHash = lambda self, ledger_id, to_str: b"EuDgqga9DNr4bjH57Rdq6BRtvCN1PV9UX5Mpnm9gbMAZ"
+ def patched_stateRootHash(self, ledger_id, to_str):
+ return b"EuDgqga9DNr4bjH57Rdq6BRtvCN1PV9UX5Mpnm9gbMAZ"
+
+ replica.stateRootHash = types.MethodType(patched_stateRootHash, replica)
+
assert replica.create3PCBatch(0) is None
\ No newline at end of file
