mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Implemented digital asset template for CREATE
.
Added tests
This commit is contained in:
parent
ffbf470c1a
commit
7abc25dd6b
0
tests/assets/__init__.py
Normal file
0
tests/assets/__init__.py
Normal file
19
tests/assets/conftest.py
Normal file
19
tests/assets/conftest.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
from ..db import conftest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def restore_config(request, node_config):
|
||||
from bigchaindb import config_utils
|
||||
config_utils.set_config(node_config)
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def setup_database(request, node_config):
|
||||
conftest.setup_database(request, node_config)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def cleanup_tables(request, node_config):
|
||||
conftest.cleanup_tables(request, node_config)
|
||||
|
28
tests/assets/test_digital_assets.py
Normal file
28
tests/assets/test_digital_assets.py
Normal file
@ -0,0 +1,28 @@
|
||||
import pytest
|
||||
from ..db.conftest import inputs
|
||||
|
||||
|
||||
def test_asset_creation(b, user_vk):
|
||||
data = {'msg': 'hello'}
|
||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE', data=data)
|
||||
tx_signed = b.sign_transaction(tx, b.me_private)
|
||||
|
||||
assert b.validate_transaction(tx_signed) == tx_signed
|
||||
assert tx_signed['transaction']['asset']['data'] == data
|
||||
assert tx_signed['transaction']['asset']['refillable'] is False
|
||||
assert tx_signed['transaction']['asset']['divisible'] is False
|
||||
assert tx_signed['transaction']['asset']['updatable'] is False
|
||||
assert tx_signed['transaction']['conditions'][0]['amount'] == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_asset_transfer(b, user_vk, user_sk):
|
||||
tx_input = b.get_owned_ids(user_vk).pop()
|
||||
tx_create = b.get_transaction(tx_input['txid'])
|
||||
tx_transfer = b.create_transaction(user_vk, user_vk, tx_input, 'TRANSFER')
|
||||
tx_transfer_signed = b.sign_transaction(tx_transfer, user_sk)
|
||||
|
||||
assert b.validate_transaction(tx_transfer_signed) == tx_transfer_signed
|
||||
assert tx_transfer_signed['transaction']['asset'] == tx_create['transaction']['asset']['id']
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user