test_api.cpp 7.1 KB
Newer Older
1 2 3 4
/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */
5
#include <eosiolib/eosio.hpp>
6

M
Matias Romeo 已提交
7
#include "test_api.hpp"
8 9 10
#include "test_action.cpp"
#include "test_print.cpp"
#include "test_types.cpp"
B
Bucky Kittinger 已提交
11
#include "test_fixedpoint.cpp"
12
#include "test_math.cpp"
B
Bucky Kittinger 已提交
13 14 15 16
#include "test_compiler_builtins.cpp"
#include "test_real.cpp"
#include "test_crypto.cpp"
#include "test_chain.cpp"
17
#include "test_transaction.cpp"
B
Bucky Kittinger 已提交
18
#include "test_checktime.cpp"
M
Matias Romeo 已提交
19
#include "test_permission.cpp"
20

M
Matias Romeo 已提交
21 22
extern "C" {

23
   void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
P
Pravin 已提交
24
      //eosio::print("==> CONTRACT: ", code, " ", action, "\n");
M
Matias Romeo 已提交
25
      //test_types
26 27 28 29 30
      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);

B
Bucky Kittinger 已提交
31 32 33 34
      //test_compiler_builtins
      WASM_TEST_HANDLER(test_compiler_builtins, test_multi3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_divti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_divti3_by_0);
B
Bucky Kittinger 已提交
35 36 37 38 39 40
      WASM_TEST_HANDLER(test_compiler_builtins, test_udivti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_udivti3_by_0);
      WASM_TEST_HANDLER(test_compiler_builtins, test_modti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_modti3_by_0);
      WASM_TEST_HANDLER(test_compiler_builtins, test_umodti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_umodti3_by_0);
B
Bucky Kittinger 已提交
41
      WASM_TEST_HANDLER(test_compiler_builtins, test_lshlti3);
42 43 44
      WASM_TEST_HANDLER(test_compiler_builtins, test_lshrti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_ashlti3);
      WASM_TEST_HANDLER(test_compiler_builtins, test_ashrti3);
B
Bucky Kittinger 已提交
45

46
      //test_action
47 48 49
      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);
50
      WASM_TEST_HANDLER_EX(test_action, require_notice);
51
      WASM_TEST_HANDLER(test_action, require_auth);
52 53
      WASM_TEST_HANDLER(test_action, assert_false);
      WASM_TEST_HANDLER(test_action, assert_true);
B
Bucky Kittinger 已提交
54
      WASM_TEST_HANDLER(test_action, now);
B
Bucky Kittinger 已提交
55
      WASM_TEST_HANDLER(test_action, test_abort);
56
      WASM_TEST_HANDLER_EX(test_action, test_current_receiver);
B
Bucky Kittinger 已提交
57 58
      WASM_TEST_HANDLER(test_action, test_current_sender);
      WASM_TEST_HANDLER(test_action, test_publication_time);
M
Matias Romeo 已提交
59

K
Kevin Heifner 已提交
60 61 62 63 64
      // test named actions
      // We enforce action name matches action data type name, so name mangling will not work for these tests.
      if ( action == N(dummy_action) ) {
         test_action::test_dummy_action();
         return;
65 66 67
      } else if ( action == N(cf_action) ) {
         test_action::test_cf_action();
         return;
K
Kevin Heifner 已提交
68 69
      }

M
Matias Romeo 已提交
70
      //test_print
71
      WASM_TEST_HANDLER(test_print, test_prints);
B
Bucky Kittinger 已提交
72
      WASM_TEST_HANDLER(test_print, test_prints_l);
73
      WASM_TEST_HANDLER(test_print, test_printi);
74
      WASM_TEST_HANDLER(test_print, test_printui);
75 76
      WASM_TEST_HANDLER(test_print, test_printi128);
      WASM_TEST_HANDLER(test_print, test_printn);
M
Matias Romeo 已提交
77

78 79 80
      //test_math
      WASM_TEST_HANDLER(test_math, test_multeq);
      WASM_TEST_HANDLER(test_math, test_diveq);
B
Bucky Kittinger 已提交
81 82
      WASM_TEST_HANDLER(test_math, test_i64_to_double);
      WASM_TEST_HANDLER(test_math, test_double_to_i64);
83 84 85 86 87
      WASM_TEST_HANDLER(test_math, test_diveq_by_0);
      WASM_TEST_HANDLER(test_math, test_double_api);
      WASM_TEST_HANDLER(test_math, test_double_api_div_0);

      //test crypto
B
Bucky Kittinger 已提交
88
      WASM_TEST_HANDLER(test_crypto, test_recover_key);
B
Bucky Kittinger 已提交
89 90
      WASM_TEST_HANDLER(test_crypto, test_recover_key_assert_true);
      WASM_TEST_HANDLER(test_crypto, test_recover_key_assert_false);
B
Bucky Kittinger 已提交
91
      WASM_TEST_HANDLER(test_crypto, test_sha1);
92
      WASM_TEST_HANDLER(test_crypto, test_sha256);
B
Bucky Kittinger 已提交
93 94 95
      WASM_TEST_HANDLER(test_crypto, test_sha512);
      WASM_TEST_HANDLER(test_crypto, test_ripemd160);
      WASM_TEST_HANDLER(test_crypto, sha1_no_data);
96
      WASM_TEST_HANDLER(test_crypto, sha256_no_data);
B
Bucky Kittinger 已提交
97 98
      WASM_TEST_HANDLER(test_crypto, sha512_no_data);
      WASM_TEST_HANDLER(test_crypto, ripemd160_no_data);
B
Bucky Kittinger 已提交
99 100 101
      WASM_TEST_HANDLER(test_crypto, sha256_null);
      WASM_TEST_HANDLER(test_crypto, assert_sha256_false);
      WASM_TEST_HANDLER(test_crypto, assert_sha256_true);
B
Bucky Kittinger 已提交
102 103 104 105 106 107
      WASM_TEST_HANDLER(test_crypto, assert_sha1_false);
      WASM_TEST_HANDLER(test_crypto, assert_sha1_true);
      WASM_TEST_HANDLER(test_crypto, assert_sha512_false);
      WASM_TEST_HANDLER(test_crypto, assert_sha512_true);
      WASM_TEST_HANDLER(test_crypto, assert_ripemd160_false);
      WASM_TEST_HANDLER(test_crypto, assert_ripemd160_true);
108 109

      //test transaction
B
Bucky Kittinger 已提交
110 111
      WASM_TEST_HANDLER(test_transaction, test_tapos_block_num);
      WASM_TEST_HANDLER(test_transaction, test_tapos_block_prefix);
B
Bucky Kittinger 已提交
112
      WASM_TEST_HANDLER(test_transaction, send_action);
B
Bucky Kittinger 已提交
113
      WASM_TEST_HANDLER(test_transaction, send_action_inline_fail);
B
Bucky Kittinger 已提交
114 115 116
      WASM_TEST_HANDLER(test_transaction, send_action_empty);
      WASM_TEST_HANDLER(test_transaction, send_action_large);
      WASM_TEST_HANDLER(test_transaction, send_action_recurse);
B
Bucky Kittinger 已提交
117 118
      WASM_TEST_HANDLER(test_transaction, test_read_transaction);
      WASM_TEST_HANDLER(test_transaction, test_transaction_size);
119 120 121
      WASM_TEST_HANDLER(test_transaction, send_transaction);
      WASM_TEST_HANDLER(test_transaction, send_transaction_empty);
      WASM_TEST_HANDLER(test_transaction, send_transaction_large);
B
Bucky Kittinger 已提交
122
      WASM_TEST_HANDLER(test_transaction, send_action_sender);
123 124 125
      WASM_TEST_HANDLER(test_transaction, deferred_print);
      WASM_TEST_HANDLER(test_transaction, send_deferred_transaction);
      WASM_TEST_HANDLER(test_transaction, cancel_deferred_transaction);
M
Matias Romeo 已提交
126 127
      WASM_TEST_HANDLER(test_transaction, send_cf_action);
      WASM_TEST_HANDLER(test_transaction, send_cf_action_fail);
128 129
      WASM_TEST_HANDLER(test_transaction, read_inline_action);
      WASM_TEST_HANDLER(test_transaction, read_inline_cf_action);
130 131 132 133 134 135 136 137 138 139

      //test chain
      WASM_TEST_HANDLER(test_chain, test_activeprods);

      // 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);
B
Bucky Kittinger 已提交
140
      WASM_TEST_HANDLER(test_fixedpoint, test_division_by_0);
141 142 143 144 145 146

      // 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);
B
Bucky Kittinger 已提交
147
      WASM_TEST_HANDLER(test_real, test_division_by_0);
148

B
Bucky Kittinger 已提交
149 150 151
      // test checktime
      WASM_TEST_HANDLER(test_checktime, checktime_pass);
      WASM_TEST_HANDLER(test_checktime, checktime_failure);
M
Matias Romeo 已提交
152

153
/*      
154
      // test softfloat
155 156 157 158 159
      WASM_TEST_HANDLER(test_softfloat, test_f32_add);
      WASM_TEST_HANDLER(test_softfloat, test_f32_sub);
      WASM_TEST_HANDLER(test_softfloat, test_f32_mul);
      WASM_TEST_HANDLER(test_softfloat, test_f32_div);
      WASM_TEST_HANDLER(test_softfloat, test_f32_min);
160
*/
161

M
Matias Romeo 已提交
162
      // test permission
163
      WASM_TEST_HANDLER_EX(test_permission, check_authorization);
M
Matias Romeo 已提交
164

165
      //unhandled test call
166
      eosio_assert(false, "Unknown Test");
167

M
Matias Romeo 已提交
168 169
   }
}