1#!/usr/bin/env bash
2
3# ------------------------------------------------------------------------------
4# This file is part of solidity.
5#
6# solidity is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# solidity is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with solidity.  If not, see <http://www.gnu.org/licenses/>
18#
19# (c) 2019 solidity contributors.
20#------------------------------------------------------------------------------
21
22set -e
23
24source scripts/common.sh
25source test/externalTests/common.sh
26
27verify_input "$@"
28BINARY_TYPE="$1"
29BINARY_PATH="$2"
30
31function compile_fn { yarn run provision:token:contracts; }
32function test_fn { yarn run test:contracts; }
33
34function colony_test
35{
36    local repo="https://github.com/solidity-external-tests/colonyNetwork.git"
37    local branch=develop_080
38    local config_file="truffle.js"
39    # On levels 1 and 2 it compiles but tests run out of gas
40    local min_optimizer_level=3
41    local max_optimizer_level=3
42
43    local selected_optimizer_levels
44    selected_optimizer_levels=$(circleci_select_steps "$(seq "$min_optimizer_level" "$max_optimizer_level")")
45    print_optimizer_levels_or_exit "$selected_optimizer_levels"
46
47    setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH"
48    download_project "$repo" "$branch" "$DIR"
49    [[ $BINARY_TYPE == native ]] && replace_global_solc "$BINARY_PATH"
50
51    neutralize_package_json_hooks
52    force_truffle_compiler_settings "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$min_optimizer_level"
53    yarn install
54    git submodule update --init
55
56    cd lib
57    rm -Rf dappsys
58    git clone https://github.com/solidity-external-tests/dappsys-monolithic.git -b master_080 dappsys
59    cd ..
60
61    replace_version_pragmas
62    [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc"
63
64    for level in $selected_optimizer_levels; do
65        truffle_run_test "$config_file" "$BINARY_TYPE" "${DIR}/solc" "$level" compile_fn test_fn
66    done
67}
68
69external_test ColonyNetworks colony_test
70