mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
PR review @r-marques
This commit is contained in:
parent
1fbb0ed4ba
commit
827e58bc75
@ -165,16 +165,14 @@ class Bigchain(object):
|
||||
if status != Bigchain.BLOCK_INVALID}
|
||||
if validity:
|
||||
|
||||
tx_status = self.TX_UNDECIDED
|
||||
# If the transaction is in a valid or any undecided block, return it. Does not check
|
||||
# if transactions in undecided blocks are consistent, but selects the valid block before
|
||||
# undecided ones
|
||||
for _id in validity:
|
||||
target_block_id = _id
|
||||
if validity[_id] == Bigchain.BLOCK_VALID:
|
||||
for target_block_id in validity:
|
||||
if validity[target_block_id] == Bigchain.BLOCK_VALID:
|
||||
tx_status = self.TX_VALID
|
||||
break
|
||||
else:
|
||||
tx_status = self.TX_UNDECIDED
|
||||
|
||||
# Query the transaction in the target block and return
|
||||
response = r.table('bigchain', read_mode=self.read_mode).get(target_block_id)\
|
||||
|
@ -114,7 +114,6 @@ class TestBigchainApi(object):
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
tx = b.create_transaction(user_vk, user_vk, input_tx, 'TRANSFER')
|
||||
tx_signed = b.sign_transaction(tx, user_sk)
|
||||
b.write_transaction(tx_signed)
|
||||
|
||||
# create block and write it to the bighcain before retrieving the transaction
|
||||
block = b.create_block([tx_signed])
|
||||
@ -123,7 +122,7 @@ class TestBigchainApi(object):
|
||||
response, status = b.get_transaction(tx_signed["id"], include_status=True)
|
||||
# add validity information, which will be returned
|
||||
assert util.serialize(tx_signed) == util.serialize(response)
|
||||
assert status == 'undecided'
|
||||
assert status == b.TX_UNDECIDED
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_read_transaction_backlog(self, b, user_vk, user_sk):
|
||||
@ -135,14 +134,13 @@ class TestBigchainApi(object):
|
||||
response, status = b.get_transaction(tx_signed["id"], include_status=True)
|
||||
# add validity information, which will be returned
|
||||
assert util.serialize(tx_signed) == util.serialize(response)
|
||||
assert status == 'backlog'
|
||||
assert status == b.TX_IN_BACKLOG
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_read_transaction_invalid_block(self, b, user_vk, user_sk):
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
tx = b.create_transaction(user_vk, user_vk, input_tx, 'TRANSFER')
|
||||
tx_signed = b.sign_transaction(tx, user_sk)
|
||||
b.write_transaction(tx_signed)
|
||||
|
||||
# create block
|
||||
block = b.create_block([tx_signed])
|
||||
@ -174,7 +172,7 @@ class TestBigchainApi(object):
|
||||
response, status = b.get_transaction(tx_signed["id"], include_status=True)
|
||||
# add validity information, which will be returned
|
||||
assert util.serialize(tx_signed) == util.serialize(response)
|
||||
assert status == 'valid'
|
||||
assert status == b.TX_VALID
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_assign_transaction_one_node(self, b, user_vk, user_sk):
|
||||
|
Loading…
x
Reference in New Issue
Block a user