This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from eosnetworkfoundation/clsdk
enhancements for clsdk
- Loading branch information
Showing
8 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,10 +63,12 @@ if(APPLE AND UNIX AND "${OPENSSL_ROOT_DIR}" STREQUAL "") | |
set(OPENSSL_ROOT_DIR "/usr/local/opt/[email protected]") | ||
endif() | ||
|
||
option(ENABLE_OC "Enable eosvm-oc on supported platforms" ON) | ||
|
||
# WASM runtimes to enable. Each runtime in this list will have: | ||
# * definition EOSIO_<RUNTIME>_RUNTIME_ENABLED defined in public libchain interface | ||
# * ctest entries with --runtime | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) | ||
if(ENABLE_OC AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) | ||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") | ||
list(APPEND EOSIO_WASM_RUNTIMES eos-vm-oc) | ||
# EOS VM OC requires LLVM, but move the check up here to a central location so that the EosioTester.cmakes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <eosio/chain/controller.hpp> | ||
#include <eosio/chain/global_property_object.hpp> | ||
#include <eosio/chain/permission_object.hpp> | ||
#include <eosio/chain/resource_limits.hpp> | ||
#include <boost/test/unit_test.hpp> | ||
#include <eosio/testing/tester.hpp> | ||
|
||
#include "fork_test_utilities.hpp" | ||
|
||
using namespace eosio; | ||
using namespace eosio::chain; | ||
using namespace eosio::testing; | ||
|
||
BOOST_AUTO_TEST_SUITE(chain_tests) | ||
|
||
BOOST_AUTO_TEST_CASE( replace_producer_keys ) try { | ||
validating_tester tester; | ||
|
||
const auto head_ptr = tester.control->head_block_state(); | ||
BOOST_REQUIRE(head_ptr); | ||
|
||
const auto new_key = get_public_key(name("newkey"), config::active_name.to_string()); | ||
|
||
// make sure new keys is not used | ||
for(const auto& prod : head_ptr->active_schedule.producers) { | ||
for(const auto& key : prod.authority.get<block_signing_authority_v0>().keys){ | ||
BOOST_REQUIRE(key.key != new_key); | ||
} | ||
} | ||
|
||
const auto old_version = head_ptr->pending_schedule.schedule.version; | ||
BOOST_REQUIRE_NO_THROW(tester.control->replace_producer_keys(new_key)); | ||
const auto new_version = head_ptr->pending_schedule.schedule.version; | ||
// make sure version not been changed | ||
BOOST_REQUIRE(old_version == new_version); | ||
|
||
const auto& gpo = tester.control->db().get<global_property_object>(); | ||
BOOST_REQUIRE(!gpo.proposed_schedule_block_num); | ||
BOOST_REQUIRE(gpo.proposed_schedule.version == 0); | ||
BOOST_REQUIRE(gpo.proposed_schedule.producers.empty()); | ||
|
||
const uint32_t expected_threshold = 1; | ||
const weight_type expected_key_weight = 1; | ||
for(const auto& prod : head_ptr->active_schedule.producers) { | ||
BOOST_REQUIRE_EQUAL(prod.authority.get<block_signing_authority_v0>().threshold, expected_threshold); | ||
for(const auto& key : prod.authority.get<block_signing_authority_v0>().keys){ | ||
BOOST_REQUIRE_EQUAL(key.key, new_key); | ||
BOOST_REQUIRE_EQUAL(key.weight, expected_key_weight); | ||
} | ||
} | ||
} FC_LOG_AND_RETHROW() | ||
|
||
BOOST_AUTO_TEST_CASE( replace_account_keys ) try { | ||
validating_tester tester; | ||
const name usr = config::system_account_name; | ||
const name active_permission = config::active_name; | ||
const auto& rlm = tester.control->get_resource_limits_manager(); | ||
const auto* perm = tester.control->db().find<permission_object, by_owner>(boost::make_tuple(usr, active_permission)); | ||
BOOST_REQUIRE(perm != NULL); | ||
|
||
const int64_t old_size = (int64_t)(chain::config::billable_size_v<permission_object> + perm->auth.get_billable_size()); | ||
const auto old_usr_auth = perm->auth; | ||
const auto new_key = get_public_key(name("newkey"), "active"); | ||
const authority expected_authority(new_key); | ||
BOOST_REQUIRE(old_usr_auth != expected_authority); | ||
const auto old_ram_usg = rlm.get_account_ram_usage(usr); | ||
|
||
BOOST_REQUIRE_NO_THROW(tester.control->replace_account_keys(usr, active_permission, new_key)); | ||
const int64_t new_size = (int64_t)(chain::config::billable_size_v<permission_object> + perm->auth.get_billable_size()); | ||
const auto new_ram_usg = rlm.get_account_ram_usage(usr); | ||
BOOST_REQUIRE_EQUAL(old_ram_usg + (new_size - old_size), new_ram_usg); | ||
const auto new_usr_auth = perm->auth; | ||
BOOST_REQUIRE(new_usr_auth == expected_authority); | ||
|
||
} FC_LOG_AND_RETHROW() | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |