Skip to content

Commit

Permalink
INDY-156 POOL_UPGRADE txn unclear error message (hyperledger#197)
Browse files Browse the repository at this point in the history
* added test and modified handler

* removed test_configReqHandler.py

* changed to InvalidClientRequest

* fixed test
  • Loading branch information
hadleym authored and ashcherbakov committed Jul 6, 2017
1 parent 2f57d6a commit 2eca155
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Empty file added __init__.py
Empty file.
7 changes: 7 additions & 0 deletions sovrin_node/server/config_req_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def validate(self, req: Request, config=None):
status = self.upgrader.statusInLedger(req.operation.get(NAME),
req.operation.get(VERSION))

if status == START and action == START:
raise InvalidClientRequest(
req.identifier,
req.reqId,
"Upgrade '{}' is already scheduled".format(
req.operation.get(NAME)))

r, msg = Authoriser.authorised(POOL_UPGRADE, ACTION, originRole,
oldVal=status, newVal=action)
if not r:
Expand Down
8 changes: 7 additions & 1 deletion sovrin_node/test/upgrade/test_pool_upgrade_reject.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sovrin_client.test.helper import checkRejects, checkNacks
from sovrin_common.constants import CANCEL, \
ACTION
from sovrin_node.test.upgrade.helper import sendUpgrade, \
from sovrin_node.test.upgrade.helper import sendUpgrade, ensureUpgradeSent, \
bumpedVersion
from stp_core.loop.eventually import eventually

Expand Down Expand Up @@ -42,4 +42,10 @@ def testNonTrustyCannotCancelUpgrade(looper, validUpgradeSent,
looper.run(eventually(checkRejects, stClient, req.reqId,
'cannot do'))

def test_accept_then_reject_upgrade(looper, trustee, trusteeWallet, validUpgradeSent, validUpgrade):
validUpgrade2 = deepcopy(validUpgrade)
_, req = sendUpgrade(trustee, trusteeWallet, validUpgrade2)
timeout = plenumWaits.expectedReqNAckQuorumTime()
looper.run(eventually(checkRejects, trustee, req.reqId,
'InvalidClientRequest', retryWait=1, timeout=timeout))

0 comments on commit 2eca155

Please sign in to comment.