Skip to content

Commit

Permalink
[INDY-1058] Get rid of Registry-based pools (hyperledger#568)
Browse files Browse the repository at this point in the history
* Initial test integration

Signed-off-by: ArtObr <[email protected]>

* Two more files done

Signed-off-by: ArtObr <[email protected]>

* new test

Signed-off-by: ArtObr <[email protected]>

* 4 more folders done

Signed-off-by: ArtObr <[email protected]>

* two more files

Signed-off-by: ArtObr <[email protected]>

* some changes

Signed-off-by: ArtObr <[email protected]>

* More tests integrated. Problems: validator functions of client in test_state_proof; problem with wrong bls keys

Signed-off-by: ArtObr <[email protected]>

* Initial commit

Signed-off-by: ArtObr <[email protected]>

* Script fix. bls validation fix

Signed-off-by: ArtObr <[email protected]>

* more changes

Signed-off-by: ArtObr <[email protected]>

* little fix

Signed-off-by: ArtObr <[email protected]>

* Fix for bls validation tests. Not done: update_incorrect test and state_proof test

Signed-off-by: ArtObr <[email protected]>

* Only state_proof test left

Signed-off-by: ArtObr <[email protected]>

* Tests integration done

Signed-off-by: ArtObr <[email protected]>

* Deletion of Client1Connected. More test fix

Signed-off-by: ArtObr <[email protected]>

* Import deletion. flake8 error fix.

Signed-off-by: ArtObr <[email protected]>

* More changes to txnPoolNodeSet

Signed-off-by: ArtObr <[email protected]>

* Changes in tests

Signed-off-by: ArtObr <[email protected]>

* Remove pf TestNodeSet. Change of helper methods. Part 1.

Signed-off-by: ArtObr <[email protected]>

* Remove TestNodeSet from helper. part 2

Signed-off-by: ArtObr <[email protected]>

* More tests integrated

Signed-off-by: ArtObr <[email protected]>

* Functions fixes.

Signed-off-by: ArtObr <[email protected]>

* Fix for genesis txns

Signed-off-by: ArtObr <[email protected]>

* More tests integrated

Signed-off-by: ArtObr <[email protected]>

* primary_selection dependency fix

Signed-off-by: ArtObr <[email protected]>

* Fixture fix for view_change

Signed-off-by: ArtObr <[email protected]>

* View change test fix

Signed-off-by: ArtObr <[email protected]>

* Skips for merkle proof tests

Signed-off-by: ArtObr <[email protected]>

* Skips for merkle proof tests

Signed-off-by: ArtObr <[email protected]>

* Review changes

Signed-off-by: ArtObr <[email protected]>

* Review changes

Signed-off-by: ArtObr <[email protected]>
  • Loading branch information
ArtObr authored and Andrew Nikitin committed Apr 10, 2018
1 parent 468fc76 commit 65dae3a
Show file tree
Hide file tree
Showing 257 changed files with 1,057 additions and 1,505 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from plenum.test.test_node import getNonPrimaryReplicas
from plenum.test.helper import sdk_send_random_requests


def test_sdk_no_ordering_during_syncup(tconf, looper, txnPoolNodeSet, sdk_pool_handle, sdk_wallet_client):
non_primary_replica = getNonPrimaryReplicas(txnPoolNodeSet, instId=0)[0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from plenum.test.delayers import cDelay
from plenum.test.test_node import getNonPrimaryReplicas
from plenum.test.batching_3pc.helper import checkNodesHaveSameRoots
from plenum.test.helper import sdk_signed_random_requests, sdk_send_and_check,\
from plenum.test.helper import sdk_signed_random_requests, sdk_send_and_check, \
sdk_send_random_requests, sdk_get_replies


Expand Down Expand Up @@ -46,7 +46,6 @@ def test_unordered_state_reverted_before_catchup(
reqs = sdk_send_random_requests(looper, sdk_pool_handle, sdk_wallet_client, tconf.Max3PCBatchSize)
sdk_get_replies(looper, reqs, timeout=40)


committed_ledger_during_3pc = non_primary_node.getLedger(
ledger_id).tree.root_hash
uncommitted_ledger_during_3pc = non_primary_node.getLedger(
Expand Down
8 changes: 0 additions & 8 deletions plenum/test/batching_3pc/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pytest

from plenum.test.conftest import getValueFromModule
from plenum.test.pool_transactions.conftest import looper, clientAndWallet1, \
client1, wallet1, client1Connected


@pytest.fixture(scope="module")
Expand All @@ -15,9 +13,3 @@ def reset():

request.addfinalizer(reset)
return tconf


@pytest.fixture(scope="module")
def client(tconf, looper, txnPoolNodeSet, client1,
client1Connected):
return client1Connected
2 changes: 1 addition & 1 deletion plenum/test/batching_3pc/test_basic_batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def testRequestStaticValidation(tconf, looper, txnPoolNodeSet,
node.doStaticValidation(req)


def test3PCOverBatchWithThresholdReqs(tconf, looper, txnPoolNodeSet, client,
def test3PCOverBatchWithThresholdReqs(tconf, looper, txnPoolNodeSet,
sdk_wallet_client, sdk_pool_handle):
"""
Check that 3 phase commit happens when threshold number of requests are
Expand Down
2 changes: 1 addition & 1 deletion plenum/test/batching_3pc/test_batching_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def testPrePrepareProcessedInOrder(perf_chk_patched, looper, txnPoolNodeSet,
"""
tconf = perf_chk_patched
pr, otherR = getPrimaryReplica(txnPoolNodeSet, instId=0), \
getNonPrimaryReplicas(txnPoolNodeSet, instId=0)
getNonPrimaryReplicas(txnPoolNodeSet, instId=0)
otherNodes = [r.node for r in otherR]
ppsToDelay = 2
delayeds = 0
Expand Down
6 changes: 3 additions & 3 deletions plenum/test/blacklist/test_blacklist_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def setup(client1):


# noinspection PyIncorrectDocstring,PyUnusedLocal,PyShadowingNames
def testDoNotBlacklistClient(setup, looper, nodeSet, up, client1, sent1):
def testDoNotBlacklistClient(setup, looper, txnPoolNodeSet, client1, sent1):
"""
Client should be not be blacklisted by node on sending an unsigned request
"""

# No node should blacklist the client
def chk():
for node in nodeSet:
for node in txnPoolNodeSet:
assert not node.isClientBlacklisted(client1.name)

timeout = waits.expectedClientToPoolConnectionTimeout(len(nodeSet))
timeout = waits.expectedClientToPoolConnectionTimeout(len(txnPoolNodeSet))
looper.run(eventually(chk, retryWait=1, timeout=timeout))
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

# noinspection PyIncorrectDocstring,PyUnusedLocal,PyShadowingNames
@pytest.mark.skip(reason="SOV-540. Implementation changed.")
def testBlacklistNodeOnMultipleNominations(looper, keySharedNodes, ready):
def testBlacklistNodeOnMultipleNominations(looper, txnPoolNodeSet, ready):
"""
A node that sends multiple nominations must be blacklisted by other nodes
"""
nodeSet = keySharedNodes
A, B, C, D = nodeSet.nodes.values()
A, B, C, D = txnPoolNodeSet

# B sends more than 2 nominations
for i in range(3):
Expand All @@ -26,5 +25,5 @@ def chk():
for node in A, C, D:
assert node.isNodeBlacklisted(B.name)

timeout = waits.expectedPoolNominationTimeout(len(nodeSet.nodes))
timeout = waits.expectedPoolNominationTimeout(len(txnPoolNodeSet))
looper.run(eventually(chk, retryWait=1, timeout=timeout))
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
# noinspection PyIncorrectDocstring
@pytest.mark.skip(reason="SOV-541. Implementation changed.")
def testBlacklistNodeOnMultiplePrimaryDeclarations(looper,
keySharedNodes,
ready):
txnPoolNodeSet):
"""
A node that sends multiple primary declarations must be blacklisted by
other nodes
"""
nodeSet = keySharedNodes
A, B, C, D = nodeSet.nodes.values()
A, B, C, D = txnPoolNodeSet

# B sends more than 2 primary declarations
for i in range(3):
Expand All @@ -30,5 +28,5 @@ def chk():
for node in A, C, D:
assert node.isNodeBlacklisted(B.name)

timeout = waits.expectedPoolNominationTimeout(len(nodeSet.nodes))
timeout = waits.expectedPoolNominationTimeout(len(txnPoolNodeSet))
looper.run(eventually(chk, retryWait=1, timeout=timeout))
1 change: 0 additions & 1 deletion plenum/test/bls/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from plenum.common.constants import DOMAIN_LEDGER_ID
from plenum.common.util import get_utc_epoch
from plenum.test.bls.helper import generate_state_root
from plenum.test.pool_transactions.conftest import looper

participants = ["Node1", "Node2", "Node3"]
signature = "somefakesignaturesomefakesignaturesomefakesignature"
Expand Down
39 changes: 39 additions & 0 deletions plenum/test/bls/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,45 @@ def sdk_check_bls_multi_sig_after_send(looper, txnPoolNodeSet,
assert multi_sigs.count(multi_sigs[0]) == len(multi_sigs)


def sdk_check_bls_multi_sig_after_send(looper, txnPoolNodeSet,
sdk_pool_handle, sdk_wallet_handle,
saved_multi_sigs_count):
# at least two because first request could have no
# signature since state can be clear
number_of_requests = 3

# 1. send requests
# Using loop to avoid 3pc batching
state_roots = []
for i in range(number_of_requests):
sdk_send_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_handle, 1)
waitNodeDataEquality(looper, txnPoolNodeSet[0], *txnPoolNodeSet[:-1])
state_roots.append(
state_roots_serializer.serialize(
bytes(txnPoolNodeSet[0].getState(DOMAIN_LEDGER_ID).committedHeadHash)))

# 2. get all saved multi-sigs
multi_sigs_for_batch = []
for state_root in state_roots:
multi_sigs = []
for node in txnPoolNodeSet:
multi_sig = node.bls_bft.bls_store.get(state_root)
if multi_sig:
multi_sigs.append(multi_sig)
multi_sigs_for_batch.append(multi_sigs)

# 3. check how many multi-sigs are saved
for multi_sigs in multi_sigs_for_batch:
assert len(multi_sigs) == saved_multi_sigs_count, \
"{} != {}".format(len(multi_sigs), saved_multi_sigs_count)

# 3. check that bls multi-sig is the same for all nodes we get PrePrepare for (that is for all expect the last one)
for multi_sigs in multi_sigs_for_batch[:-1]:
if multi_sigs:
assert multi_sigs.count(multi_sigs[0]) == len(multi_sigs)


def process_commits_for_key(key, pre_prepare, bls_bfts):
for sender_bls_bft in bls_bfts:
commit = create_commit_bls_sig(
Expand Down
1 change: 0 additions & 1 deletion plenum/test/bls/test_make_proof.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from base58 import b58encode
from plenum.test.pool_transactions.conftest import looper
from plenum.test.helper import sdk_send_random_and_check
from plenum.common.types import f
from plenum.common.constants import ROOT_HASH
Expand Down
3 changes: 0 additions & 3 deletions plenum/test/checkpoints/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pytest

from plenum.test.conftest import getValueFromModule
from plenum.test.pool_transactions.conftest import clientAndWallet1, \
client1, wallet1, client1Connected, looper, nodeThetaAdded, \
stewardAndWallet1, steward1, stewardWallet
from plenum.test.batching_3pc.conftest import tconf


Expand Down
4 changes: 2 additions & 2 deletions plenum/test/checkpoints/helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from plenum.test.helper import assertEquality


def chkChkpoints(nodes, total: int, stableIndex: int=None):
def chkChkpoints(nodes, total: int, stableIndex: int = None):
for node in nodes:
for r in node.replicas:
assert len(r.checkpoints) == total, '{} checkpoints {}, whereas total {}'.\
assert len(r.checkpoints) == total, '{} checkpoints {}, whereas total {}'. \
format(r, len(r.checkpoints), total)
if stableIndex is not None:
assert r.checkpoints.values()[stableIndex].isStable, r.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

def test_upper_bound_of_checkpoint_after_catchup_is_divisible_by_chk_freq(
chkFreqPatched, looper, txnPoolNodeSet, steward1, stewardWallet,
client1, wallet1, client1Connected, tdir, client_tdir, tconf,
client1, wallet1, tdir, client_tdir, tconf,
allPluginsPath):

sendReqsToNodesAndVerifySuffReplies(looper, wallet1, client1, 4)

_, _, epsilon = addNewStewardAndNode(looper, steward1, stewardWallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

def test_second_checkpoint_after_catchup_can_be_stabilized(
chkFreqPatched, looper, txnPoolNodeSet, steward1, stewardWallet,
client1, wallet1, client1Connected, tdir, client_tdir, tconf,
client1, wallet1, tdir, client_tdir, tconf,
allPluginsPath):

_, _, epsilon = addNewStewardAndNode(looper, steward1, stewardWallet,
'EpsilonSteward', 'Epsilon',
tdir, client_tdir, tconf,
Expand Down
1 change: 1 addition & 0 deletions plenum/test/checkpoints/test_message_outside_watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
CHK_FREQ = 5
LOG_SIZE = 3 * CHK_FREQ


def test_non_primary_recvs_3phase_message_outside_watermarks(chkFreqPatched, looper, txnPoolNodeSet, sdk_pool_handle,
sdk_wallet_client, reqs_for_logsize):
"""
Expand Down
1 change: 0 additions & 1 deletion plenum/test/checkpoints/test_message_outside_watermark1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from plenum.test.view_change.conftest import perf_chk_patched
from plenum.test.helper import sdk_send_random_and_check


TestRunningTimeLimitSec = 300
PerfCheckFreq = 30

Expand Down
1 change: 0 additions & 1 deletion plenum/test/checkpoints/test_ordering_after_catchup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

def add_new_node(looper, pool_nodes, steward, steward_wallet,
tdir, client_tdir, tconf, all_plugins_path):

name = randomString(6)
node_name = "Node-" + name
new_steward_name = "Steward-" + name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from stp_core.loop.eventually import eventually
from plenum.test.helper import sdk_send_batches_of_random_and_check


CHK_FREQ = 5


Expand Down
3 changes: 3 additions & 0 deletions plenum/test/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def createAllNodes(request, cli):
def stopNodes():
for node in cli.nodes.values():
node.stop()

request.addfinalizer(stopNodes)


Expand All @@ -85,8 +86,10 @@ def be(ctx):
Fixture that is a 'be' function that closes over the test context.
'be' allows to change the current cli in the context.
"""

def _(cli):
ctx['current_cli'] = cli

return _


Expand Down
Loading

0 comments on commit 65dae3a

Please sign in to comment.