Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix build errors caused by memo #248
Browse files Browse the repository at this point in the history
- added checks on redundant scope specification in readscope #70
  • Loading branch information
bytemaster committed Aug 29, 2017
1 parent 7731360 commit b6f98b8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
10 changes: 9 additions & 1 deletion libraries/chain/chain_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,17 @@ void chain_controller::check_transaction_authorization(const SignedTransaction&
}

void chain_controller::validate_scope( const Transaction& trx )const {
EOS_ASSERT(trx.scope.size() > 0, transaction_exception, "No scope specified by transaction" );
EOS_ASSERT(trx.scope.size() + trx.readscope.size() > 0, transaction_exception, "No scope specified by transaction" );
for( uint32_t i = 1; i < trx.scope.size(); ++i )
EOS_ASSERT( trx.scope[i-1] < trx.scope[i], transaction_exception, "Scopes must be sorted and unique" );
for( uint32_t i = 1; i < trx.readscope.size(); ++i )
EOS_ASSERT( trx.readscope[i-1] < trx.readscope[i], transaction_exception, "Scopes must be sorted and unique" );

vector<types::AccountName> intersection;
std::set_intersection( trx.scope.begin(), trx.scope.end(),
trx.readscope.begin(), trx.readscope.end(),
std::back_inserter(intersection) );
FC_ASSERT( intersection.size() == 0, "a transaction may not redeclare scope in readscope" );
}

const permission_object& chain_controller::lookup_minimum_permission(types::AccountName authorizer_account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ std::vector<chain::Message> native_contract_chain_initializer::prepare_database(
message = chain::Message(config::EosContractName,
vector<types::AccountPermission>{{config::EosContractName, "active"}},
"transfer", types::transfer(config::EosContractName, acct.name,
acct.liquid_balance.amount/*, "Genesis Allocation"*/));
acct.liquid_balance.amount, "Genesis Allocation"));
messages_to_process.emplace_back(std::move(message));
}
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/types/include/eos/types/Asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <eos/types/native.hpp>

/// eos with 8 digits of precision
#define EOS_SYMBOL (int64_t(8) | (uint64_t('E') << 8) | (uint64_t('O') << 16) | (uint64_t('S') << 24))
#define EOS_SYMBOL (int64_t(5) | (uint64_t('E') << 8) | (uint64_t('O') << 16) | (uint64_t('S') << 24))

/// Defined to be largest power of 10 that fits in 53 bits of precision
#define EOS_MAX_SHARE_SUPPLY int64_t(1000000000000000ll)
#define EOS_MAX_SHARE_SUPPLY int64_t(1'000'000'000'000'000ll)

namespace eos { namespace types {

Expand Down
2 changes: 1 addition & 1 deletion tests/common/macro_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
trx.scope = sort_names({#sender,#recipient}); \
transaction_helpers::emplace_message(trx, config::EosContractName, \
vector<types::AccountPermission>{ {#sender,"active"} }, \
"transfer", types::transfer{#sender, #recipient, Amount.amount}); \
"transfer", types::transfer{#sender, #recipient, Amount.amount, memo}); \
trx.expiration = chain.head_block_time() + 100; \
transaction_helpers::set_reference_block(trx, chain.head_block_id()); \
chain.push_transaction(trx); \
Expand Down
8 changes: 4 additions & 4 deletions tests/slow_tests/slow_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void TransferCurrency( testing_blockchain& chain, AccountName from, AccountName
trx.scope = sort_names({from,to});
transaction_helpers::emplace_message(trx, "currency",
vector<types::AccountPermission>{ {from,"active"} },
"transfer", types::transfer{from, to, amount});
"transfer", types::transfer{from, to, amount,""});

trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());
Expand All @@ -324,7 +324,7 @@ void WithdrawCurrency( testing_blockchain& chain, AccountName from, AccountName
trx.scope = sort_names({from,to});
transaction_helpers::emplace_message(trx, "currency",
vector<types::AccountPermission>{ {from,"active"},{to,"active"} },
"transfer", types::transfer{from, to, amount});
"transfer", types::transfer{from, to, amount,""});
trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());
chain.push_transaction(trx);
Expand Down Expand Up @@ -367,7 +367,7 @@ BOOST_FIXTURE_TEST_CASE(create_script, testing_fixture)
trx.scope = sort_names({"currency","inita"});
transaction_helpers::emplace_message(trx, "currency",
vector<types::AccountPermission>{ {"currency","active"} },
"transfer", types::transfer{"currency", "inita", 1+i});
"transfer", types::transfer{"currency", "inita", 1+i,""});
trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());
//idump((trx));
Expand Down Expand Up @@ -1167,7 +1167,7 @@ BOOST_FIXTURE_TEST_CASE(create_script_w_loop, testing_fixture)
trx.scope = sort_names({"currency","inita"});
transaction_helpers::emplace_message(trx, "currency",
vector<types::AccountPermission>{ {"currency","active"} },
"transfer", types::transfer{"currency", "inita", 1});
"transfer", types::transfer{"currency", "inita", 1,""});
trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());
try
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ BOOST_FIXTURE_TEST_CASE(trx_variant, testing_fixture) {
trx.scope = sort_names({from,to});
transaction_helpers::emplace_message(trx, "eos",
vector<types::AccountPermission>{ {from,"active"} },
"transfer", types::transfer{from, to, amount/*, ""*/});
"transfer", types::transfer{from, to, amount, ""});
trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());

Expand Down Expand Up @@ -180,7 +180,7 @@ BOOST_FIXTURE_TEST_CASE(irrelevant_auth, testing_fixture) {
ProcessedTransaction trx;
trx.scope = sort_names({"joe", "inita"});
transaction_helpers::emplace_message(trx, config::EosContractName, vector<types::AccountPermission>{{"inita", "active"}},
"transfer", types::transfer{"inita", "joe", 50});
"transfer", types::transfer{"inita", "joe", 50,""});
trx.expiration = chain.head_block_time() + 100;
transaction_helpers::set_reference_block(trx, chain.head_block_id());
chain.push_transaction(trx, chain_controller::skip_transaction_signatures);
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/native_contract_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ BOOST_FIXTURE_TEST_CASE(transfer, testing_fixture)
trx.expiration = chain.head_block_time() + 100;
trx.scope = sort_names( {"inita", "initb"} );

types::transfer trans = { "inita", "initb", (100) };
types::transfer trans = { "inita", "initb", (100), "" };

UInt64 value(5);
auto packed = fc::raw::pack(value);
Expand Down

0 comments on commit b6f98b8

Please sign in to comment.