def scenario1():
    m = ManticoreEVM()

    market = initialize(m,
                        parameters={'pr_fl': 10**6},
                        market_owner_token_balance=10**21)

    bob = init_user(m, market, 'bob', 100 * ONE_ETH)
    eve = init_user(m, market, 'eve', 100 * ONE_ETH)

    calls_support(market, [(eve, 1 * ONE_ETH), (bob, 10 * ONE_ETH)])

    market.reserve_contract.withdraw(caller=eve.account)
    print("[+] Eve called support")

    check_balance(m, market, eve)

    print(f"[+] Look for results in {m.workspace}")
示例#2
0
#arg_1 = ONE_GWEI
#arg_2 = 110
#arg_3 = ONE_ETH
#arg_4 = 1 #m.make_symbolic_value(name="stk")
#arg_5 = 1
#arg_6 = 1
#arg_7 = 25
#arg_8 = 50
#arg_9 = ONE_KWEI * 6

market_parameters['vote_by_d'] = 1
market_parameters['pl'] = 1
market_parameters['stk'] = 1

market = initialize(m, parameters=market_parameters)

backend_balance = 100 * ONE_ETH
backend_account = m.create_account(balance=backend_balance)
print("[+] Creating a backend account", hex(backend_account.address))

market.ether_token_contract.deposit(value=backend_balance,
                                    caller=backend_account)

market.ether_token_contract.approve(market.reserve_contract,
                                    backend_balance,
                                    caller=backend_account)
market.market_token_contract.approve(market.voting_contract,
                                     backend_balance,
                                     caller=backend_account)
solver = Z3Solver.instance()

from initialize_market import initialize
from constants import ONE_ETH
from backend_init import register_backend
from list import list

consts = config.get_group("evm")
consts.oog = "ignore"

# This script corresponds to issue #17 raised in the ToB audit
################ Script #######################

m = ManticoreEVM()

market = initialize(m, parameters={'cost': 101, 'back_p': 33, 'maker_p': 33})

backend_user = register_backend(m, market, [market.market_token_owner])

user_account = m.create_account(balance=1 * ONE_ETH)
print("[+] Creating a market owner account", hex(user_account.address))

market.ether_token_contract.deposit(value=1 * ONE_ETH, caller=user_account)

print("[+] Deposit called")

market.ether_token_contract.approve(market.datatrust_contract.address,
                                    1 * ONE_ETH,
                                    caller=user_account)
print("[+] Approve called")
示例#4
0
consts = config.get_group("evm")
consts.oog = "ignore"

# TODO(rbharath): This script fails to run, even though the delivery price freeze fix hasn't been merged...
################ Script #######################

m = ManticoreEVM()

market_parameters = DEFAULT_PARAMETERS
market_parameters['vote_by_d'] = 1
market_parameters['pl'] = 1
market_parameters['stk'] = 1
market_parameters['cost'] = 1

market = initialize(m,
                    parameters=market_parameters,
                    user_initial_eth_balance=100 * ONE_ETH)

backend_balance = 100 * ONE_ETH
backend_account = m.create_account(balance=backend_balance)
print("[+] Creating a backend account", hex(backend_account.address))

market.ether_token_contract.deposit(value=backend_balance,
                                    caller=backend_account)

market.ether_token_contract.approve(market.reserve_contract,
                                    backend_balance,
                                    caller=backend_account)
market.market_token_contract.approve(market.voting_contract,
                                     backend_balance,
                                     caller=backend_account)
示例#5
0
from initialize_market import initialize, DEFAULT_PARAMETERS

consts = config.get_group("evm")
consts.oog = "ignore"

# This script checks that MarketToken.setPrivileged can
# be called with a zero address, which would brick the
# contract. Running this scripts generates sequences of
# EVM class that lead to these test cases.

m = ManticoreEVM()

market_parameters = DEFAULT_PARAMETERS

market = initialize(m, parameters=market_parameters, only_create=True)

arg_1 = m.make_symbolic_value(name="mt_arg_1")
arg_2 = m.make_symbolic_value(name="mt_arg_2")

# reserve: address, listing: address
market.market_token_contract.setPrivileged(arg_1,
                                           arg_2,
                                           caller=market.market_token_owner)

for state in m.ready_states:
    m.generate_testcase(state,
                        name="BugFound",
                        only_if=BoolAnd(arg_1 == 0, BoolNot(arg_2 == 0)))
    m.generate_testcase(state,
                        name="BugFound",