Skip to content

Commit

Permalink
Merge pull request EOSIO#6749 from EOSIO/update-test-contracts
Browse files Browse the repository at this point in the history
Updated test contract to work with v1.6.x of eosio.cdt
  • Loading branch information
arhag authored Feb 14, 2019
2 parents 877f734 + 3732cc7 commit 90b2ee3
Show file tree
Hide file tree
Showing 82 changed files with 2,671 additions and 4,714 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*.dylib
*.ll
*.bc
*.wasm
*.wast
*.wast.hpp
*.s
Expand Down
5 changes: 2 additions & 3 deletions unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ include(ExternalProject)
if( EOSIO_COMPILE_TEST_CONTRACTS )
set(EOSIO_WASM_OLD_BEHAVIOR "Off")
find_package(eosio.cdt REQUIRED)

message( STATUS "Building contracts in directory `eos/unittests/test-contracts/`" )
ExternalProject_Add(
test_contracts_project
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test-contracts
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/test-contracts
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${EOSIO_CDT_ROOT}/lib/cmake/eosio.cdt/EosioWasmToolchain.cmake -DBoost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS} -DEOSIO_COMPILE_TEST_CONTRACTS=${EOSIO_COMPILE_TEST_CONTRACTS}
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${EOSIO_CDT_ROOT}/lib/cmake/eosio.cdt/EosioWasmToolchain.cmake -DEOSIO_COMPILE_TEST_CONTRACTS=${EOSIO_COMPILE_TEST_CONTRACTS}
UPDATE_COMMAND ""
PATCH_COMMAND ""
TEST_COMMAND ""
Expand All @@ -37,7 +37,6 @@ set( CMAKE_CXX_STANDARD 14 )

add_subdirectory(contracts)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.hpp ESCAPE_QUOTES)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/contracts.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/contracts.hpp ESCAPE_QUOTES)

### BUILD UNIT TEST EXECUTABLE ###
Expand Down
2 changes: 0 additions & 2 deletions unittests/abi_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include <boost/test/framework.hpp>

#include <config.hpp>

#include <deep_nested.abi.hpp>
#include <large_nested.abi.hpp>

Expand Down
626 changes: 233 additions & 393 deletions unittests/api_tests.cpp

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions unittests/contracts.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,16 @@ namespace eosio {
MAKE_READ_WASM_ABI(eosio_wrap, eosio.wrap, contracts)

// Contracts in `eos/unittests/unittests/test-contracts' directory
MAKE_READ_WASM_ABI(deferred_test, deferred_test, test-contracts)
MAKE_READ_WASM_ABI(asserter, asserter, test-contracts)
MAKE_READ_WASM_ABI(integration_test, integration_test, test-contracts)
MAKE_READ_WASM_ABI(multi_index_test, multi_index_test, test-contracts)
MAKE_READ_WASM_ABI(deferred_test, deferred_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(snapshot_test, snapshot_test, test-contracts)
MAKE_READ_WASM_ABI(test_ram_limit, test_ram_limit, 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_api_mem, test_api_mem, test-contracts)
MAKE_READ_WASM_ABI(test_ram_limit, test_ram_limit, test-contracts)
};
} /// eosio::testing
} /// eosio
15 changes: 7 additions & 8 deletions unittests/currency_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,16 @@ BOOST_FIXTURE_TEST_CASE( test_proxy, currency_tester ) try {
action setowner_act;
setowner_act.account = N(proxy);
setowner_act.name = N(setowner);
setowner_act.authorization = vector<permission_level>{{N(alice), config::active_name}};
setowner_act.authorization = vector<permission_level>{{N(proxy), config::active_name}};
setowner_act.data = proxy_abi_ser.variant_to_binary("setowner", mutable_variant_object()
("owner", "alice")
("delay", 10),
abi_serializer_max_time
);
trx.actions.emplace_back(std::move(setowner_act));

set_transaction_headers(trx);
trx.sign(get_private_key(N(alice), "active"), control->get_chain_id());
trx.sign(get_private_key(N(proxy), "active"), control->get_chain_id());
push_transaction(trx);
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id()));
Expand Down Expand Up @@ -473,7 +473,7 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
action setowner_act;
setowner_act.account = N(proxy);
setowner_act.name = N(setowner);
setowner_act.authorization = vector<permission_level>{{N(bob), config::active_name}};
setowner_act.authorization = vector<permission_level>{{N(proxy), config::active_name}};
setowner_act.data = proxy_abi_ser.variant_to_binary("setowner", mutable_variant_object()
("owner", "bob")
("delay", 10),
Expand All @@ -482,7 +482,7 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
trx.actions.emplace_back(std::move(setowner_act));

set_transaction_headers(trx);
trx.sign(get_private_key(N(bob), "active"), control->get_chain_id());
trx.sign(get_private_key(N(proxy), "active"), control->get_chain_id());
push_transaction(trx);
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id()));
Expand All @@ -506,7 +506,6 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
produce_block();
BOOST_REQUIRE_EQUAL(get_balance( N(proxy)), asset::from_string("5.0000 CUR"));
BOOST_REQUIRE_EQUAL(get_balance( N(bob)), asset::from_string("0.0000 CUR"));
BOOST_REQUIRE_EQUAL(get_balance( N(bob)), asset::from_string("0.0000 CUR"));
BOOST_REQUIRE_EQUAL(1, index.size());
BOOST_REQUIRE_EQUAL(false, chain_has_transaction(deferred_id));
}
Expand All @@ -525,7 +524,7 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
action setowner_act;
setowner_act.account = N(bob);
setowner_act.name = N(setowner);
setowner_act.authorization = vector<permission_level>{{N(alice), config::active_name}};
setowner_act.authorization = vector<permission_level>{{N(bob), config::active_name}};
setowner_act.data = proxy_abi_ser.variant_to_binary("setowner", mutable_variant_object()
("owner", "alice")
("delay", 0),
Expand All @@ -534,7 +533,7 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
trx.actions.emplace_back(std::move(setowner_act));

set_transaction_headers(trx);
trx.sign(get_private_key(N(alice), "active"), control->get_chain_id());
trx.sign(get_private_key(N(bob), "active"), control->get_chain_id());
push_transaction(trx);
produce_block();
BOOST_REQUIRE_EQUAL(true, chain_has_transaction(trx.id()));
Expand Down
11 changes: 0 additions & 11 deletions unittests/include/config.hpp.in

This file was deleted.

82 changes: 0 additions & 82 deletions unittests/multi_index_tests.cpp

This file was deleted.

Loading

0 comments on commit 90b2ee3

Please sign in to comment.