提交 4428d5ff 编写于 作者: D Daniel Larimer

fix unit tests

上级 74581363
......@@ -259,7 +259,7 @@ DEFINE_INTRINSIC_FUNCTION2(env,readMessage,readMessage,i32,i32,destptr,i32,dests
int minlen = std::min<int>(wasm.current_validate_context->msg.data.size(), destsize);
wdump((destsize)(wasm.current_validate_context->msg.data.size()));
// wdump((destsize)(wasm.current_validate_context->msg.data.size()));
memcpy( begin, wasm.current_validate_context->msg.data.data(), minlen );
return minlen;
}
......@@ -371,7 +371,7 @@ DEFINE_INTRINSIC_FUNCTION1(env,free,free,none,i32,ptr) {
FC_ASSERT( getFunctionType(call)->parameters.size() == 2 );
idump((current_validate_context->msg.code)(current_validate_context->msg.type)(current_validate_context->code));
// idump((current_validate_context->msg.code)(current_validate_context->msg.type)(current_validate_context->code));
std::vector<Value> args = { Value(uint64_t(current_validate_context->msg.code)),
Value(uint64_t(current_validate_context->msg.type)) };
......
......@@ -25,6 +25,8 @@
inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
std::sort( names.begin(), names.end() );
auto itr = std::unique( names.begin(), names.end() );
names.erase( itr, names.end() );
return names;
}
......@@ -80,6 +82,7 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
#define STAKE4(chain, sender, recipient, amount) \
{ \
eos::chain::SignedTransaction trx; \
trx.scope = sort_names( { #sender, #recipient } ); \
trx.emplaceMessage(config::EosContractName, vector<AccountName>{#sender, config::StakedBalanceContractName}, \
vector<types::AccountPermission>{}, "lock", types::lock{#sender, #recipient, amount}); \
if (std::string(#sender) != std::string(#recipient)) { \
......@@ -96,6 +99,7 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
#define BEGIN_UNSTAKE3(chain, account, amount) \
{ \
eos::chain::SignedTransaction trx; \
trx.scope = sort_names( { "staked" } ); \
trx.emplaceMessage(config::StakedBalanceContractName, vector<AccountName>{#account}, \
vector<types::AccountPermission>{}, \
"unlock", types::unlock{#account, amount}); \
......@@ -108,6 +112,7 @@ inline std::vector<Name> sort_names( std::vector<Name>&& names ) {
#define FINISH_UNSTAKE3(chain, account, amount) \
{ \
eos::chain::SignedTransaction trx; \
trx.scope = sort_names( { "staked", #account } ); \
trx.emplaceMessage(config::StakedBalanceContractName, vector<AccountName>{#account, config::EosContractName}, \
vector<types::AccountPermission>{}, "claim", types::claim{#account, amount}); \
boost::sort(trx.messages.back().recipients); \
......
......@@ -302,7 +302,11 @@ void TransferCurrency( testing_blockchain& chain, AccountName from, AccountName
trx.scope = sort_names({from,to});
trx.emplaceMessage("currency", sort_names( {from,to} ),
vector<types::AccountPermission>{ {from,"active"} },
"transfer", types::transfer{from, to, amount, ""});
"transfer", types::transfer{from, to, amount});
auto& re = trx.messages.back().recipients;
auto itr = std::remove( re.begin(), re.end(), Name("currency") );
re.erase( itr, re.end() );
trx.expiration = chain.head_block_time() + 100;
trx.set_reference_block(chain.head_block_id());
idump((trx));
......@@ -314,7 +318,7 @@ void WithdrawCurrency( testing_blockchain& chain, AccountName from, AccountName
trx.scope = sort_names({from,to});
trx.emplaceMessage("currency", sort_names( {from,to} ),
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;
trx.set_reference_block(chain.head_block_id());
chain.push_transaction(trx);
......@@ -341,7 +345,7 @@ BOOST_FIXTURE_TEST_CASE(create_script, testing_fixture)
trx.scope = {"currency"};
trx.messages.resize(1);
trx.messages[0].code = config::SystemContractName;
trx.messages[0].recipients = {"currency"};
trx.messages[0].recipients = {};
trx.setMessage(0, "setcode", handler);
trx.expiration = chain.head_block_time() + 100;
trx.set_reference_block(chain.head_block_id());
......@@ -355,9 +359,9 @@ BOOST_FIXTURE_TEST_CASE(create_script, testing_fixture)
{
eos::chain::SignedTransaction trx;
trx.scope = sort_names({"currency","inita"});
trx.emplaceMessage("currency", vector<AccountName>{"inita","currency"},
trx.emplaceMessage("currency", vector<AccountName>{"inita"},
vector<types::AccountPermission>{ {"currency","active"} },
"transfer", types::transfer{"currency", "inita", 1+i, "hello"});
"transfer", types::transfer{"currency", "inita", 1+i});
trx.expiration = chain.head_block_time() + 100;
trx.set_reference_block(chain.head_block_id());
//idump((trx));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册