test_api.cpp 6.5 KB
Newer Older
1 2 3 4
/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */
5
#include <eoslib/eos.hpp>
M
Matias Romeo 已提交
6 7
#include "test_api.hpp"

8
#include "test_account.cpp"
9 10 11 12
#include "test_chain.cpp"
#include "test_crypto.cpp"
#include "test_db.cpp"
#include "test_math.cpp"
13
#include "test_action.cpp"
14 15
#include "test_print.cpp"
#include "test_string.cpp"
16 17
#include "test_fixedpoint.cpp"
#include "test_real.cpp"
18 19 20
#include "test_transaction.cpp"
#include "test_types.cpp"

M
Matias Romeo 已提交
21 22 23 24 25 26 27
extern "C" {

    void init()  {

    }

   void apply( unsigned long long code, unsigned long long action ) {
28

P
Pravin 已提交
29
      //eosio::print("==> CONTRACT: ", code, " ", action, "\n");
30

M
Matias Romeo 已提交
31
      //test_types
32 33 34 35 36
      WASM_TEST_HANDLER(test_types, types_size);
      WASM_TEST_HANDLER(test_types, char_to_symbol);
      WASM_TEST_HANDLER(test_types, string_to_name);
      WASM_TEST_HANDLER(test_types, name_class);

37 38 39 40 41 42 43 44 45
      //test_action
      WASM_TEST_HANDLER(test_action, read_action_normal);
      WASM_TEST_HANDLER(test_action, read_action_to_0);
      WASM_TEST_HANDLER(test_action, read_action_to_64k);
      WASM_TEST_HANDLER(test_action, require_notice);
      WASM_TEST_HANDLER(test_action, require_auth);
      WASM_TEST_HANDLER(test_action, assert_false);
      WASM_TEST_HANDLER(test_action, assert_true);
      WASM_TEST_HANDLER(test_action, now);
M
Matias Romeo 已提交
46 47

      //test_print
48 49 50 51
      WASM_TEST_HANDLER(test_print, test_prints);
      WASM_TEST_HANDLER(test_print, test_printi);
      WASM_TEST_HANDLER(test_print, test_printi128);
      WASM_TEST_HANDLER(test_print, test_printn);
M
Matias Romeo 已提交
52 53

      //test_math
54 55 56
      WASM_TEST_HANDLER(test_math, test_multeq_i128);
      WASM_TEST_HANDLER(test_math, test_diveq_i128);
      WASM_TEST_HANDLER(test_math, test_diveq_i128_by_0);
M
Matias Romeo 已提交
57 58 59
      WASM_TEST_HANDLER(test_math, test_double_api);
      WASM_TEST_HANDLER(test_math, test_double_api_div_0);

60 61 62 63 64 65 66 67 68

      //test db
      WASM_TEST_HANDLER(test_db, key_i64_general);
      WASM_TEST_HANDLER(test_db, key_i64_remove_all);
      WASM_TEST_HANDLER(test_db, key_i64_small_load);
      WASM_TEST_HANDLER(test_db, key_i64_small_store);
      WASM_TEST_HANDLER(test_db, key_i64_store_scope);
      WASM_TEST_HANDLER(test_db, key_i64_remove_scope);
      WASM_TEST_HANDLER(test_db, key_i64_not_found);
M
Matias Romeo 已提交
69
      WASM_TEST_HANDLER(test_db, key_i64_front_back);
70
      WASM_TEST_HANDLER(test_db, key_i64i64i64_general);
71
      WASM_TEST_HANDLER(test_db, key_i128i128_general);
72
      WASM_TEST_HANDLER(test_db, key_str_general);
73
      WASM_TEST_HANDLER(test_db, key_str_table);
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
      WASM_TEST_HANDLER(test_db, key_str_setup_limit);
      WASM_TEST_HANDLER(test_db, key_str_min_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_str_under_limit);
      WASM_TEST_HANDLER(test_db, key_str_available_space_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_str_another_under_limit);
      WASM_TEST_HANDLER(test_db, key_i64_setup_limit);
      WASM_TEST_HANDLER(test_db, key_i64_min_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i64_under_limit);
      WASM_TEST_HANDLER(test_db, key_i64_available_space_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i64_another_under_limit);
      WASM_TEST_HANDLER(test_db, key_i128i128_setup_limit);
      WASM_TEST_HANDLER(test_db, key_i128i128_min_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i128i128_under_limit);
      WASM_TEST_HANDLER(test_db, key_i128i128_available_space_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i128i128_another_under_limit);
      WASM_TEST_HANDLER(test_db, key_i64i64i64_setup_limit);
      WASM_TEST_HANDLER(test_db, key_i64i64i64_min_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i64i64i64_under_limit);
      WASM_TEST_HANDLER(test_db, key_i64i64i64_available_space_exceed_limit);
      WASM_TEST_HANDLER(test_db, key_i64i64i64_another_under_limit);
94

95 96 97 98 99 100 101
      //test crypto
      WASM_TEST_HANDLER(test_crypto, test_sha256);
      WASM_TEST_HANDLER(test_crypto, sha256_no_data);
      WASM_TEST_HANDLER(test_crypto, asert_sha256_false);
      WASM_TEST_HANDLER(test_crypto, asert_sha256_true);
      WASM_TEST_HANDLER(test_crypto, asert_no_data);

102 103
      //test transaction
      WASM_TEST_HANDLER(test_transaction, send_message);
104
      WASM_TEST_HANDLER(test_transaction, send_message_empty);
105 106
      WASM_TEST_HANDLER(test_transaction, send_message_max);
      WASM_TEST_HANDLER(test_transaction, send_message_large);
107
      WASM_TEST_HANDLER(test_transaction, send_message_recurse);
108
      WASM_TEST_HANDLER(test_transaction, send_message_inline_fail);
109
      WASM_TEST_HANDLER(test_transaction, send_transaction);
110
      WASM_TEST_HANDLER(test_transaction, send_transaction_empty);
111 112
      WASM_TEST_HANDLER(test_transaction, send_transaction_max);
      WASM_TEST_HANDLER(test_transaction, send_transaction_large);
A
Andrianto Lie 已提交
113

M
Matias Romeo 已提交
114 115 116
      //test chain
      WASM_TEST_HANDLER(test_chain, test_activeprods);

A
Andrianto Lie 已提交
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
      // test string
      WASM_TEST_HANDLER(test_string, construct_with_size);
      WASM_TEST_HANDLER(test_string, construct_with_data);
      WASM_TEST_HANDLER(test_string, construct_with_data_copied);
      WASM_TEST_HANDLER(test_string, construct_with_data_partially);
      WASM_TEST_HANDLER(test_string, copy_constructor);
      WASM_TEST_HANDLER(test_string, assignment_operator);
      WASM_TEST_HANDLER(test_string, index_operator);
      WASM_TEST_HANDLER(test_string, index_out_of_bound);
      WASM_TEST_HANDLER(test_string, substring);
      WASM_TEST_HANDLER(test_string, substring_out_of_bound);
      WASM_TEST_HANDLER(test_string, concatenation_null_terminated);
      WASM_TEST_HANDLER(test_string, concatenation_non_null_terminated);
      WASM_TEST_HANDLER(test_string, assign);
      WASM_TEST_HANDLER(test_string, comparison_operator);
      WASM_TEST_HANDLER(test_string, print_null_terminated);
      WASM_TEST_HANDLER(test_string, print_non_null_terminated);
      WASM_TEST_HANDLER(test_string, print_unicode);
135 136
      WASM_TEST_HANDLER(test_string, valid_utf8);
      WASM_TEST_HANDLER(test_string, invalid_utf8);
A
Andrianto Lie 已提交
137
      WASM_TEST_HANDLER(test_string, string_literal);
A
Andrianto Lie 已提交
138

139 140 141 142 143 144 145 146 147 148 149 150 151
      // test fixed_point
      WASM_TEST_HANDLER(test_fixedpoint, create_instances);
      WASM_TEST_HANDLER(test_fixedpoint, test_addition);
      WASM_TEST_HANDLER(test_fixedpoint, test_subtraction);
      WASM_TEST_HANDLER(test_fixedpoint, test_multiplication);
      WASM_TEST_HANDLER(test_fixedpoint, test_division);


      // test double
      WASM_TEST_HANDLER(test_real, create_instances);
      WASM_TEST_HANDLER(test_real, test_addition);
      WASM_TEST_HANDLER(test_real, test_multiplication);
      WASM_TEST_HANDLER(test_real, test_division);
152 153 154 155

      // test account
      WASM_TEST_HANDLER(test_account, test_balance_acc1);

156 157
      //unhandled test call
      WASM_TEST_ERROR_CODE = WASM_TEST_FAIL;
M
Matias Romeo 已提交
158 159 160
   }

}