Пример #1
0
def reset_chain(data_dir):
    chaindata_dir = get_chaindata_dir(data_dir)
    remove_dir_if_exists(chaindata_dir)

    dapp_dir = get_dapp_dir(data_dir)
    remove_dir_if_exists(dapp_dir)

    nodekey_path = get_nodekey_path(data_dir)
    remove_file_if_exists(nodekey_path)

    geth_ipc_path = get_geth_ipc_path(data_dir)
    remove_file_if_exists(geth_ipc_path)
def test_bytecode_comes_from_migrations_when_present(testrpc_chain, migration_0001):
    project = Project()
    chain = testrpc_chain

    remove_file_if_exists('contracts/Math.sol')

    assert 'Math' not in project.compiled_contracts
    assert len(project.migrations) == 1

    MATH = migration_0001.compiled_contracts['Math']
    Math = chain.get_contract_factory('Math')

    assert Math.abi == MATH['abi']
    assert Math.code == MATH['code']
    assert Math.code_runtime == MATH['code_runtime']
def test_bytecode_comes_from_latest_migration(testrpc_chain, migration_0001, migration_0002):
    project = Project()
    chain = testrpc_chain

    remove_file_if_exists('contracts/Math.sol')

    assert 'Math' not in project.compiled_contracts
    assert len(project.migrations) == 2

    MATH_V1 = migration_0001.compiled_contracts['Math']
    MATH_V2 = migration_0002.compiled_contracts['Math']
    Math = chain.get_contract_factory('Math')

    # sanity
    assert MATH_V1['code'] != MATH_V2['code']

    assert Math.abi == MATH_V2['abi']
    assert Math.code == MATH_V2['code']
    assert Math.code_runtime == MATH_V2['code_runtime']