-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add test contract code for existing abi/wasm and clean up libraries/testing & unittests dependencies
- Loading branch information
Showing
78 changed files
with
4,933 additions
and
479 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
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 |
---|---|---|
@@ -1,81 +1,22 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
#include <eosio/chain/asset.hpp> | ||
#include <fc/io/fstream.hpp> | ||
|
||
#define CORE_SYM_NAME "${CORE_SYMBOL_NAME}" | ||
#define CORE_SYM_PRECISION 4 | ||
|
||
#define _STRINGIZE1(x) #x | ||
#define _STRINGIZE2(x) _STRINGIZE1(x) | ||
|
||
#define CORE_SYM_STR ( _STRINGIZE2(CORE_SYM_PRECISION) "," CORE_SYM_NAME ) | ||
#define CORE_SYM ( ::eosio::chain::string_to_symbol_c( CORE_SYM_PRECISION, CORE_SYM_NAME ) ) | ||
|
||
struct core_sym { | ||
static inline eosio::chain::asset from_string(const std::string& s) { | ||
return eosio::chain::asset::from_string(s + " " CORE_SYM_NAME); | ||
} | ||
}; | ||
|
||
// CN -> contract C++ name, C -> contract name, D -> top level directory | ||
#define MAKE_READ_WASM_ABI(CN,C, D) \ | ||
static std::vector<uint8_t> CN ## _wasm() { \ | ||
std::string s; \ | ||
fc::read_file_contents("${CMAKE_BINARY_DIR}/unittests/" #D "/" #C "/" #C ".wasm", s); \ | ||
return std::vector<uint8_t>(s.begin(), s.end()); \ | ||
} \ | ||
static std::vector<char> CN ## _abi() { \ | ||
std::string s; \ | ||
fc::read_file_contents("${CMAKE_BINARY_DIR}/unittests/" #D "/" #C "/" #C ".abi", s); \ | ||
return std::vector<char>(s.begin(), s.end()); \ | ||
} | ||
|
||
//contracts that need to be available by native contract unit testing's libtester need to be embedded | ||
// in to the library as the build directory may not exist after being 'make install'ed. | ||
#define MAKE_EMBD_WASM_ABI(CN) \ | ||
static std::vector<uint8_t> CN ## _wasm(); \ | ||
static std::vector<std::uint8_t> CN ## _wasm(); \ | ||
static std::vector<char> CN ## _abi(); | ||
|
||
namespace eosio { | ||
namespace testing { | ||
struct contracts { | ||
// Contracts in `eos/unittests/contracts' directory | ||
// Contracts in `libraries/testing/contracts' directory | ||
MAKE_EMBD_WASM_ABI(eosio_bios) | ||
MAKE_READ_WASM_ABI(eosio_msig, eosio.msig, contracts) | ||
MAKE_READ_WASM_ABI(eosio_system, eosio.system, contracts) | ||
MAKE_READ_WASM_ABI(eosio_token, eosio.token, contracts) | ||
MAKE_READ_WASM_ABI(eosio_wrap, eosio.wrap, contracts) | ||
|
||
MAKE_EMBD_WASM_ABI(before_producer_authority_eosio_bios) | ||
MAKE_EMBD_WASM_ABI(before_preactivate_eosio_bios) | ||
|
||
// Contracts in `eos/unittests/unittests/test-contracts' directory | ||
MAKE_READ_WASM_ABI(asserter, asserter, test-contracts) | ||
MAKE_READ_WASM_ABI(deferred_test, deferred_test, test-contracts) | ||
MAKE_READ_WASM_ABI(get_sender_test, get_sender_test, test-contracts) | ||
MAKE_READ_WASM_ABI(get_table_test, get_table_test, test-contracts) | ||
MAKE_READ_WASM_ABI(get_table_seckey_test, get_table_seckey_test, test-contracts) | ||
MAKE_READ_WASM_ABI(noop, noop, test-contracts) | ||
MAKE_READ_WASM_ABI(payloadless, payloadless, test-contracts) | ||
MAKE_READ_WASM_ABI(proxy, proxy, test-contracts) | ||
MAKE_READ_WASM_ABI(ram_restrictions_test, ram_restrictions_test, test-contracts) | ||
MAKE_READ_WASM_ABI(reject_all, reject_all, test-contracts) | ||
MAKE_READ_WASM_ABI(restrict_action_test, restrict_action_test, test-contracts) | ||
MAKE_READ_WASM_ABI(snapshot_test, snapshot_test, test-contracts) | ||
MAKE_READ_WASM_ABI(test_api, test_api, test-contracts) | ||
MAKE_READ_WASM_ABI(test_api_db, test_api_db, test-contracts) | ||
MAKE_READ_WASM_ABI(test_api_multi_index, test_api_multi_index, test-contracts) | ||
MAKE_READ_WASM_ABI(test_ram_limit, test_ram_limit, test-contracts) | ||
MAKE_READ_WASM_ABI(action_results, action_results, test-contracts) | ||
MAKE_READ_WASM_ABI(wasm_config_bios, wasm_config_bios, test-contracts) | ||
MAKE_READ_WASM_ABI(params_test, params_test, test-contracts) | ||
MAKE_READ_WASM_ABI(crypto_primitives_test,crypto_primitives_test,test-contracts) | ||
MAKE_READ_WASM_ABI(get_block_num_test, get_block_num_test, test-contracts) | ||
MAKE_READ_WASM_ABI(nested_container_multi_index, nested_container_multi_index, test-contracts) | ||
|
||
}; | ||
} /// eosio::testing | ||
} /// eosio |
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,26 @@ | ||
cmake_minimum_required( VERSION 3.8 ) | ||
project(testing_contracts) | ||
|
||
if( EOSIO_COMPILE_TEST_CONTRACTS ) | ||
set(EOSIO_WASM_OLD_BEHAVIOR "Off") | ||
if(USE_EOSIO_CDT_1_7_X OR USE_EOSIO_CDT_1_8_X) | ||
find_package( eosio.cdt REQUIRED ) | ||
else() | ||
find_package( cdt REQUIRED ) | ||
endif() | ||
endif() | ||
|
||
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja") | ||
add_compile_options(-fcolor-diagnostics) | ||
endif() | ||
|
||
if( USE_EOSIO_CDT_1_7_X ) | ||
add_definitions(-DUSE_EOSIO_CDT_1_7_X=true) | ||
elseif( USE_EOSIO_CDT_1_8_X ) | ||
add_definitions(-DUSE_EOSIO_CDT_1_8_X=true) | ||
endif() | ||
|
||
add_subdirectory(eosio.bios) | ||
|
||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/old_versions/v1.6.0-rc3/eosio.bios/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/old_versions/v1.6.0-rc3/eosio.bios/) | ||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/old_versions/v1.7.0-develop-preactivate_feature/eosio.bios/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/old_versions/v1.7.0-develop-preactivate_feature/eosio.bios/) |
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,6 @@ | ||
if( EOSIO_COMPILE_TEST_CONTRACTS ) | ||
add_contract( eosio.bios eosio.bios eosio.bios.cpp ) | ||
else() | ||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/eosio.bios.wasm ${CMAKE_CURRENT_BINARY_DIR}/eosio.bios.wasm COPYONLY ) | ||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/eosio.bios.abi ${CMAKE_CURRENT_BINARY_DIR}/eosio.bios.abi COPYONLY ) | ||
endif() |
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
Oops, something went wrong.