Exemplo n.º 1
0
# Pays

pay = goal.pay(goal.account, receiver=joe, amt=10000)  # under min balance
txid, err = goal.send(pay, confirm=False)              # errors early
assert err

pay = goal.pay(goal.account, receiver=joe, amt=500_000)
txinfo, err = goal.send(pay)
assert not err, err
tx = txinfo['txn']['txn']
assert tx['amt'] == 500_000
assert tx['fee'] == 1000
assert goal.balance(joe) == 500_000

# Asset creation
acfg = goal.acfg(joe,
                 total=10_000, unit_name='oz', asset_name='Gold',
                 freeze=flo)
txinfo, err = goal.send(acfg)
assert not err, err
gold = txinfo['asset-index']
assert goal.balance(joe, gold) == 10_000

# Asset transfer
axfer = goal.axfer(joe, goal.account, 50, gold)
txinfo, err = goal.send(axfer)
assert err
assert goal.balance(joe, gold) == 10_000

optin = goal.axfer(goal.account, goal.account, 0, gold)
txinfo, err = goal.send(optin)
assert not err, err
Exemplo n.º 2
0
    expected_goal_mb + APP_MIN_BALANCE,
    goal_only=True,
)
expected_goal_mb += APP_MIN_BALANCE

# joe opts into Gold and Silver:
txinfo, err = goal.axfer(joe, joe, 0, assets["Gold"], send=True)
txinfo, err = goal.axfer(joe, joe, 0, assets["Silver"], send=True)
assert not err, err

expected_mb = CONSENSUS_MIN_BALANCE + 2 * ASSET_MIN_BALANCE
expected_goal_mb += APP_MIN_BALANCE
assert_min_balance(goal, joe, expected_mb, expected_goal_mb)

# next, destroy Gold and Silver
txinfo, err = goal.acfg(flo, index=assets["Gold"], send=True)
assert not err, err
expected_mb = CONSENSUS_MIN_BALANCE
expected_goal_mb += APP_MIN_BALANCE
assert_min_balance(goal, flo, expected_mb, expected_goal_mb)

txinfo, err = goal.acfg(goal.account, index=assets["Silver"], send=True)
assert not err, err
expected_goal_mb -= ASSET_MIN_BALANCE
assert_min_balance(
    goal,
    goal.account,
    expected_goal_mb,
    expected_goal_mb + APP_MIN_BALANCE,
    goal_only=True,
)