Skip to content
Open
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
78 changes: 0 additions & 78 deletions .github/workflows/ubuntu-2004.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/ubuntu-2204.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build contracts
on:
push:
branches:
- main
- "release/*"
pull_request:
types: [assigned, opened, synchronize, reopened, labeled]
env:
BUILDER_IMAGE: "apm2006/leap:v3.2.5-cdt4.0.1"
jobs:
ubuntu-2404-build:
name: Ubuntu 22.04 | Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
set -e
export DOCKER="docker run --rm -v $(pwd):/root/target ${BUILDER_IMAGE}"
docker pull ${BUILDER_IMAGE}
echo ${DOCKER}
echo =====
mkdir build
${DOCKER} bash -c "cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=yes -Dleap_DIR=/opt/leap/build/lib/cmake/leap .."
echo =====
${DOCKER} bash -c "cd build && make -j $(nproc) VERBOSE=1"
echo =====
${DOCKER} bash -c 'cd build/tests && ctest -j $(nproc)'
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)

set(EOSIO_VERSION_MIN "3.1")
set(EOSIO_VERSION_SOFT_MAX "3.1")
set(EOSIO_VERSION_SOFT_MAX "4.1")
# set(EOSIO_VERSION_HARD_MAX "")

find_package(leap)
Expand Down
22 changes: 11 additions & 11 deletions tests/eosio.system_tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ using mvo = fc::mutable_variant_object;

namespace eosio_system {

auto dump_trace = [](transaction_trace_ptr trace_ptr) -> transaction_trace_ptr {
std::cout << std::endl << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
for(auto trace : trace_ptr->action_traces) {
std::cout << "action_name trace: " << trace.act.name.to_string() << std::endl;
//TODO: split by new line character, loop and indent output
std::cout << trace.console << std::endl << std::endl;
}
std::cout << std::endl << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl << std::endl;
return trace_ptr;
};
// auto dump_trace = [](transaction_trace_ptr trace_ptr) -> transaction_trace_ptr {
// std::cout << std::endl << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
// for(auto trace : trace_ptr->action_traces) {
// std::cout << "action_name trace: " << trace.act.name.to_string() << std::endl;
// //TODO: split by new line character, loop and indent output
// std::cout << trace.console << std::endl << std::endl;
// }
// std::cout << std::endl << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl << std::endl;
// return trace_ptr;
// };

class eosio_system_tester : public TESTER {
public:
Expand Down Expand Up @@ -200,7 +200,7 @@ class eosio_system_tester : public TESTER {
trx.actions.emplace_back(on_block_act);
trx.sign( get_private_key( config::system_account_name, "active" ), control->get_chain_id() );
auto t = push_transaction(trx);
dump_trace(t);
// dump_trace(t);
return t;
}
// TELOS END
Expand Down
21 changes: 16 additions & 5 deletions tests/telos.system_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <boost/test/unit_test.hpp>
#include <cmath>

#include "eosio.system_tester.hpp"

Expand Down Expand Up @@ -198,9 +199,12 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
auto usecs_between_fills = claim_time - initial_claim_time;
int32_t secs_between_fills = usecs_between_fills / 1000000;

const double bpay_rate_percent = bpay_rate / double(100000);
// Replicate contract's dynamic price-based calculation
// In test environment, TLOS price defaults to 1 (matches contract fallback when oracle data unavailable)
uint64_t tlos_price = 1; // Default price (matches contract's get_telos_average_price() fallback)
auto to_workers = static_cast<int64_t>((12 * double(worker_amount) * double(usecs_between_fills)) / double(usecs_per_year));
auto to_producers = static_cast<int64_t>((bpay_rate_percent * double(initial_supply.get_amount()) * double(usecs_between_fills)) / double(usecs_per_year));
double bp_pay_per_month = std::min((double(378000) * std::pow(tlos_price/10000.0,-0.516)),double(882000)) * 10000;
auto to_producers = static_cast<int64_t>((bp_pay_per_month * 12 * double(usecs_between_fills)) / double(usecs_per_year));

prod = get_producer_info("defproducera");
asset to_bpay = asset(to_producers, symbol{CORE_SYM});
Expand All @@ -216,7 +220,11 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
BOOST_REQUIRE_EQUAL(supply, initial_supply);
BOOST_REQUIRE_EQUAL(get_balance("exrsrv.tf"_n), initial_tedp_balance - new_tokens);
const asset payment = get_payment_info("defproducera"_n)["pay"].as<asset>();
BOOST_REQUIRE_EQUAL(payment, to_bpay);
// Allow small tolerance (1 unit = 0.0001 TLOS) for floating point rounding differences
int64_t diff = payment.get_amount() - to_bpay.get_amount();
BOOST_REQUIRE_MESSAGE(diff >= -1 && diff <= 1,
"Payment amount differs from expected by more than 1 unit. Payment: " +
payment.to_string() + ", Expected: " + to_bpay.to_string());
const asset initial_prod_balance = get_balance("defproducera"_n);
push_action("defproducera"_n, "claimrewards"_n, mvo()("owner", "defproducera"));

Expand Down Expand Up @@ -317,9 +325,12 @@ BOOST_FIXTURE_TEST_CASE(multi_producer_pay, eosio_system_tester, * boost::unit_t
auto usecs_between_fills = claim_time - initial_claim_time;
int32_t secs_between_fills = usecs_between_fills / 1000000;

const double bpay_rate_percent = bpay_rate / double(100000);
// Replicate contract's dynamic price-based calculation
// In test environment, TLOS price defaults to 1 (matches contract fallback when oracle data unavailable)
uint64_t tlos_price = 1; // Default price (matches contract's get_telos_average_price() fallback)
auto to_workers = static_cast<int64_t>((12 * double(worker_amount) * double(usecs_between_fills)) / double(usecs_per_year));
auto to_producers = static_cast<int64_t>((bpay_rate_percent * double(initial_supply.get_amount()) * double(usecs_between_fills)) / double(usecs_per_year));
double bp_pay_per_month = std::min((double(378000) * std::pow(tlos_price/10000.0,-0.516)),double(882000)) * 10000;
auto to_producers = static_cast<int64_t>((bp_pay_per_month * 12 * double(usecs_between_fills)) / double(usecs_per_year));

asset to_bpay = asset(to_producers, symbol{CORE_SYM});
asset to_wps = asset(to_workers, symbol{CORE_SYM});
Expand Down