Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use libtester 5.0 in CI; use ubuntu 22.04 for CI; use EOS VM OC for tests #681

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means anyone performing ctest will now need to be using post-5.0.0 libtester otherwise the tests will fail because OC won't work properly.

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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought pretty hard about how I could avoid removing the fixture (and thus needing to plumb through all the t. below, among the other refactoring). Just couldn't come up with anything. The problem is the only ctor of validating_tester that allows either a custom config or modifying the config (what is used in current approach), also requires an externally created tmpdir to ensure the tmpdir outlives the tester. It's too bad there isn't a variant of the ctor that just has the config modification callback so that validating_tester's internal tmpdir can continue to be used.

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()
Loading