api_tests.cpp 18.0 KB
Newer Older
1 2 3 4 5 6 7 8
#include <algorithm>
#include <random>
#include <iostream>
#include <vector>
#include <iterator>
#include <sstream>
#include <numeric>

M
Matias Romeo 已提交
9
#include <boost/test/unit_test.hpp>
10 11
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream_buffer.hpp>
M
Matias Romeo 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

#include <eos/chain/chain_controller.hpp>
#include <eos/chain/exceptions.hpp>
#include <eos/chain/account_object.hpp>
#include <eos/chain/key_value_object.hpp>
#include <eos/chain/block_summary_object.hpp>
#include <eos/chain/wasm_interface.hpp>

#include <eos/utilities/tempdir.hpp>

#include <fc/crypto/digest.hpp>
#include <fc/exception/exception.hpp>

#include "../common/database_fixture.hpp"

#include <Inline/BasicTypes.h>
#include <IR/Module.h>
#include <IR/Validate.h>
#include <WAST/WAST.h>
#include <WASM/WASM.h>
#include <Runtime/Runtime.h>

34
#include <test_api/test_api.wast.hpp>
M
Matias Romeo 已提交
35 36
#include <test_api/test_api.hpp>
FC_REFLECT( dummy_message, (a)(b)(c) );
37
FC_REFLECT( u128_msg, (values) );
M
Matias Romeo 已提交
38 39 40 41

using namespace eos;
using namespace chain;

42 43
namespace bio = boost::iostreams;

M
Matias Romeo 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
BOOST_AUTO_TEST_SUITE(api_tests)

vector<uint8_t> assemble_wast( const std::string& wast ) {
   //   std::cout << "\n" << wast << "\n";
   IR::Module module;
   std::vector<WAST::Error> parseErrors;
   WAST::parseModule(wast.c_str(),wast.size(),module,parseErrors);
   if(parseErrors.size())
   {
      // Print any parse errors;
      std::cerr << "Error parsing WebAssembly text file:" << std::endl;
      for(auto& error : parseErrors)
      {
         std::cerr << ":" << error.locus.describe() << ": " << error.message.c_str() << std::endl;
         std::cerr << error.locus.sourceLine << std::endl;
         std::cerr << std::setw(error.locus.column(8)) << "^" << std::endl;
      }
      FC_ASSERT( !"error parsing wast" );
   }

   try
   {
      // Serialize the WebAssembly module.
      Serialization::ArrayOutputStream stream;
      WASM::serialize(stream,module);
      return stream.getBytes();
   }
   catch(Serialization::FatalSerializationException exception)
   {
      std::cerr << "Error serializing WebAssembly binary file:" << std::endl;
      std::cerr << exception.message << std::endl;
      throw;
   }
}

79
uint32_t CallFunction( testing_blockchain& chain, const types::Message& msg, const vector<char>& data, const vector<AccountName>& scope = {N(testapi)}) {
80
   static int expiration = 1;
M
Matias Romeo 已提交
81
   eos::chain::SignedTransaction trx;
82
   trx.scope = scope;
M
Matias Romeo 已提交
83
   
84 85 86
   //msg.data.clear();
   vector<char>& dest = *(vector<char> *)(&msg.data);
   std::copy(data.begin(), data.end(), std::back_inserter(dest));
87

M
Matias Romeo 已提交
88
   //std::cout << "MANDO: " << msg.code << " " << msg.type << std::endl;
89
   transaction_emplace_message(trx, msg);
M
Matias Romeo 已提交
90
   
91
   trx.expiration = chain.head_block_time() + expiration++;
92
   transaction_set_reference_block(trx, chain.head_block_id());
M
Matias Romeo 已提交
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
   //idump((trx));
   chain.push_transaction(trx);

   //
   auto& wasm = wasm_interface::get();
   uint32_t *res = Runtime::memoryArrayPtr<uint32_t>(wasm.current_memory, (1<<16) - 2*sizeof(uint32_t), 2);

   if(res[0] == WASM_TEST_FAIL) {
      char *str_err = &Runtime::memoryRef<char>(wasm.current_memory, res[1]);
      wlog( "${err}", ("err",str_err));
   }

   return res[0];
}


using namespace std;
string readFile2(const string &fileName)
{
    ifstream ifs(fileName.c_str(), ios::in | ios::binary | ios::ate);

    ifstream::pos_type fileSize = ifs.tellg();
    ifs.seekg(0, ios::beg);

    vector<char> bytes(fileSize);
    ifs.read(bytes.data(), fileSize);

    return string(bytes.data(), fileSize);
}

123 124 125 126
uint64_t TEST_METHOD(const char* CLASS, const char *METHOD) {
  //std::cerr << CLASS << "::" << METHOD << std::endl;
  return ( (uint64_t(DJBH(CLASS))<<32) | uint32_t(DJBH(METHOD)) ); 
} 
M
Matias Romeo 已提交
127

128 129
#define CALL_TEST_FUNCTION(TYPE, AUTH, DATA) CallFunction(chain, Message{"testapi", AUTH, TYPE}, DATA)
#define CALL_TEST_FUNCTION_SCOPE(TYPE, AUTH, DATA, SCOPE) CallFunction(chain, Message{"testapi", AUTH, TYPE}, DATA, SCOPE)
130 131 132 133 134 135 136 137 138 139 140 141

bool is_access_violation(fc::unhandled_exception const & e) {
   try {
      std::rethrow_exception(e.get_inner_exception());
    }
    catch (const Runtime::Exception& e) {
      return e.cause == Runtime::Exception::Cause::accessViolation;
    } catch (...) {

    }
   return false;
}
M
Matias Romeo 已提交
142 143 144

bool is_tx_missing_recipient(tx_missing_recipient const & e) { return true;}
bool is_tx_missing_auth(tx_missing_auth const & e) { return true; }
145
bool is_tx_missing_scope(tx_missing_scope const& e) { return true; }
146 147
bool is_tx_resource_exhausted(tx_resource_exhausted const & e) { return true; }
bool is_tx_unknown_argument(tx_unknown_argument const & e) { return true; }
M
Matias Romeo 已提交
148 149
bool is_assert_exception(fc::assert_exception const & e) { return true; }

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
std::vector<std::string> capture;

struct MySink : public bio::sink
{

   std::streamsize write(const char* s, std::streamsize n)
   {
      std::string tmp;
      tmp.assign(s, n);
      capture.push_back(tmp);
      std::cout << "stream : [" << tmp << "]" << std::endl;
      return n;
   }
};
uint32_t last_fnc_err = 0;
#define CAPTURE(STREAM, EXEC) \
   {\
      capture.clear(); \
      bio::stream_buffer<MySink> sb; sb.open(MySink()); \
      std::streambuf *oldbuf = std::STREAM.rdbuf(&sb); \
      last_fnc_err = EXEC; \
      std::STREAM.rdbuf(oldbuf); \
   }

174 175 176 177 178 179 180 181
void send_set_code_message(testing_blockchain& chain, types::setcode& handler, AccountName account)
{
   eos::chain::SignedTransaction trx;
   handler.account = account;
   trx.scope = { account };
   trx.messages.resize(1);
   trx.messages[0].authorization = {{account,"active"}};
   trx.messages[0].code = config::EosContractName;
182
   transaction_set_message(trx, 0, "setcode", handler);
183
   trx.expiration = chain.head_block_time() + 100;
184
   transaction_set_reference_block(trx, chain.head_block_id());
185 186 187
   chain.push_transaction(trx);
   chain.produce_blocks(1);
}
188

M
Matias Romeo 已提交
189 190
BOOST_FIXTURE_TEST_CASE(test_all, testing_fixture)
{ try {
191 192
      //auto wasm = assemble_wast( readFile2("/home/matu/Documents/Dev/eos/contracts/test_api/test_api.wast").c_str() );
      auto wasm = assemble_wast( test_api_wast );
M
Matias Romeo 已提交
193 194 195

      Make_Blockchain(chain);
      chain.produce_blocks(2);
196
      Make_Account(chain, testapi);
197
      Make_Account(chain, another);
M
Matias Romeo 已提交
198 199 200 201 202 203 204
      Make_Account(chain, acc1);
      Make_Account(chain, acc2);
      Make_Account(chain, acc3);
      Make_Account(chain, acc4);
      chain.produce_blocks(1);

      //Set test code
205 206 207 208 209 210 211
      types::setcode handler;
      handler.code.resize(wasm.size());
      memcpy( handler.code.data(), wasm.data(), wasm.size() );

      send_set_code_message(chain, handler, "testapi");
      send_set_code_message(chain, handler, "acc1");
      send_set_code_message(chain, handler, "acc2");
M
Matias Romeo 已提交
212 213

      //Test types
214 215 216 217
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_types", "types_size"),     {}, {} ) == WASM_TEST_PASS, "test_types::types_size()" );
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_types", "char_to_symbol"), {}, {} ) == WASM_TEST_PASS, "test_types::char_to_symbol()" );
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_types", "string_to_name"), {}, {} ) == WASM_TEST_PASS, "test_types::string_to_name()" );
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_types", "name_class"),     {}, {} ) == WASM_TEST_PASS, "test_types::name_class()" );
M
Matias Romeo 已提交
218 219 220

      //Test message
      dummy_message dummy13{DUMMY_MESSAGE_DEFAULT_A, DUMMY_MESSAGE_DEFAULT_B, DUMMY_MESSAGE_DEFAULT_C};
221
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "read_message"), {}, fc::raw::pack(dummy13) ) == WASM_TEST_PASS, "test_message::read_message()" );
M
Matias Romeo 已提交
222

223
      std::vector<char> raw_bytes((1<<16));
224
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "read_message_to_0"), {}, raw_bytes) == WASM_TEST_PASS, "test_message::read_message_to_0()" );
M
Matias Romeo 已提交
225

226
      raw_bytes.resize((1<<16)+1);
227
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "read_message_to_0"), {}, raw_bytes), 
228
         fc::unhandled_exception, is_access_violation );
M
Matias Romeo 已提交
229

230
      raw_bytes.resize(1);
231
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "read_message_to_64k"), {}, raw_bytes) == WASM_TEST_PASS, "test_message::read_message_to_64k()" );
M
Matias Romeo 已提交
232

233
      raw_bytes.resize(2);
234
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "read_message_to_64k"), {}, raw_bytes), 
235 236
         fc::unhandled_exception, is_access_violation );
      
237
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "require_notice"), {}, raw_bytes) == WASM_TEST_PASS, "test_message::require_notice()" );
M
Matias Romeo 已提交
238

239
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "require_auth"), {}, {}), 
M
Matias Romeo 已提交
240
         tx_missing_auth, is_tx_missing_auth );
241
      
M
Matias Romeo 已提交
242
      auto a3only = vector<types::AccountPermission>{{"acc3","active"}};
243
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "require_auth"), a3only, {}), 
M
Matias Romeo 已提交
244 245 246
         tx_missing_auth, is_tx_missing_auth );

      auto a4only = vector<types::AccountPermission>{{"acc4","active"}};
247
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "require_auth"), a4only, {}),
M
Matias Romeo 已提交
248 249 250
         tx_missing_auth, is_tx_missing_auth );

      auto a3a4 = vector<types::AccountPermission>{{"acc3","active"}, {"acc4","active"}};
251
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "require_auth"), a3a4, {}) == WASM_TEST_PASS, "test_message::require_auth()");
M
Matias Romeo 已提交
252

253
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "assert_false"), {}, {}),
M
Matias Romeo 已提交
254 255
         fc::assert_exception, is_assert_exception );

256
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "assert_true"), {}, {}) == WASM_TEST_PASS, "test_message::assert_true()");
M
Matias Romeo 已提交
257 258 259 260

      chain.produce_blocks(1);
      
      uint32_t now = chain.head_block_time().sec_since_epoch();
261
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "now"), {}, fc::raw::pack(now)) == WASM_TEST_PASS, "test_message::now()");
M
Matias Romeo 已提交
262 263

      chain.produce_blocks(1);
264
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_message", "now"), {}, fc::raw::pack(now)) == WASM_TEST_FAIL, "test_message::now()");
265 266

      //Test print
267
      CAPTURE(cerr, CALL_TEST_FUNCTION( TEST_METHOD("test_print", "test_prints"), {}, {}) );
268 269 270 271 272 273 274 275 276 277 278
      
      BOOST_CHECK_EQUAL( last_fnc_err , WASM_TEST_PASS);
      BOOST_CHECK_EQUAL( capture.size() , 3);
      BOOST_CHECK_EQUAL( (capture[0] == "ab" && capture[1] == "c" && capture[2] == "efg") , true);

      auto U64Str = [](uint64_t v) -> std::string { 
         std::stringstream s;
         s << v;
         return s.str();
      };

279
      CAPTURE(cerr, CALL_TEST_FUNCTION( TEST_METHOD("test_print", "test_printi"), {}, {}) );
280 281 282 283 284 285 286 287 288 289
      BOOST_CHECK_EQUAL( capture.size() , 3);
      BOOST_CHECK_EQUAL( capture[0], U64Str(0) );
      BOOST_CHECK_EQUAL( capture[1], U64Str(556644) );
      BOOST_CHECK_EQUAL( capture[2], U64Str(-1) );

      auto U128Str = [](uint128_t value) -> std::string { 
        fc::uint128_t v(value>>64, uint64_t(value) );
        return fc::variant(v).get_string();
      };

290
      CAPTURE(cerr, CALL_TEST_FUNCTION( TEST_METHOD("test_print", "test_printi128"), {}, {}) );
291 292 293 294 295
      BOOST_CHECK_EQUAL( capture.size() , 3);
      BOOST_CHECK_EQUAL( capture[0], U128Str(-1));
      BOOST_CHECK_EQUAL( capture[1], U128Str(0));
      BOOST_CHECK_EQUAL( capture[2], U128Str(87654323456));

296
      CAPTURE(cerr, CALL_TEST_FUNCTION( TEST_METHOD("test_print", "test_printn"), {}, {}) );
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
      BOOST_CHECK_EQUAL( capture.size() , 8);
      BOOST_CHECK_EQUAL( (
         capture[0] == "abcde" && 
         capture[1] == "ab.de"  && 
         capture[2] == "1q1q1q" &&
         capture[3] == "abcdefghijk" &&
         capture[4] == "abcdefghijkl" &&
         capture[5] == "abcdefghijklm" &&
         capture[6] == "abcdefghijklm" &&
         capture[7] == "abcdefghijklm" 
      ), true);

      //Test math
      std::random_device rd;
      std::mt19937_64 gen(rd());
      std::uniform_int_distribution<unsigned long long> dis;

      for(int i=0; i<10; i++) {
         u128_msg msg;
         msg.values[0] = dis(gen); msg.values[0] <<= 64; msg.values[0] |= dis(gen);
         msg.values[1] = dis(gen); msg.values[1] <<= 64; msg.values[1] |= dis(gen);
         msg.values[2] = msg.values[0] * msg.values[1];
319
         BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_math", "test_multeq_i128"), {}, fc::raw::pack(msg) ) == WASM_TEST_PASS, "test_math::test_multeq_i128()" );
320 321 322 323 324 325 326
      }

      for(int i=0; i<10; i++) {
         u128_msg msg;
         msg.values[0] = dis(gen); msg.values[0] <<= 64; msg.values[0] |= dis(gen);
         msg.values[1] = dis(gen); msg.values[1] <<= 64; msg.values[1] |= dis(gen);
         msg.values[2] = msg.values[0] / msg.values[1];
327
         BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_math", "test_diveq_i128"), {}, fc::raw::pack(msg) ) == WASM_TEST_PASS, "test_math::test_diveq_i128()" );
328 329
      }

330
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_math", "test_diveq_i128_by_0"), {}, {} ),
331 332
         fc::assert_exception, is_assert_exception );

333 334 335 336 337
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_math", "test_double_api"), {}, {} ) == WASM_TEST_PASS, "test_math::test_double_api()" );

      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_math", "test_double_api_div_0"), {}, {} ),
      fc::assert_exception, is_assert_exception );
      
338
      //Test db (i64)
339
      const auto& idx = chain_db.get_index<key_value_index, by_scope_primary>();
340

341
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_general"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i64_general()" );
342 343
      BOOST_CHECK_EQUAL( std::distance(idx.begin(), idx.end()) , 4);
      
344
      auto itr = idx.lower_bound( boost::make_tuple( N(testapi), N(testapi), N(test_table)) );
345

346 347 348 349
      BOOST_CHECK_EQUAL((uint64_t)itr->primary_key, N(alice)); ++itr;
      BOOST_CHECK_EQUAL((uint64_t)itr->primary_key, N(bob)); ++itr;
      BOOST_CHECK_EQUAL((uint64_t)itr->primary_key, N(carol)); ++itr;
      BOOST_CHECK_EQUAL((uint64_t)itr->primary_key, N(dave));
350

351
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_remove_all"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i64_remove_all()" );
352 353
      BOOST_CHECK_EQUAL( std::distance(idx.begin(), idx.end()) , 0);

354
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_small_load"), {}, {} ),
355 356
         fc::assert_exception, is_assert_exception );

357
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_small_store"), {}, {} ),
358 359
         fc::assert_exception, is_assert_exception );

360
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION_SCOPE( TEST_METHOD("test_db", "key_i64_store_scope"), {}, {}, {N(another)} ),
361 362
         tx_missing_scope, is_tx_missing_scope );

363
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION_SCOPE( TEST_METHOD("test_db", "key_i64_remove_scope"), {}, {}, {N(another)} ),
364
         tx_missing_scope, is_tx_missing_scope );
M
Matias Romeo 已提交
365

366
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_not_found"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i64_not_found()" );
M
Matias Romeo 已提交
367
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64_front_back"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i64_front_back()" );
368 369 370

      //Test db (i128i128)
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i128i128_general"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i128i128_general()" );
M
Matias Romeo 已提交
371

372 373 374
      //Test db (i64i64i64)
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_db", "key_i64i64i64_general"), {}, {} ) == WASM_TEST_PASS, "test_db::key_i64i64i64_general()" );

M
Matias Romeo 已提交
375 376 377 378 379 380 381 382 383 384
      //Test crypto
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_crypto", "test_sha256"), {}, {} ) == WASM_TEST_PASS, "test_crypto::test_sha256()" );
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_crypto", "sha256_no_data"), {}, {} ),
         fc::assert_exception, is_assert_exception );
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_crypto", "asert_sha256_false"), {}, {} ),
         fc::assert_exception, is_assert_exception );
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_crypto", "asert_sha256_true"), {}, {} ) == WASM_TEST_PASS, "test_crypto::asert_sha256_true()" );
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_crypto", "asert_no_data"), {}, {} ),
         fc::assert_exception, is_assert_exception );

385 386
      //Test transaction
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message"), {}, {}) == WASM_TEST_PASS, "test_transaction::send_message()");
387
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message_empty"), {}, {}) == WASM_TEST_PASS, "test_transaction::send_message_empty()");
388 389 390 391
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message_large"), {}, {} ),
         tx_resource_exhausted, is_tx_resource_exhausted );
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message_max"), {}, {} ),
         tx_resource_exhausted, is_tx_resource_exhausted );
392 393
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message_recurse"), {}, fc::raw::pack(dummy13) ),
         tx_resource_exhausted, is_tx_resource_exhausted );
394 395
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_message_inline_fail"), {}, {} ),
         fc::assert_exception, is_assert_exception );
396
      BOOST_CHECK_MESSAGE( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_transaction"), {}, {}) == WASM_TEST_PASS, "test_transaction::send_message()");
397 398
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_transaction_empty"), {}, {} ),
         tx_unknown_argument, is_tx_unknown_argument );
399 400 401 402 403 404
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_transaction_large"), {}, {} ),
         tx_resource_exhausted, is_tx_resource_exhausted );
      BOOST_CHECK_EXCEPTION( CALL_TEST_FUNCTION( TEST_METHOD("test_transaction", "send_transaction_max"), {}, {} ),
         tx_resource_exhausted, is_tx_resource_exhausted );


M
Matias Romeo 已提交
405

M
Matias Romeo 已提交
406 407 408 409
} FC_LOG_AND_RETHROW() }


BOOST_AUTO_TEST_SUITE_END()