-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from KitHat/master
ST-600 & ST-601 -- remove utxo from state and limit the number of utxo's returned
- Loading branch information
Showing
18 changed files
with
144 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
sovtoken/sovtoken/test/req_handlers/get_utxo_req_handler/test_get_utxo_get_result.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import pytest | ||
from sovtoken.constants import OUTPUTS, ADDRESS | ||
from sovtoken.request_handlers.token_utils import create_state_key | ||
from sovtoken.test.helper import libsovtoken_address_to_address | ||
|
||
from plenum.common.constants import STATE_PROOF | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def add_utxo(payment_address, get_utxo_handler): | ||
get_utxo_handler.state.set(create_state_key(payment_address.replace("pay:sov:", ""), 1), "3".encode()) | ||
get_utxo_handler.state.set(create_state_key(libsovtoken_address_to_address(payment_address), 1), "3".encode()) | ||
|
||
|
||
def test_get_utxo_request_has_utxos(get_utxo_request, get_utxo_handler, payment_address, add_utxo): | ||
result = get_utxo_handler.get_result(get_utxo_request) | ||
assert result[STATE_PROOF] | ||
assert result[OUTPUTS] | ||
assert len(result[OUTPUTS]) == 1 | ||
assert result[OUTPUTS][0].address == payment_address.replace("pay:sov:", "") | ||
assert result[OUTPUTS][0].address == libsovtoken_address_to_address(payment_address) | ||
assert result[OUTPUTS][0].amount == 3 | ||
assert result[OUTPUTS][0].seqNo == 1 | ||
|
||
|
||
def test_get_utxo_request_no_utxos(get_utxo_request, get_utxo_handler, payment_address_2, add_utxo): | ||
get_utxo_request.operation[ADDRESS] = payment_address_2.replace("pay:sov:", "") | ||
get_utxo_request.operation[ADDRESS] = libsovtoken_address_to_address(payment_address_2) | ||
result = get_utxo_handler.get_result(get_utxo_request) | ||
assert result[STATE_PROOF] | ||
assert len(result[OUTPUTS]) == 0 |
15 changes: 15 additions & 0 deletions
15
...en/test/req_handlers/get_utxo_req_handler/test_get_utxo_get_result_big_number_of_utxos.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from sovtoken.constants import OUTPUTS | ||
from sovtoken.test.helper import libsovtoken_address_to_address | ||
|
||
from plenum.common.constants import STATE_PROOF | ||
|
||
|
||
def test_get_utxo_request_has_utxos(get_utxo_request, get_utxo_handler, payment_address, insert_over_thousand_utxos): | ||
result = get_utxo_handler.get_result(get_utxo_request) | ||
assert result[STATE_PROOF] | ||
assert result[OUTPUTS] | ||
assert len(result[OUTPUTS]) == 1000 | ||
for i in range(1000): | ||
assert result[OUTPUTS][i].address == libsovtoken_address_to_address(payment_address) | ||
assert result[OUTPUTS][i].seqNo == i | ||
assert result[OUTPUTS][i].amount == i |
6 changes: 4 additions & 2 deletions
6
sovtoken/sovtoken/test/req_handlers/mint_req_handler/test_mint_req_handler_update_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from sovtoken.test.helper import libsovtoken_address_to_address | ||
|
||
|
||
def test_mint_handler_update_state_valid_txn(mint_txn, mint_handler, payment_address): | ||
mint_handler.update_state(mint_txn, None, None, is_committed=True) | ||
|
||
token_state = mint_handler.state | ||
utxo_cache = mint_handler.database_manager.get_store("utxo_cache") | ||
|
||
assert int(token_state.get((payment_address[8:] + ":1").encode(), isCommitted=False)) == 10 | ||
assert utxo_cache.get(payment_address[8:].encode()).decode() == '1:10' | ||
assert int(token_state.get((libsovtoken_address_to_address(payment_address) + ":1").encode(), isCommitted=False)) == 10 | ||
assert utxo_cache.get(libsovtoken_address_to_address(payment_address).encode()).decode() == '1:10' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
sovtoken/sovtoken/test/req_handlers/xfer_req_handler/test_xfer_handler_update_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
from sovtoken.test.helper import libsovtoken_address_to_address | ||
|
||
|
||
def test_xfer_handler_update_state(xfer_handler, xfer_txn, payment_address_2): | ||
xfer_handler.update_state(xfer_txn, None, None) | ||
|
||
token_state = xfer_handler.state | ||
utxo_cache = xfer_handler.utxo_cache | ||
|
||
assert int(token_state.get((payment_address_2[8:] + ":2").encode(), isCommitted=False)) == 10 | ||
assert utxo_cache.get(payment_address_2[8:]) == '2:10' | ||
assert int(token_state.get((libsovtoken_address_to_address(payment_address_2) + ":2").encode(), isCommitted=False)) == 10 | ||
assert utxo_cache.get(libsovtoken_address_to_address(payment_address_2)) == '2:10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.