mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
unitest for bug
This commit is contained in:
parent
4d1f103e87
commit
fde91624ca
@ -47,3 +47,68 @@ def test_get_outputs_endpoint_with_invalid_unspent(client, user_pk):
|
||||
res = client.get(OUTPUTS_ENDPOINT + params)
|
||||
assert expected == res.json
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_divisble_transactions_returns_500(b, client):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.common import crypto
|
||||
import json
|
||||
|
||||
TX_ENDPOINT = '/api/v1/transactions'
|
||||
|
||||
def mine(tx_list):
|
||||
block = b.create_block(tx_list)
|
||||
b.write_block(block)
|
||||
|
||||
# vote the block valid
|
||||
vote = b.vote(block.id, b.get_last_voted_block().id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
alice_priv, alice_pub = crypto.generate_key_pair()
|
||||
bob_priv, bob_pub = crypto.generate_key_pair()
|
||||
carly_priv, carly_pub = crypto.generate_key_pair()
|
||||
|
||||
create_tx = Transaction.create([alice_pub], [([alice_pub], 4)])
|
||||
create_tx.sign([alice_priv])
|
||||
|
||||
res = client.post(TX_ENDPOINT, data=json.dumps(create_tx.to_dict()))
|
||||
assert res.status_code == 202
|
||||
|
||||
mine([create_tx])
|
||||
|
||||
transfer_tx = Transaction.transfer(create_tx.to_inputs(),
|
||||
[([alice_pub], 3), ([bob_pub], 1)],
|
||||
asset_id=create_tx.id)
|
||||
transfer_tx.sign([alice_priv])
|
||||
|
||||
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
|
||||
assert res.status_code == 202
|
||||
|
||||
mine([transfer_tx])
|
||||
|
||||
transfer_tx_carly = Transaction.transfer([transfer_tx.to_inputs()[1]],
|
||||
[([carly_pub], 1)],
|
||||
asset_id=create_tx.id)
|
||||
transfer_tx_carly.sign([bob_priv])
|
||||
|
||||
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx_carly.to_dict()))
|
||||
assert res.status_code == 202
|
||||
|
||||
mine([transfer_tx_carly])
|
||||
|
||||
asset_id = create_tx.id
|
||||
|
||||
url = TX_ENDPOINT + "?asset_id=" + asset_id
|
||||
assert client.get(url).status_code == 200
|
||||
assert len(client.get(url).json) == 3
|
||||
|
||||
url = OUTPUTS_ENDPOINT + '?public_key=' + alice_pub
|
||||
assert client.get(url).status_code == 200
|
||||
|
||||
url = OUTPUTS_ENDPOINT + '?public_key=' + bob_pub
|
||||
assert client.get(url).status_code == 200
|
||||
|
||||
url = OUTPUTS_ENDPOINT + '?public_key=' + carly_pub
|
||||
assert client.get(url).status_code == 200
|
||||
|
Loading…
x
Reference in New Issue
Block a user