Skip to content

Commit 9eab129

Browse files
dsurninashcherbakov
dsurnin
authored andcommitted
File struct (#396)
* fix serialization in JsonSerializer (#393) * Add base dir to Client constructor in tests * Fix code validation
1 parent 76b9e79 commit 9eab129

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

common/serializers/json_serializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def encode(self, o):
3838
if isinstance(o, (bytes, bytearray)):
3939
return '"{}"'.format(base64.b64encode(o).decode("utf-8"))
4040
else:
41-
return json.JSONEncoder.encode(self, o)
41+
return super().encode(o)
4242

4343
JsonEncoder = OrderedJsonEncoder()
4444

plenum/common/script_helper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,20 @@ def __checkClientConnected(cli, ):
241241

242242

243243
def changeHA(looper, config, nodeName, nodeSeed, newNodeHA,
244-
stewardName, stewardsSeed, newClientHA=None):
244+
stewardName, stewardsSeed, newClientHA=None, basedir=None):
245245
if not newClientHA:
246246
newClientHA = HA(newNodeHA.host, newNodeHA.port + 1)
247247

248+
assert basedir is not None
249+
248250
# prepare steward wallet
249251
stewardSigner = SimpleSigner(seed=stewardsSeed)
250252
stewardWallet = Wallet(stewardName)
251253
stewardWallet.addIdentifier(signer=stewardSigner)
252254

253255
# prepare client to submit change ha request
254256
_, randomClientPort = genHa()
255-
client = Client(stewardName,
256-
ha=('0.0.0.0', randomClientPort), config=config)
257+
client = Client(stewardName, ha=('0.0.0.0', randomClientPort), config=config, basedirpath=basedir)
257258
looper.add(client)
258259
timeout = waits.expectedClientToPoolConnectionTimeout(4)
259260
looper.run(eventually(__checkClientConnected, client,

plenum/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
GENERAL_CONFIG_DIR = '/etc/plenum/'
3434
# walletDir = 'wallet'
3535

36-
# it should be filled from baseConfig
36+
# it should be filled from baseConfig
3737
NETWORK_NAME = ''
3838

3939
GENERAL_CONFIG_FILE = 'plenum_config.py'

plenum/test/script/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def looper(txnPoolNodesLooper):
2424

2525

2626
def changeNodeHa(looper, txnPoolNodeSet, tdirWithPoolTxns,
27-
poolTxnData, poolTxnStewardNames, tconf, shouldBePrimary):
27+
poolTxnData, poolTxnStewardNames, tconf, shouldBePrimary, tdir):
2828

2929
# prepare new ha for node and client stack
3030
subjectedNode = None
@@ -46,7 +46,7 @@ def changeNodeHa(looper, txnPoolNodeSet, tdirWithPoolTxns,
4646

4747
# change HA
4848
stewardClient, req = changeHA(looper, tconf, subjectedNode.name, nodeSeed,
49-
nodeStackNewHA, stewardName, stewardsSeed)
49+
nodeStackNewHA, stewardName, stewardsSeed, basedir=tdir)
5050

5151
waitForSufficientRepliesForRequests(looper, stewardClient,
5252
requests=[req])

plenum/test/script/test_change_non_primary_node_ha.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
@pytest.mark.skipif('sys.platform == "win32"', reason='SOV-330')
1717
def testChangeNodeHaForNonPrimary(looper, txnPoolNodeSet, tdirWithPoolTxns,
18-
poolTxnData, poolTxnStewardNames, tconf):
18+
poolTxnData, poolTxnStewardNames, tconf, tdir):
1919

2020
changeNodeHa(looper,
2121
txnPoolNodeSet,
2222
tdirWithPoolTxns,
2323
poolTxnData,
2424
poolTxnStewardNames,
2525
tconf,
26-
shouldBePrimary=False)
26+
shouldBePrimary=False,
27+
tdir=tdir)

plenum/test/script/test_change_primary_node_ha.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
@pytest.mark.skipif('sys.platform == "win32"', reason='SOV-330')
1717
def testChangeNodeHaForPrimary(looper, txnPoolNodeSet, tdirWithPoolTxns,
18-
poolTxnData, poolTxnStewardNames, tconf):
18+
poolTxnData, poolTxnStewardNames, tconf, tdir):
1919
changeNodeHa(looper,
2020
txnPoolNodeSet,
2121
tdirWithPoolTxns,
2222
poolTxnData,
2323
poolTxnStewardNames,
2424
tconf,
25-
shouldBePrimary=True)
25+
shouldBePrimary=True,
26+
tdir=tdir)

0 commit comments

Comments
 (0)