Skip to content

Commit 17f8c52

Browse files
rakanalhhackaugusto
authored andcommitted
Use to_hex instead of hex
1 parent d0ac116 commit 17f8c52

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

raiden/api/rest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import gevent
99
import gevent.pool
1010
import structlog
11-
from eth_utils import encode_hex, to_checksum_address
11+
from eth_utils import encode_hex, to_checksum_address, to_hex
1212
from flask import Flask, make_response, request, send_from_directory, url_for
1313
from flask.json import jsonify
1414
from flask_cors import CORS
@@ -1052,8 +1052,8 @@ def initiate_payment(
10521052
'target_address': target_address,
10531053
'amount': amount,
10541054
'identifier': identifier,
1055-
'secret': payment_status.secret.hex(),
1056-
'secret_hash': payment_status.secret_hash.hex(),
1055+
'secret': to_hex(payment_status.secret),
1056+
'secret_hash': to_hex(payment_status.secret_hash),
10571057
}
10581058
result = self.payment_schema.dump(payment)
10591059
return api_response(result=result.data)

raiden/tests/integration/api/test_restapi.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
import gevent
44
import grequests
55
import pytest
6-
from eth_utils import is_checksum_address, to_canonical_address, to_checksum_address
6+
from eth_utils import (
7+
is_checksum_address,
8+
to_bytes,
9+
to_canonical_address,
10+
to_checksum_address,
11+
to_hex,
12+
)
713
from flask import url_for
814

915
from raiden.api.v1.encoding import AddressField, HexAddressConverter
@@ -931,9 +937,11 @@ def test_api_payments(api_server_test_instance, raiden_network, token_addresses)
931937
assert response.items() >= payment.items()
932938
assert 'secret' in response
933939
assert 'secret_hash' in response
934-
assert len(response['secret']) == 64
935-
assert len(response['secret_hash']) == 64
936-
assert sha3(bytes.fromhex(response['secret'])).hex() == response['secret_hash']
940+
assert len(response['secret']) == 66
941+
assert len(response['secret_hash']) == 66
942+
943+
generated_secret_hash = to_hex(sha3(to_bytes(hexstr=response['secret'])))
944+
assert generated_secret_hash == response['secret_hash']
937945

938946

939947
def assert_payment_conflict(responses):

0 commit comments

Comments
 (0)