mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 15:35:45 +00:00
resolved linting issues
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
71e13709fa
commit
0d9102a03d
@ -48,16 +48,18 @@ def test_divisible_assets():
|
||||
# the description, Bob and Alice agree that each token can be used to ride
|
||||
# the bike for one hour.
|
||||
|
||||
bike_token = [{
|
||||
"data": multihash(
|
||||
marshal(
|
||||
{
|
||||
"token_for": {"bike": {"serial_number": 420420}},
|
||||
"description": "Time share token. Each token equals one hour of riding.",
|
||||
}
|
||||
)
|
||||
),
|
||||
}]
|
||||
bike_token = [
|
||||
{
|
||||
"data": multihash(
|
||||
marshal(
|
||||
{
|
||||
"token_for": {"bike": {"serial_number": 420420}},
|
||||
"description": "Time share token. Each token equals one hour of riding.",
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
||||
]
|
||||
|
||||
# She prepares a `CREATE` transaction and issues 10 tokens.
|
||||
# Here, Alice defines in a tuple that she wants to assign
|
||||
|
||||
@ -21,12 +21,14 @@ def test_basic():
|
||||
alice = generate_keypair()
|
||||
|
||||
# create a digital asset for Alice
|
||||
game_boy_token = [{
|
||||
"data": {
|
||||
"hash": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"storageID": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
},
|
||||
}]
|
||||
game_boy_token = [
|
||||
{
|
||||
"data": {
|
||||
"hash": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
"storageID": "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
# prepare the transaction with the digital asset and issue 10 tokens to bob
|
||||
prepared_creation_tx = pm_alpha.transactions.prepare(
|
||||
@ -37,7 +39,8 @@ def test_basic():
|
||||
},
|
||||
signers=alice.public_key,
|
||||
recipients=[([alice.public_key], 10)],
|
||||
assets=game_boy_token)
|
||||
assets=game_boy_token,
|
||||
)
|
||||
|
||||
# fulfill and send the transaction
|
||||
fulfilled_creation_tx = pm_alpha.transactions.fulfill(prepared_creation_tx, private_keys=alice.private_key)
|
||||
|
||||
@ -47,12 +47,14 @@ def test_divisible_assets():
|
||||
# the description, Bob and Alice agree that each token can be used to ride
|
||||
# the bike for one hour.
|
||||
|
||||
bike_token = [{
|
||||
"data": {
|
||||
"token_for": {"bike": {"serial_number": 420420}},
|
||||
"description": "Time share token. Each token equals one hour of riding.",
|
||||
},
|
||||
}]
|
||||
bike_token = [
|
||||
{
|
||||
"data": {
|
||||
"token_for": {"bike": {"serial_number": 420420}},
|
||||
"description": "Time share token. Each token equals one hour of riding.",
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
# She prepares a `CREATE` transaction and issues 10 tokens.
|
||||
# Here, Alice defines in a tuple that she wants to assign
|
||||
|
||||
@ -23,7 +23,9 @@ def test_double_create():
|
||||
results = queue.Queue()
|
||||
|
||||
tx = pm.transactions.fulfill(
|
||||
pm.transactions.prepare(operation="CREATE", signers=alice.public_key, assets=[{"data": {"uuid": str(uuid4())}}]),
|
||||
pm.transactions.prepare(
|
||||
operation="CREATE", signers=alice.public_key, assets=[{"data": {"uuid": str(uuid4())}}]
|
||||
),
|
||||
private_keys=alice.private_key,
|
||||
)
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@ def get_asset(conn, asset_id):
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
|
||||
# TODO: pass filter/projection in function call this is not the expected behaviour for a function called get_assets
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_assets(conn, asset_ids):
|
||||
|
||||
@ -153,13 +153,15 @@ def run_election_new_upsert_validator(args, planet):
|
||||
:return: election_id or `False` in case of failure
|
||||
"""
|
||||
|
||||
new_validator = [{
|
||||
"data": {
|
||||
"public_key": {"value": public_key_from_base64(args.public_key), "type": "ed25519-base16"},
|
||||
"power": args.power,
|
||||
"node_id": args.node_id,
|
||||
new_validator = [
|
||||
{
|
||||
"data": {
|
||||
"public_key": {"value": public_key_from_base64(args.public_key), "type": "ed25519-base16"},
|
||||
"power": args.power,
|
||||
"node_id": args.node_id,
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
|
||||
return create_new_election(args.sk, planet, ValidatorElection, new_validator)
|
||||
|
||||
|
||||
@ -250,15 +250,12 @@ class Planetmint(object):
|
||||
def get_transaction(self, transaction_id):
|
||||
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
||||
if transaction:
|
||||
# TODO: get_assets is used with transaction_id this will not work with the asset change
|
||||
# assets = backend.query.get_assets(self.connection, [transaction_id])
|
||||
assets = backend.query.get_assets(self.connection, [transaction_id])
|
||||
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||
# NOTE: assets must not be replaced for transfer transactions
|
||||
# TODO: check if this holds true for other tx types, some test cases connected to election and voting are still failing
|
||||
# NOTE: assets should be appended for all txs that define new assets otherwise the ids are already stored in tx
|
||||
# if transaction["operation"] != "TRANSFER" and transaction["operation"] != "VOTE" and assets:
|
||||
# transaction["assets"] = list(assets)
|
||||
# transaction["assets"] = [asset[0] for asset in assets]
|
||||
if transaction["operation"] != "TRANSFER" and transaction["operation"] != "VOTE" and assets:
|
||||
transaction["assets"] = assets[0][0]
|
||||
|
||||
if "metadata" not in transaction:
|
||||
metadata = metadata[0] if metadata else None
|
||||
|
||||
@ -17,14 +17,16 @@ def valid_txid(txid):
|
||||
return txid.lower()
|
||||
raise ValueError("Invalid hash")
|
||||
|
||||
|
||||
def valid_txid_list(txids):
|
||||
txids = txids.split(',')
|
||||
r = re.compile('^[a-fA-F0-9]{64}$')
|
||||
txids = txids.split(",")
|
||||
r = re.compile("^[a-fA-F0-9]{64}$")
|
||||
valid_txids = list(filter(r.match, txids))
|
||||
if not len(txids) == len(valid_txids):
|
||||
raise ValueError('List contains invalid hash')
|
||||
raise ValueError("List contains invalid hash")
|
||||
return [txid.lower() for txid in valid_txids]
|
||||
|
||||
|
||||
def valid_bool(val):
|
||||
val = val.lower()
|
||||
if val == "true":
|
||||
|
||||
@ -18,6 +18,7 @@ def test_asset_transfer(b, signed_create_tx, user_pk, user_sk):
|
||||
assert b.validate_transaction(tx_transfer_signed) == tx_transfer_signed
|
||||
assert tx_transfer_signed.assets[0]["id"] == signed_create_tx.id
|
||||
|
||||
|
||||
# NOTE: TO BE REMOVED BECAUSE V3.0 ALLOWS FOR MULTIPLE ASSETS THEREFOR MULTIPLE ASSET IDS
|
||||
# def test_validate_transfer_asset_id_mismatch(b, signed_create_tx, user_pk, user_sk):
|
||||
# from planetmint.transactions.common.exceptions import AssetIdMismatch
|
||||
|
||||
@ -709,7 +709,9 @@ def new_validator():
|
||||
power = 1
|
||||
node_id = "fake_node_id"
|
||||
|
||||
return [{"data": {"public_key": {"value": public_key, "type": "ed25519-base16"}, "power": power, "node_id": node_id}}]
|
||||
return [
|
||||
{"data": {"public_key": {"value": public_key, "type": "ed25519-base16"}, "power": power, "node_id": node_id}}
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -3,5 +3,7 @@ from transactions.types.elections.chain_migration_election import ChainMigration
|
||||
|
||||
def test_valid_migration_election(b_mock, node_key):
|
||||
voters = b_mock.get_recipients_list()
|
||||
election = ChainMigrationElection.generate([node_key.public_key], voters, [{"data": {}}], None).sign([node_key.private_key])
|
||||
election = ChainMigrationElection.generate([node_key.public_key], voters, [{"data": {}}], None).sign(
|
||||
[node_key.private_key]
|
||||
)
|
||||
assert b_mock.validate_election(election)
|
||||
|
||||
@ -287,7 +287,9 @@ def test_deliver_transfer_tx__double_spend_fails(b, init_chain_request):
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
assert result.code == OkCode
|
||||
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign([alice.private_key])
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign(
|
||||
[alice.private_key]
|
||||
)
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
|
||||
assert result.code == OkCode
|
||||
@ -337,7 +339,9 @@ def test_store_pre_commit_state_in_end_block(b, alice, init_chain_request):
|
||||
from planetmint.backend import query
|
||||
|
||||
tx = Create.generate(
|
||||
[alice.public_key], [([alice.public_key], 1)], assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}]
|
||||
[alice.public_key],
|
||||
[([alice.public_key], 1)],
|
||||
assets=[{"data": "QmaozNR7DZHQK1ZcU9p7QdrshMvXqWK6gpu5rmrkPdT3L4"}],
|
||||
).sign([alice.private_key])
|
||||
|
||||
app = App(b)
|
||||
@ -379,7 +383,9 @@ def test_rollback_pre_commit_state_after_crash(b):
|
||||
private_key = validators[0]["private_key"]
|
||||
voter_keys = [v["private_key"] for v in validators]
|
||||
|
||||
migration_election, votes = generate_election(b, ChainMigrationElection, public_key, private_key, [{"data": {}}], voter_keys)
|
||||
migration_election, votes = generate_election(
|
||||
b, ChainMigrationElection, public_key, private_key, [{"data": {}}], voter_keys
|
||||
)
|
||||
|
||||
total_votes = votes
|
||||
txs = [migration_election, *votes]
|
||||
|
||||
@ -117,7 +117,9 @@ def test_post_transaction_responses(tendermint_ws_url, b):
|
||||
code, message = b.write_transaction(tx, BROADCAST_TX_COMMIT)
|
||||
assert code == 202
|
||||
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign([alice.private_key])
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign(
|
||||
[alice.private_key]
|
||||
)
|
||||
|
||||
code, message = b.write_transaction(tx_transfer, BROADCAST_TX_COMMIT)
|
||||
assert code == 202
|
||||
|
||||
@ -35,23 +35,25 @@ def test_asset_is_separated_from_transaciton(b):
|
||||
alice = generate_key_pair()
|
||||
bob = generate_key_pair()
|
||||
|
||||
assets = [{
|
||||
"data": multihash(
|
||||
marshal(
|
||||
{
|
||||
"Never gonna": [
|
||||
"give you up",
|
||||
"let you down",
|
||||
"run around" "desert you",
|
||||
"make you cry",
|
||||
"say goodbye",
|
||||
"tell a lie",
|
||||
"hurt you",
|
||||
]
|
||||
}
|
||||
assets = [
|
||||
{
|
||||
"data": multihash(
|
||||
marshal(
|
||||
{
|
||||
"Never gonna": [
|
||||
"give you up",
|
||||
"let you down",
|
||||
"run around" "desert you",
|
||||
"make you cry",
|
||||
"say goodbye",
|
||||
"tell a lie",
|
||||
"hurt you",
|
||||
]
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
||||
tx = Create.generate([alice.public_key], [([bob.public_key], 1)], metadata=None, assets=assets).sign(
|
||||
[alice.private_key]
|
||||
@ -94,7 +96,9 @@ def test_validation_error(b):
|
||||
from transactions.common.crypto import generate_key_pair
|
||||
|
||||
alice = generate_key_pair()
|
||||
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
tx = (
|
||||
Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
)
|
||||
|
||||
tx["metadata"] = ""
|
||||
assert not b.validate_transaction(tx)
|
||||
@ -106,7 +110,9 @@ def test_write_and_post_transaction(mock_post, b):
|
||||
from planetmint.tendermint_utils import encode_transaction
|
||||
|
||||
alice = generate_key_pair()
|
||||
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
tx = (
|
||||
Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
)
|
||||
|
||||
tx = b.validate_transaction(tx)
|
||||
b.write_transaction(tx, BROADCAST_TX_ASYNC)
|
||||
@ -124,7 +130,9 @@ def test_post_transaction_valid_modes(mock_post, b, mode):
|
||||
from transactions.common.crypto import generate_key_pair
|
||||
|
||||
alice = generate_key_pair()
|
||||
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
tx = (
|
||||
Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
)
|
||||
tx = b.validate_transaction(tx)
|
||||
b.write_transaction(tx, mode)
|
||||
|
||||
@ -137,7 +145,9 @@ def test_post_transaction_invalid_mode(b):
|
||||
from transactions.common.exceptions import ValidationError
|
||||
|
||||
alice = generate_key_pair()
|
||||
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
tx = (
|
||||
Create.generate([alice.public_key], [([alice.public_key], 1)], assets=None).sign([alice.private_key]).to_dict()
|
||||
)
|
||||
tx = b.validate_transaction(tx)
|
||||
with pytest.raises(ValidationError):
|
||||
b.write_transaction(tx, "nope")
|
||||
@ -175,7 +185,13 @@ def test_store_transaction(mocker, b, signed_create_tx, signed_transfer_tx, db_c
|
||||
assert utxo["output_index"] == 0
|
||||
mocked_store_asset.assert_called_once_with(
|
||||
b.connection,
|
||||
[{"data": signed_create_tx.assets[0]["data"], "tx_id": signed_create_tx.id, "asset_ids": [signed_create_tx.id]}],
|
||||
[
|
||||
{
|
||||
"data": signed_create_tx.assets[0]["data"],
|
||||
"tx_id": signed_create_tx.id,
|
||||
"asset_ids": [signed_create_tx.id],
|
||||
}
|
||||
],
|
||||
)
|
||||
else:
|
||||
mocked_store_asset.assert_called_once_with(
|
||||
@ -410,7 +426,9 @@ def test_get_spent_transaction_critical_double_spend(b, alice, bob, carol):
|
||||
|
||||
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=assets).sign([alice.private_key])
|
||||
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign([alice.private_key])
|
||||
tx_transfer = Transfer.generate(tx.to_inputs(), [([bob.public_key], 1)], asset_ids=[tx.id]).sign(
|
||||
[alice.private_key]
|
||||
)
|
||||
|
||||
double_spend = Transfer.generate(tx.to_inputs(), [([carol.public_key], 1)], asset_ids=[tx.id]).sign(
|
||||
[alice.private_key]
|
||||
@ -447,8 +465,12 @@ def test_validation_with_transaction_buffer(b):
|
||||
priv_key, pub_key = generate_key_pair()
|
||||
|
||||
create_tx = Create.generate([pub_key], [([pub_key], 10)]).sign([priv_key])
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign([priv_key])
|
||||
double_spend = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign([priv_key])
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign(
|
||||
[priv_key]
|
||||
)
|
||||
double_spend = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign(
|
||||
[priv_key]
|
||||
)
|
||||
|
||||
assert b.is_valid_transaction(create_tx)
|
||||
assert b.is_valid_transaction(transfer_tx, [create_tx])
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
import subprocess
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
def test_build_root_docs():
|
||||
proc = subprocess.Popen(["bash"], stdin=subprocess.PIPE)
|
||||
|
||||
@ -17,7 +17,9 @@ def generate_create_and_transfer(keypair=None):
|
||||
keypair = generate_key_pair()
|
||||
priv_key, pub_key = keypair
|
||||
create_tx = Create.generate([pub_key], [([pub_key], 10)]).sign([priv_key])
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign([priv_key])
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([pub_key], 10)], asset_ids=[create_tx.id]).sign(
|
||||
[priv_key]
|
||||
)
|
||||
return create_tx, transfer_tx
|
||||
|
||||
|
||||
@ -27,9 +29,9 @@ def test_validation_worker_process_multiple_transactions(b):
|
||||
|
||||
keypair = generate_key_pair()
|
||||
create_tx, transfer_tx = generate_create_and_transfer(keypair)
|
||||
double_spend = Transfer.generate(create_tx.to_inputs(), [([keypair.public_key], 10)], asset_ids=[create_tx.id]).sign(
|
||||
[keypair.private_key]
|
||||
)
|
||||
double_spend = Transfer.generate(
|
||||
create_tx.to_inputs(), [([keypair.public_key], 10)], asset_ids=[create_tx.id]
|
||||
).sign([keypair.private_key])
|
||||
|
||||
in_queue, results_queue = mp.Queue(), mp.Queue()
|
||||
vw = ValidationWorker(in_queue, results_queue)
|
||||
|
||||
@ -30,9 +30,9 @@ def test_upsert_validator_valid_election_vote(b_mock, valid_upsert_validator_ele
|
||||
|
||||
election_pub_key = election_id_to_public_key(valid_upsert_validator_election.id)
|
||||
|
||||
vote = Vote.generate([input0], [([election_pub_key], votes)], election_ids=[valid_upsert_validator_election.id]).sign(
|
||||
[key0.private_key]
|
||||
)
|
||||
vote = Vote.generate(
|
||||
[input0], [([election_pub_key], votes)], election_ids=[valid_upsert_validator_election.id]
|
||||
).sign([key0.private_key])
|
||||
assert b_mock.validate_transaction(vote)
|
||||
|
||||
|
||||
@ -230,13 +230,15 @@ def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
|
||||
power = 1
|
||||
public_key = "9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403"
|
||||
public_key64 = public_key_to_base64(public_key)
|
||||
new_validator = [{
|
||||
"data": {
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
new_validator = [
|
||||
{
|
||||
"data": {
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
|
||||
voters = b.get_recipients_list()
|
||||
election = ValidatorElection.generate([node_key.public_key], voters, new_validator, None).sign(
|
||||
@ -272,13 +274,15 @@ def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys):
|
||||
power = 1
|
||||
public_key = "9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403"
|
||||
public_key64 = public_key_to_base64(public_key)
|
||||
new_validator = [{
|
||||
"data": {
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
new_validator = [
|
||||
{
|
||||
"data": {
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
voters = b.get_recipients_list()
|
||||
election = ValidatorElection.generate([node_key.public_key], voters, new_validator).sign([node_key.private_key])
|
||||
# store election
|
||||
@ -302,13 +306,15 @@ def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys):
|
||||
|
||||
# remove validator
|
||||
power = 0
|
||||
new_validator = [{
|
||||
"data":{
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
new_validator = [
|
||||
{
|
||||
"data": {
|
||||
"public_key": {"value": public_key, "type": "ed25519-base16"},
|
||||
"node_id": "some_node_id",
|
||||
"power": power,
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
voters = b.get_recipients_list()
|
||||
election = ValidatorElection.generate([node_key.public_key], voters, new_validator).sign([node_key.private_key])
|
||||
# store election
|
||||
|
||||
@ -74,7 +74,9 @@ def to_inputs(election, i, ed25519_node_keys):
|
||||
def gen_vote(election, i, ed25519_node_keys):
|
||||
(input_i, votes_i, key_i) = to_inputs(election, i, ed25519_node_keys)
|
||||
election_pub_key = election_id_to_public_key(election.id)
|
||||
return Vote.generate([input_i], [([election_pub_key], votes_i)], election_ids=[election.id]).sign([key_i.private_key])
|
||||
return Vote.generate([input_i], [([election_pub_key], votes_i)], election_ids=[election.id]).sign(
|
||||
[key_i.private_key]
|
||||
)
|
||||
|
||||
|
||||
def generate_validators(powers):
|
||||
@ -117,6 +119,7 @@ def generate_validators(powers):
|
||||
)
|
||||
return validators
|
||||
|
||||
|
||||
# NOTE: This works for some but not for all test cases check if this or code base needs fix
|
||||
def generate_election(b, cls, public_key, private_key, asset_data, voter_keys):
|
||||
voters = b.get_recipients_list()
|
||||
|
||||
@ -103,7 +103,9 @@ def test_get_divisble_transactions_returns_500(b, client):
|
||||
|
||||
mine([create_tx])
|
||||
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([alice_pub], 3), ([bob_pub], 1)], asset_ids=[create_tx.id])
|
||||
transfer_tx = Transfer.generate(
|
||||
create_tx.to_inputs(), [([alice_pub], 3), ([bob_pub], 1)], asset_ids=[create_tx.id]
|
||||
)
|
||||
transfer_tx.sign([alice_priv])
|
||||
|
||||
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
|
||||
|
||||
@ -365,7 +365,9 @@ def test_post_wrong_asset_division_transfer_returns_400(b, client, user_pk):
|
||||
res = client.post(TX_ENDPOINT + "?mode=commit", data=json.dumps(create_tx.to_dict()))
|
||||
assert res.status_code == 202
|
||||
|
||||
transfer_tx = Transfer.generate(create_tx.to_inputs(), [([pub_key], 20)], asset_ids=[create_tx.id]).sign( # 20 > 10
|
||||
transfer_tx = Transfer.generate(
|
||||
create_tx.to_inputs(), [([pub_key], 20)], asset_ids=[create_tx.id]
|
||||
).sign( # 20 > 10
|
||||
[priv_key]
|
||||
)
|
||||
res = client.post(TX_ENDPOINT + "?mode=commit", data=json.dumps(transfer_tx.to_dict()))
|
||||
@ -391,19 +393,19 @@ def test_transactions_get_list_good(client):
|
||||
asset_ids = ["1" * 64]
|
||||
|
||||
with patch("planetmint.Planetmint.get_transactions_filtered", get_txs_patched):
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ','.join(asset_ids)
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ",".join(asset_ids)
|
||||
assert client.get(url).json == [
|
||||
["asset_ids", asset_ids],
|
||||
["last_tx", None],
|
||||
["operation", None],
|
||||
]
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ','.join(asset_ids) + "&operation=CREATE"
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ",".join(asset_ids) + "&operation=CREATE"
|
||||
assert client.get(url).json == [
|
||||
["asset_ids", asset_ids],
|
||||
["last_tx", None],
|
||||
["operation", "CREATE"],
|
||||
]
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ','.join(asset_ids) + "&last_tx=true"
|
||||
url = TX_ENDPOINT + "?asset_ids=" + ",".join(asset_ids) + "&last_tx=true"
|
||||
assert client.get(url).json == [
|
||||
["asset_ids", asset_ids],
|
||||
["last_tx", True],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user