本文整理汇总了Python中bigchaindb.models.Transaction.get_asset_id方法的典型用法代码示例。如果您正苦于以下问题:Python Transaction.get_asset_id方法的具体用法?Python Transaction.get_asset_id怎么用?Python Transaction.get_asset_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bigchaindb.models.Transaction
的用法示例。
在下文中一共展示了Transaction.get_asset_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_asset_id_mismatch
# 需要导入模块: from bigchaindb.models import Transaction [as 别名]
# 或者: from bigchaindb.models.Transaction import get_asset_id [as 别名]
def test_asset_id_mismatch(alice, user_pk):
from bigchaindb.models import Transaction
from bigchaindb.common.exceptions import AssetIdMismatch
tx1 = Transaction.create([alice.public_key], [([user_pk], 1)],
metadata={'msg': random.random()})
tx1.sign([alice.private_key])
tx2 = Transaction.create([alice.public_key], [([user_pk], 1)],
metadata={'msg': random.random()})
tx2.sign([alice.private_key])
with pytest.raises(AssetIdMismatch):
Transaction.get_asset_id([tx1, tx2])
示例2: test_get_asset_id_transfer_transaction
# 需要导入模块: from bigchaindb.models import Transaction [as 别名]
# 或者: from bigchaindb.models.Transaction import get_asset_id [as 别名]
def test_get_asset_id_transfer_transaction(b, signed_create_tx, user_pk):
from bigchaindb.models import Transaction
tx_transfer = Transaction.transfer(signed_create_tx.to_inputs(), [([user_pk], 1)],
signed_create_tx.id)
asset_id = Transaction.get_asset_id(tx_transfer)
assert asset_id == tx_transfer.asset['id']
示例3: test_get_txids_filtered
# 需要导入模块: from bigchaindb.models import Transaction [as 别名]
# 或者: from bigchaindb.models.Transaction import get_asset_id [as 别名]
def test_get_txids_filtered(signed_create_tx, signed_transfer_tx):
from bigchaindb.backend import connect, query
from bigchaindb.models import Transaction
conn = connect()
# create and insert two blocks, one for the create and one for the
# transfer transaction
conn.db.transactions.insert_one(signed_create_tx.to_dict())
conn.db.transactions.insert_one(signed_transfer_tx.to_dict())
asset_id = Transaction.get_asset_id([signed_create_tx, signed_transfer_tx])
# Test get by just asset id
txids = set(query.get_txids_filtered(conn, asset_id))
assert txids == {signed_create_tx.id, signed_transfer_tx.id}
# Test get by asset and CREATE
txids = set(query.get_txids_filtered(conn, asset_id, Transaction.CREATE))
assert txids == {signed_create_tx.id}
# Test get by asset and TRANSFER
txids = set(query.get_txids_filtered(conn, asset_id, Transaction.TRANSFER))
assert txids == {signed_transfer_tx.id}
示例4: test_get_asset_id_create_transaction
# 需要导入模块: from bigchaindb.models import Transaction [as 别名]
# 或者: from bigchaindb.models.Transaction import get_asset_id [as 别名]
def test_get_asset_id_create_transaction(alice, user_pk):
from bigchaindb.models import Transaction
tx_create = Transaction.create([alice.public_key], [([user_pk], 1)])
assert Transaction.get_asset_id(tx_create) == tx_create.id