Exemple #1
0
def give_toybox(event):
    from websauna.wallet.tests.eth.utils import send_balance_to_address, do_faux_deposit

    user = event.user

    toybox = get_toy_box(event.network)
    if not toybox:
        return

    amount = event.network.other_data["initial_assets"].get("toybox_amount")
    if not amount:
        return

    if not event.web3:
        # MockEthreumService test shortcut
        dbsession = Session.object_session(event.address)
        network = event.address.network
        house_holdings = get_house_holdings(toybox)
        op = do_faux_deposit(event.address, house_holdings.account.asset.id, Decimal(amount))
    else:
        # Generate initial operation to supply the user
        house_holdings = get_house_holdings(toybox)
        op = house_holdings.withdraw(Decimal(amount), event.address.address, "Starter assets for user {}".format(user.friendly_name))

        # Generate op.id
        dbsession = Session.object_session(user)
        dbsession.flush()

    assert op.id

    # Record this operation in user data so we can verify it later
    op_txs = user.user_data.get("starter_asset_txs", [])
    op_txs.append({"toybox": str(op.id)})
    user.user_data["starter_asset_txs"] = op_txs
Exemple #2
0
def setup_toybox(request):
    """Setup TOYBOX asset for testing."""

    print("Setting up TOYBOX asset")

    dbsession = request.dbsession
    network = get_eth_network(dbsession, "testnet")
    toybox = get_toy_box(network)
    if toybox:
        return

    # Roll out toybox contract
    asset = create_token(network, "Toybox", "TOYBOX", 10222333, get_house_address(network))

    # setup toybox give away data for primary network
    network.other_data["initial_assets"]["toybox"] = str(asset.id)
    network.other_data["initial_assets"]["toybox_amount"] = 50
def setup_toybox(request):
    """Setup TOYBOX asset for testing."""

    print("Setting up TOYBOX asset")

    dbsession = request.dbsession
    network = get_eth_network(dbsession, "testnet")
    toybox = get_toy_box(network)
    if toybox:
        return

    # Roll out toybox contract
    asset = create_token(network, "Toybox", "TOYBOX", 10222333, get_house_address(network))

    # setup toybox give away data for primary network
    network.other_data["initial_assets"]["toybox"] = str(asset.id)
    network.other_data["initial_assets"]["toybox_amount"] = 50