diff --git a/Commands.md b/Commands.md index 32487c7..d376d94 100644 --- a/Commands.md +++ b/Commands.md @@ -51,7 +51,7 @@ Sell your evotokens and retire liquidity. The amount of evotoken is exact and th Exchange your tokens. There two methods. The first one is to do a transfer to the contract with a memo starting with "exchange:" and followed by the details of your operation, with the format "EVOTOKN, min_expected_asset, memo". Blank spaces before EVOTOKN, min_expected_asset and memo are ignored. The amount to be obtained by the user will be computed by the contract and executed only if it is at least min_expected_asset. - cleos push action eosio.token '["YOUR_ACCOUNT", "evolutiondex", "1.0000 EOS", "exchange: EOSPESO, 0.1000 PESO, memo for the transfer]' -p YOUR_ACCOUNT + cleos push action eosio.token transfer '["YOUR_ACCOUNT", "evolutiondex", "1.0000 EOS", "exchange: EOSPESO, 0.1000 PESO, memo for the transfer"]' -p YOUR_ACCOUNT The other method operates between funds already deposited in the contract. The structure of the input is account, evotoken, extended_asset to pay (exact), asset to receive (limiting). @@ -165,4 +165,4 @@ Finally, to change the fee for operating through EOSPESO run: and the fee will now be set to 0.37%. Or you can configure a contract to perform the *changefee* action. -Check the commands of wevotethefee [here](wevotethefee/vote_commands.md). \ No newline at end of file +Check the commands of wevotethefee [here](wevotethefee/vote_commands.md). diff --git a/evolutiondex.cpp b/evolutiondex.cpp index 92ec383..aa072d5 100644 --- a/evolutiondex.cpp +++ b/evolutiondex.cpp @@ -200,6 +200,7 @@ void evolutiondex::inittoken(name user, symbol new_symbol, extended_asset initia extended_asset initial_pool2, int initial_fee, name fee_contract) { require_auth( user ); + require_auth( get_self() ); check((initial_pool1.quantity.amount > 0) && (initial_pool2.quantity.amount > 0), "Both assets must be positive"); check((initial_pool1.quantity.amount < INIT_MAX) && (initial_pool2.quantity.amount < INIT_MAX), "Initial amounts must be less than 10^15"); int128_t geometric_mean = sqrt(int128_t(initial_pool1.quantity.amount) * int128_t(initial_pool2.quantity.amount)); diff --git a/tests/contracts.hpp b/tests/contracts.hpp index 8407539..00f15ee 100644 --- a/tests/contracts.hpp +++ b/tests/contracts.hpp @@ -4,28 +4,28 @@ namespace eosio { namespace testing { struct contracts { - static std::vector system_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.system/eosio.system.wasm"); } - static std::vector system_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.system/eosio.system.abi"); } + static std::vector system_wasm() { return read_wasm("{CONTRACTS_BUILD_FOLDER}/contracts/eosio.system/eosio.system.wasm"); } + static std::vector system_abi() { return read_abi("{CONTRACTS_BUILD_FOLDER}/contracts/eosio.system/eosio.system.abi"); } - static std::vector token_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.token/eosio.token.wasm"); } - static std::vector token_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.token/eosio.token.abi"); } + static std::vector token_wasm() { return read_wasm("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.token/eosio.token.wasm"); } + static std::vector token_abi() { return read_abi("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.token/eosio.token.abi"); } - static std::vector msig_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.msig/eosio.msig.wasm"); } - static std::vector msig_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.msig/eosio.msig.abi"); } + static std::vector msig_wasm() { return read_wasm("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.msig/eosio.msig.wasm"); } + static std::vector msig_abi() { return read_abi("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.msig/eosio.msig.abi"); } - static std::vector wrap_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.wrap/eosio.wrap.wasm"); } - static std::vector wrap_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.wrap/eosio.wrap.abi"); } + static std::vector wrap_wasm() { return read_wasm("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.wrap/eosio.wrap.wasm"); } + static std::vector wrap_abi() { return read_abi("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.wrap/eosio.wrap.abi"); } - static std::vector bios_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.bios/eosio.bios.wasm"); } - static std::vector bios_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/eosio.contracts/build/contracts/eosio.bios/eosio.bios.abi"); } + static std::vector bios_wasm() { return read_wasm("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.bios/eosio.bios.wasm"); } + static std::vector bios_abi() { return read_abi("${CONTRACTS_BUILD_FOLDER}/contracts/eosio.bios/eosio.bios.abi"); } - static std::vector evolutiondex_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/evo/tests/../evolutiondex.wasm"); } - static std::vector evolutiondex_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/evo/tests/../evolutiondex.abi"); } + static std::vector evolutiondex_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/../evolutiondex.wasm"); } + static std::vector evolutiondex_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/../evolutiondex.abi"); } - static std::vector badtoken_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/evo/tests/../badtoken.wasm"); } - static std::vector badtoken_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/evo/tests/../badtoken.abi"); } + static std::vector badtoken_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/badtoken.wasm"); } + static std::vector badtoken_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/badtoken.abi"); } - static std::vector wevotethefee_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/evo/wevotethefee/wevotethefee.wasm"); } - static std::vector wevotethefee_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/evo/wevotethefee/wevotethefee.abi"); } + static std::vector wevotethefee_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/../wevotethefee/wevotethefee.wasm"); } + static std::vector wevotethefee_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/../wevotethefee/wevotethefee.abi"); } }; }} //ns eosio::testing diff --git a/tests/contracts.hpp.in b/tests/contracts.hpp.in index b06fdb0..cfa925b 100644 --- a/tests/contracts.hpp.in +++ b/tests/contracts.hpp.in @@ -22,10 +22,10 @@ struct contracts { static std::vector evolutiondex_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/../evolutiondex.wasm"); } static std::vector evolutiondex_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/../evolutiondex.abi"); } - static std::vector badtoken_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/../badtoken.wasm"); } - static std::vector badtoken_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/../badtoken.abi"); } + static std::vector badtoken_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/badtoken/badtoken.wasm"); } + static std::vector badtoken_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/badtoken/badtoken.abi"); } - static std::vector wevotethefee_wasm() { return read_wasm("/home/sergio/Dropbox/eos/contracts/evo/wevotethefee/wevotethefee.wasm"); } - static std::vector wevotethefee_abi() { return read_abi("/home/sergio/Dropbox/eos/contracts/evo/wevotethefee/wevotethefee.abi"); } + static std::vector wevotethefee_wasm() { return read_wasm("${CMAKE_CURRENT_SOURCE_DIR}/../wevotethefee/wevotethefee.wasm"); } + static std::vector wevotethefee_abi() { return read_abi("${CMAKE_CURRENT_SOURCE_DIR}/../wevotethefee/wevotethefee.abi"); } }; }} //ns eosio::testing \ No newline at end of file diff --git a/tests/evolutiondex_tests.cpp b/tests/evolutiondex_tests.cpp index 3841753..ab8d401 100644 --- a/tests/evolutiondex_tests.cpp +++ b/tests/evolutiondex_tests.cpp @@ -127,14 +127,22 @@ class evolutiondex_tester : public tester { } action_result inittoken( name user, symbol new_symbol, extended_asset initial_pool1, extended_asset initial_pool2, int initial_fee, name fee_contract){ - return push_action( N(evolutiondex), user, N(inittoken), mvo() + std::vector auths{user, N(evolutiondex)}; + try { + eosio::testing::base_tester::push_action( N(evolutiondex), N(inittoken), auths, mvo() ( "user", user) ("new_symbol", new_symbol) ("initial_pool1", initial_pool1) ("initial_pool2", initial_pool2) ("initial_fee", initial_fee) ("fee_contract", fee_contract) - ); + , 100, 0); + } catch (const fc::exception& ex) { + edump((ex)); + edump((ex.to_detail_string())); + return error(ex.top_message()); + } + return success(); } action_result addliquidity(name user, asset to_buy, asset max_asset1, asset max_asset2) { return push_action( N(evolutiondex), user, N(addliquidity), mvo() @@ -671,6 +679,7 @@ BOOST_FIXTURE_TEST_CASE( increasing_parameter_zero_fee, evolutiondex_tester ) tr BOOST_REQUIRE_EQUAL(is_increasing(old_vec, system_balance(EVO.value)), true); } FC_LOG_AND_RETHROW() + BOOST_FIXTURE_TEST_CASE( memoexchange_test, evolutiondex_tester ) try { const auto& accnt2 = control->db().get( N(evolutiondex) ); abi_def abi_evo; @@ -805,6 +814,13 @@ BOOST_FIXTURE_TEST_CASE( the_other_actions, evolutiondex_tester ) try { extend(asset::from_string("0.0003 EOS")) )); // INITTOKEN + BOOST_REQUIRE_EQUAL( error("missing authority of evolutiondex"), + push_action( N(evolutiondex), N(alice), N(inittoken), mvo() + ("user", N(alice)) ("new_symbol", EVO4) + ("initial_pool1", extend(asset::from_string("1.0000 EOS"))) + ("initial_pool2", extend(asset::from_string("1.0000 ECO"))) + ("initial_fee", 1) ("fee_contract", N(carol)) ) + ); BOOST_REQUIRE_EQUAL( error("missing authority of alice"), push_action( N(evolutiondex), N(bob), N(inittoken), mvo() ("user", N(alice)) ("new_symbol", EVO4) @@ -838,6 +854,7 @@ BOOST_FIXTURE_TEST_CASE( the_other_actions, evolutiondex_tester ) try { BOOST_REQUIRE_EQUAL( success(), inittoken( N(alice), EVO4, extend(asset::from_string("0.0001 EOS")), extend(asset::from_string("0.1000 VOICE")), 10, N(wevotethefee)) ); + produce_blocks(); BOOST_REQUIRE_EQUAL( wasm_assert_msg("token symbol already exists"), inittoken( N(alice), EVO4, extend(asset::from_string("0.0001 EOS")), extend(asset::from_string("0.1000 VOICE")), 10, N(wevotethefee)) ); @@ -913,7 +930,6 @@ BOOST_FIXTURE_TEST_CASE( the_other_actions, evolutiondex_tester ) try { } FC_LOG_AND_RETHROW() - BOOST_FIXTURE_TEST_CASE( we_vote_the_fee, evolutiondex_tester ) try { create_tokens_and_issue();