Skip to content

Commit

Permalink
Merge pull request #681 from eosnetworkfoundation/libtester5_oc
Browse files Browse the repository at this point in the history
use libtester 5.0 in CI; use ubuntu 22.04 for CI; use EOS VM OC for tests
  • Loading branch information
spoonincode authored Feb 23, 2024
2 parents 7e1fb46 + 5e8c9aa commit 2371df3
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 67 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: 'false'
Expand All @@ -23,40 +23,29 @@ jobs:
run: cat .github/workflows/contract.md >> $GITHUB_STEP_SUMMARY

build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
DWITH_TEST_ACTIONS: ['on', 'off']
name: EOS EVM Contract Build - Tests ${{ matrix.DWITH_TEST_ACTIONS }}
env:
CC: gcc-10
CXX: g++-10
DCMAKE_BUILD_TYPE: 'Release'

steps:
- name: Authenticate
id: auth
uses: AntelopeIO/github-app-token-action@v1
with:
app_id: ${{ secrets.TRUSTEVM_CI_APP_ID }}
private_key: ${{ secrets.TRUSTEVM_CI_APP_KEY }}

- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
token: ${{ steps.auth.outputs.token }}

- name: Download CDT
uses: AntelopeIO/asset-artifact-download-action@v2
uses: AntelopeIO/asset-artifact-download-action@v3
with:
owner: AntelopeIO
repo: cdt
target: 'v3.1.0'
prereleases: false
file: 'cdt_.*amd64.deb'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install CDT
run: sudo apt-get install -y ./cdt*.deb
Expand All @@ -74,15 +63,15 @@ jobs:
if-no-files-found: error

- name: Download Leap - dev binary
uses: AntelopeIO/asset-artifact-download-action@v2
uses: AntelopeIO/asset-artifact-download-action@v3
with:
owner: AntelopeIO
repo: leap
target: 'v4.0.3'
target: '^5.0.1'
prereleases: false
file: 'leap-dev.*(x86_64|amd64).deb'
file: 'leap-dev.*ubuntu22\.04_amd64.deb'
container-package: experimental-binaries
token: ${{ secrets.GITHUB_TOKEN }}
artifact-name: leap-dev-ubuntu22-amd64

- name: Install Leap
run: sudo apt-get install -y ./leap*.deb
Expand Down
5 changes: 2 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ add_eosio_test_executable( unit_test
${CMAKE_SOURCE_DIR}/external/ethash/lib/ethash/primes.c
)

# TODO: add back eos-vm-oc once change to disable EOS VM OC subjective limits during unit test are added
add_test(NAME consensus_tests COMMAND unit_test --report_level=detailed --color_output --run_test=evm_runtime_tests)
add_test(NAME consensus_tests COMMAND unit_test --report_level=detailed --color_output --run_test=evm_runtime_tests -- --eos-vm-oc)

add_test(NAME unit_tests COMMAND unit_test --report_level=detailed --color_output --run_test=!evm_runtime_tests)
add_test(NAME unit_tests COMMAND unit_test --report_level=detailed --color_output --run_test=!evm_runtime_tests -- --eos-vm-oc)
24 changes: 7 additions & 17 deletions tests/eosio.system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,15 @@ using namespace fc;

using mvo = fc::mutable_variant_object;

#ifndef TESTER
#ifdef NON_VALIDATING_TEST
#define TESTER tester
#else
#define TESTER validating_tester
#endif
#endif

namespace eosio_system {

class eosio_system_tester : public TESTER {
class eosio_system_tester : public validating_tester {
public:

eosio_system_tester()
: eosio_system_tester([](TESTER& ) {}){}

template<typename Lambda>
eosio_system_tester(Lambda setup) {
setup(*this);
eosio_system_tester(const fc::temp_directory& tmpdir)
: validating_tester(tmpdir, [](controller::config& cfg) {
cfg.eosvmoc_config.cache_size = 1024u*1024*256;
}, true) {
execute_setup_policy(setup_policy::full);

produce_blocks( 2 );

Expand Down Expand Up @@ -451,7 +441,7 @@ class eosio_system_tester : public TESTER {
}
produce_blocks( 250);

auto trace_auth = TESTER::push_action(config::system_account_name, updateauth::get_name(), config::system_account_name, mvo()
auto trace_auth = validating_tester::push_action(config::system_account_name, updateauth::get_name(), config::system_account_name, mvo()
("account", name(config::system_account_name).to_string())
("permission", name(config::active_name).to_string())
("parent", name(config::owner_name).to_string())
Expand Down
61 changes: 33 additions & 28 deletions tests/evm_runtime_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ struct evm_runtime_tester : eosio_system_tester, silkworm::State {
size_t total_failed{0};
size_t total_skipped{0};

evm_runtime_tester() {
evm_runtime_tester(const fc::temp_directory& tmpdir) : eosio_system_tester(tmpdir) {
std::string verbose_arg = "--verbose";
std::string slowtests_arg = "--slow-tests";
auto argc = boost::unit_test::framework::master_test_suite().argc;
Expand Down Expand Up @@ -1101,12 +1101,14 @@ struct evm_runtime_tester : eosio_system_tester, silkworm::State {
};

BOOST_AUTO_TEST_SUITE(evm_runtime_tests)
BOOST_FIXTURE_TEST_CASE( GeneralStateTests, evm_runtime_tester ) try {
BOOST_AUTO_TEST_CASE( GeneralStateTests ) try {
fc::temp_directory tmpdir;
evm_runtime_tester t(tmpdir);

StopWatch sw;
sw.start();

load_excluded();
t.load_excluded();

const fs::path root_dir{contracts::eth_test_folder()};

Expand All @@ -1120,44 +1122,47 @@ BOOST_FIXTURE_TEST_CASE( GeneralStateTests, evm_runtime_tester ) try {
const RunnerFunc runner{entry.second};

for (auto i = fs::recursive_directory_iterator(root_dir / dir); i != fs::recursive_directory_iterator{}; ++i) {
if (exclude_test(*i, root_dir, slow_tests)) {
++total_skipped;
if (t.exclude_test(*i, root_dir, t.slow_tests)) {
++t.total_skipped;
i.disable_recursion_pending();
} else if (fs::is_regular_file(i->path())) {
const fs::path path{*i};
run_test_file(path, runner);
t.run_test_file(path, runner);
}
}
}

const auto [_, duration] = sw.lap();
std::cout << total_passed << " tests passed" << ", "
<< total_failed << " failed" << ", "
<< total_skipped << " skipped"
std::cout << t.total_passed << " tests passed" << ", "
<< t.total_failed << " failed" << ", "
<< t.total_skipped << " skipped"
<< " in " << StopWatch::format(duration) << std::endl;

BOOST_REQUIRE_EQUAL(total_failed, 0);
BOOST_REQUIRE_EQUAL(t.total_failed, 0u);

} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( balance_and_dust_tests, evm_runtime_tester ) try {
BOOST_REQUIRE_EQUAL(testbaldust("basic"_n), success());

BOOST_REQUIRE_EQUAL(testbaldust("underflow1"_n), error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(testbaldust("underflow2"_n), error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(testbaldust("underflow3"_n), error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(testbaldust("underflow4"_n), error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(testbaldust("underflow5"_n), error("assertion failure with message: decrementing more than available"));

BOOST_REQUIRE_EQUAL(testbaldust("overflow1"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflow2"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflow3"_n), success());
BOOST_REQUIRE_EQUAL(testbaldust("overflow4"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflow5"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflowa"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflowb"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflowc"_n), error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(testbaldust("overflowd"_n), error("assertion failure with message: accumulation overflow"));
BOOST_AUTO_TEST_CASE( balance_and_dust_tests ) try {
fc::temp_directory tmpdir;
evm_runtime_tester t(tmpdir);

BOOST_REQUIRE_EQUAL(t.testbaldust("basic"_n), t.success());

BOOST_REQUIRE_EQUAL(t.testbaldust("underflow1"_n), t.error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(t.testbaldust("underflow2"_n), t.error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(t.testbaldust("underflow3"_n), t.error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(t.testbaldust("underflow4"_n), t.error("assertion failure with message: decrementing more than available"));
BOOST_REQUIRE_EQUAL(t.testbaldust("underflow5"_n), t.error("assertion failure with message: decrementing more than available"));

BOOST_REQUIRE_EQUAL(t.testbaldust("overflow1"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflow2"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflow3"_n), t.success());
BOOST_REQUIRE_EQUAL(t.testbaldust("overflow4"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflow5"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflowa"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflowb"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflowc"_n), t.error("assertion failure with message: accumulation overflow"));
BOOST_REQUIRE_EQUAL(t.testbaldust("overflowd"_n), t.error("assertion failure with message: accumulation overflow"));
} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 2371df3

Please sign in to comment.