Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RC 0.9.14 #272

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
from sovtoken.exceptions import UTXOError

from indy_common.authorize.auth_actions import AuthActionAdd
from sovtoken.constants import INPUTS, OUTPUTS, XFER_PUBLIC, TOKEN_LEDGER_ID, UTXO_CACHE_LABEL
from sovtoken.constants import INPUTS, OUTPUTS, XFER_PUBLIC, TOKEN_LEDGER_ID, UTXO_CACHE_LABEL, SIGS
from sovtoken.messages.txn_validator import txn_xfer_public_validate
from sovtoken.request_handlers.token_utils import spend_input, add_new_output, sum_inputs, sum_outputs, \
validate_given_inputs_outputs
from sovtoken.types import Output

from plenum.common.constants import ED25519
from plenum.common.exceptions import InvalidClientMessageException, InvalidClientRequest, OperationError
from plenum.common.request import Request
from plenum.common.txn_util import get_payload_data, get_seq_no
from plenum.common.txn_util import get_payload_data, get_seq_no, add_sigs_to_txn
from plenum.server.database_manager import DatabaseManager
from plenum.server.request_handlers.handler_interfaces.write_request_handler import WriteRequestHandler

Expand Down Expand Up @@ -63,6 +64,14 @@ def update_state(self, txn, prev_result, request, is_committed=False):
error = 'Exception {} while updating state'.format(ex)
raise OperationError(error)

def _req_to_txn(self, req: Request):
sigs = req.operation.pop(SIGS)
txn = super()._req_to_txn(req)
req.operation[SIGS] = sigs
sigs = [(i["address"], s) for i, s in zip(req.operation[INPUTS], sigs)]
add_sigs_to_txn(txn, sigs, sig_type=ED25519)
return txn

def _do_validate_inputs_ouputs(self, request):
try:
sum_in = sum_inputs(self.utxo_cache,
Expand Down
29 changes: 28 additions & 1 deletion sovtoken/sovtoken/test/test_public_xfer_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from plenum.common.txn_util import get_seq_no
from plenum.common.exceptions import RequestNackedException
from plenum.common.types import OPERATION
from sovtoken.constants import SIGS, ADDRESS, SEQNO, AMOUNT, OUTPUTS, PAYMENT_ADDRESS
from sovtoken.constants import SIGS, ADDRESS, SEQNO, AMOUNT, OUTPUTS, PAYMENT_ADDRESS, INPUTS
from sovtoken.test.helper import user1_token_wallet


Expand Down Expand Up @@ -287,3 +287,30 @@ def test_multiple_inputs_outputs_with_change(
assert address5_utxos[1][PAYMENT_ADDRESS] == address5
assert address5_utxos[0][AMOUNT] == 100
assert address5_utxos[1][AMOUNT] == 10


def test_xfer_signatures_included_in_txn(
helpers,
addresses,
initial_mint
):
[address1, address2, address3, address4, address5] = addresses

inputs = helpers.general.get_utxo_addresses([address1, address2, address3])
inputs = [utxo for utxos in inputs for utxo in utxos]

outputs = [
{"address": address4, "amount": 200},
{"address": address5, "amount": 100},
]

request = helpers.request.transfer(inputs, outputs)
response = helpers.sdk.send_and_check_request_objects([request])

sigs = [(i["address"], s) for i, s in zip(request.operation[INPUTS], request.operation[SIGS])]
request = response[0][0]
sigs.append((request["identifier"], request["signature"]))

rep_sigs = [(v['from'], v['value']) for v in response[0][1]["result"]["reqSignature"]["values"]]

assert sorted(rep_sigs) == sorted(sigs)