예제 #1
0
def test_issuance(logger, dbsession, web3, private_key_hex):
    """Walk through issuance process from top to bottom"""

    # Creating transactions
    txs = deploy_token_contracts(logger, dbsession, "testing", web3,
                           ethereum_abi_file=None,
                           ethereum_private_key=private_key_hex,
                           ethereum_gas_limit=None,
                           ethereum_gas_price=None,
                           name="Moo Corp",
                           symbol="MOO",
                           amount=9999,
                           transfer_restriction="unrestricted")
    assert len(txs) == 5

    # Send transactions to emphmereal test chain
    txs = broadcast(logger,
                    dbsession,
                    "testing",
                    web3,
                   ethereum_private_key=private_key_hex,
                   ethereum_gas_limit=None,
                   ethereum_gas_price=None,
                   )
    assert len(txs) == 5

    # Check they got mined
    txs = update_status(logger,
                    dbsession,
                    "testing",
                    web3,
                   ethereum_private_key=private_key_hex,
                   ethereum_gas_limit=None,
                   ethereum_gas_price=None,
                   )
    assert len(txs) == 5
    for tx in txs:  # type: PreparedTransaction
        assert tx.result_transaction_success

    token_address = txs[0].contract_address

    # Check that we can view the token status
    status = contract_status(logger,
                    dbsession,
                    "testing",
                    web3,
                    ethereum_abi_file=None,
                    ethereum_private_key=private_key_hex,
                    ethereum_gas_limit=None,
                    ethereum_gas_price=None,
                    token_contract=token_address,
                    )

    assert status["name"] == "Moo Corp"
    assert status["totalSupply"] == 9999 * 10**18
예제 #2
0
def sample_token(logger, dbsession, web3, private_key_hex, sample_csv_file,
                 db_path, click_runner, get_contract_deployed_tx, kyc_contract,
                 monkeypatch_get_contract_deployed_tx, request):
    """Create a security token used in these tests."""
    if request.param == 'restricted':
        from sto.ethereum.utils import priv_key_to_address
        # whitelist owner
        result = click_runner.invoke(cli, [
            '--database-file', db_path, '--ethereum-private-key',
            private_key_hex, '--ethereum-gas-limit', 999999999, 'kyc-manage',
            '--whitelist-address',
            priv_key_to_address(private_key_hex)
        ])
        assert result.exit_code == 0

    result = click_runner.invoke(cli, [
        '--database-file', db_path, '--ethereum-private-key', private_key_hex,
        '--ethereum-gas-limit', 999999999, 'issue', '--name', "Moo Corp",
        '--symbol', "MOO", '--url', "https://tokenmarket.net", '--amount',
        9999, '--transfer-restriction', request.param
    ])

    assert result.exit_code == 0
    result = click_runner.invoke(cli, [
        '--database-file',
        db_path,
        '--ethereum-private-key',
        private_key_hex,
        '--ethereum-gas-limit',
        999999999,
        'tx-broadcast',
    ])
    assert result.exit_code == 0

    token_address = get_contract_deployed_tx(dbsession,
                                             "SecurityToken").contract_address

    # Check that we can view the token status
    status = contract_status(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_abi_file=None,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
        token_contract=token_address,
    )

    assert status["name"] == "Moo Corp"
    assert status["totalSupply"] == 9999 * 10**18
    dbsession.commit()

    return token_address
예제 #3
0
파일: main.py 프로젝트: uivlis/sto
def status(config: BoardCommmadConfiguration, address):
    """Print token contract status."""

    logger = config.logger

    assert is_ethereum_network(config.network)  # Nothing else implemented yet

    from sto.ethereum.issuance import contract_status

    dbsession = config.dbsession

    contract_status(logger,
                    dbsession,
                    config.network,
                    ethereum_node_url=config.ethereum_node_url,
                    ethereum_abi_file=config.ethereum_abi_file,
                    ethereum_private_key=config.ethereum_private_key,
                    ethereum_gas_limit=config.ethereum_gas_limit,
                    ethereum_gas_price=config.ethereum_gas_price,
                    token_contract=address)
예제 #4
0
def sample_token(logger, dbsession, web3, private_key_hex, sample_csv_file):
    """Create a security token used in these tests."""

    # Creating transactions
    txs = deploy_token_contracts(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_abi_file=None,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=9999999,
        ethereum_gas_price=None,
        name="Moo Corp",
        symbol="MOO",
        url="https://tokenmarket.net",
        amount=9999,
        transfer_restriction="unrestricted"
    )

    token_address = txs[0].contract_address

    # Deploy contract transactions to emphmereal test chain
    broadcast(logger,
              dbsession,
              "testing",
              web3,
              ethereum_private_key=private_key_hex,
              ethereum_gas_limit=None,
              ethereum_gas_price=None,
              )

    # Check that we can view the token status
    status = contract_status(logger,
                             dbsession,
                             "testing",
                             web3,
                             ethereum_abi_file=None,
                             ethereum_private_key=private_key_hex,
                             ethereum_gas_limit=None,
                             ethereum_gas_price=None,
                             token_contract=token_address,
                             )

    assert status["name"] == "Moo Corp"
    assert status["totalSupply"] == 9999 * 10 ** 18

    return token_address
예제 #5
0
파일: test_cli.py 프로젝트: uivlis/sto
def test_distribute(logger, dbsession, web3, private_key_hex, sample_csv_file):
    """Distribute tokens."""

    # Creating transactions
    txs = deploy_token_contracts(
       logger, dbsession, "testing", web3,
       ethereum_abi_file=None,
       ethereum_private_key=private_key_hex,
       ethereum_gas_limit=99999999,
       ethereum_gas_price=None,
       name="Moo Corp",
       symbol="MOO",
       url="https://tokenmarket.net",
       amount=9999,
       transfer_restriction="unrestricted"
    )

    token_address = txs[0].contract_address

    # Deploy contract transactions to emphmereal test chain
    broadcast(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
    )

    # Check that we can view the token status
    status = contract_status(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_abi_file=None,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
        token_contract=token_address,
    )

    assert status["name"] == "Moo Corp"
    assert status["totalSupply"] == 9999 * 10 ** 18

    entries = read_csv(logger, sample_csv_file)

    new_distributes, old_distributes = distribute_tokens(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_abi_file=None,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
        token_address=token_address,
        dists=entries
    )

    assert new_distributes == 2
    assert old_distributes == 0

    # Check they got mined
    # Send transactions to emphmereal test chain
    txs = broadcast(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
    )
    # Check they got mined
    txs = update_status(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
    )
    assert len(txs) == 6
    for tx in txs:  # type: PreparedTransaction
        assert tx.result_transaction_success

    # Check that rerun does not recreate txs
    new_distributes, old_distributes = distribute_tokens(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_abi_file=None,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
        token_address=token_address,
        dists=entries
    )

    assert new_distributes == 0
    assert old_distributes == 2