mirror of
https://github.com/planetmint/planetmint.git
synced 2025-06-14 18:26:35 +00:00
fixed api test case
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
921e604724
commit
38711cf43a
@ -66,7 +66,7 @@ class DataAccessor:
|
|||||||
def get_outputs_by_tx_id(self, txid):
|
def get_outputs_by_tx_id(self, txid):
|
||||||
return backend.query.get_outputs_by_tx_id(self.connection, txid)
|
return backend.query.get_outputs_by_tx_id(self.connection, txid)
|
||||||
|
|
||||||
def get_outputs_filtered(self, owner, spent=None):
|
def get_outputs_filtered(self, owner, spent=None) -> list[Output]:
|
||||||
"""Get a list of output links filtered on some criteria
|
"""Get a list of output links filtered on some criteria
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -81,9 +81,7 @@ class DataAccessor:
|
|||||||
"""
|
"""
|
||||||
outputs = backend.query.get_outputs_by_owner(self.connection, owner)
|
outputs = backend.query.get_outputs_by_owner(self.connection, owner)
|
||||||
unspent_outputs = backend.query.get_outputs_by_owner(self.connection, owner, TARANT_TABLE_UTXOS)
|
unspent_outputs = backend.query.get_outputs_by_owner(self.connection, owner, TARANT_TABLE_UTXOS)
|
||||||
if spent is None:
|
if spent is True:
|
||||||
return outputs
|
|
||||||
elif spent is True:
|
|
||||||
spent_outputs = []
|
spent_outputs = []
|
||||||
for output in outputs:
|
for output in outputs:
|
||||||
if not any(
|
if not any(
|
||||||
@ -94,6 +92,7 @@ class DataAccessor:
|
|||||||
return unspent_outputs
|
return unspent_outputs
|
||||||
elif spent is False:
|
elif spent is False:
|
||||||
return unspent_outputs
|
return unspent_outputs
|
||||||
|
return outputs
|
||||||
|
|
||||||
def store_block(self, block):
|
def store_block(self, block):
|
||||||
"""Create a new block."""
|
"""Create a new block."""
|
||||||
|
@ -104,14 +104,15 @@ class TestTransactionValidation(object):
|
|||||||
def test_non_create_valid_input_wrong_owner(self, b, user_pk):
|
def test_non_create_valid_input_wrong_owner(self, b, user_pk):
|
||||||
from transactions.common.crypto import generate_key_pair
|
from transactions.common.crypto import generate_key_pair
|
||||||
from transactions.common.exceptions import InvalidSignature
|
from transactions.common.exceptions import InvalidSignature
|
||||||
|
from transactions.common.transaction_link import TransactionLink
|
||||||
|
|
||||||
input_tx = b.models.fastquery.get_outputs_by_public_key(user_pk).pop()
|
output = b.models.get_outputs_filtered(user_pk).pop()
|
||||||
input_transaction = b.models.get_transaction(input_tx.txid)
|
input_transaction = b.models.get_transaction(output.transaction_id)
|
||||||
sk, pk = generate_key_pair()
|
sk, pk = generate_key_pair()
|
||||||
tx = Create.generate([pk], [([user_pk], 1)])
|
tx = Create.generate([pk], [([user_pk], 1)])
|
||||||
tx.operation = "TRANSFER"
|
tx.operation = "TRANSFER"
|
||||||
tx.assets = [{"id": input_transaction.id}]
|
tx.assets = [{"id": input_transaction.id}]
|
||||||
tx.inputs[0].fulfills = input_tx
|
tx.inputs[0].fulfills = TransactionLink(output.transaction_id, output.index)
|
||||||
|
|
||||||
with pytest.raises(InvalidSignature):
|
with pytest.raises(InvalidSignature):
|
||||||
b.validate_transaction(tx)
|
b.validate_transaction(tx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user