test_api.cpp 6.7 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"
19

M
Matias Romeo 已提交
20
extern "C" {
21
   void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
B
Bucky Kittinger 已提交
22 23 24 25
      if ( action == N(cf_action) ) {
         test_action::test_cf_action();
         return;
      }
26
      require_auth(code); 
B
Bucky Kittinger 已提交
27

M
Matias Romeo 已提交
28
      //test_types
29 30 31 32 33
      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 已提交
34 35 36 37
      //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 已提交
38 39 40 41 42 43
      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 已提交
44
      WASM_TEST_HANDLER(test_compiler_builtins, test_lshlti3);
45 46 47
      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 已提交
48

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

K
Kevin Heifner 已提交
63 64 65 66 67
      // 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;
B
Bucky Kittinger 已提交
68
      } 
M
Matias Romeo 已提交
69
      //test_print
70
      WASM_TEST_HANDLER(test_print, test_prints);
B
Bucky Kittinger 已提交
71
      WASM_TEST_HANDLER(test_print, test_prints_l);
72
      WASM_TEST_HANDLER(test_print, test_printi);
73
      WASM_TEST_HANDLER(test_print, test_printui);
74 75
      WASM_TEST_HANDLER(test_print, test_printi128);
      WASM_TEST_HANDLER(test_print, test_printn);
M
Matias Romeo 已提交
76

77 78 79
      //test_math
      WASM_TEST_HANDLER(test_math, test_multeq);
      WASM_TEST_HANDLER(test_math, test_diveq);
B
Bucky Kittinger 已提交
80 81
      WASM_TEST_HANDLER(test_math, test_i64_to_double);
      WASM_TEST_HANDLER(test_math, test_double_to_i64);
82 83 84 85 86
      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 已提交
87
      WASM_TEST_HANDLER(test_crypto, test_recover_key);
B
Bucky Kittinger 已提交
88 89
      WASM_TEST_HANDLER(test_crypto, test_recover_key_assert_true);
      WASM_TEST_HANDLER(test_crypto, test_recover_key_assert_false);
B
Bucky Kittinger 已提交
90
      WASM_TEST_HANDLER(test_crypto, test_sha1);
91
      WASM_TEST_HANDLER(test_crypto, test_sha256);
B
Bucky Kittinger 已提交
92 93 94
      WASM_TEST_HANDLER(test_crypto, test_sha512);
      WASM_TEST_HANDLER(test_crypto, test_ripemd160);
      WASM_TEST_HANDLER(test_crypto, sha1_no_data);
95
      WASM_TEST_HANDLER(test_crypto, sha256_no_data);
B
Bucky Kittinger 已提交
96 97
      WASM_TEST_HANDLER(test_crypto, sha512_no_data);
      WASM_TEST_HANDLER(test_crypto, ripemd160_no_data);
B
Bucky Kittinger 已提交
98 99 100
      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 已提交
101 102 103 104 105 106
      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);
107 108

      //test transaction
B
Bucky Kittinger 已提交
109 110
      WASM_TEST_HANDLER(test_transaction, test_tapos_block_num);
      WASM_TEST_HANDLER(test_transaction, test_tapos_block_prefix);
B
Bucky Kittinger 已提交
111
      WASM_TEST_HANDLER(test_transaction, send_action);
B
Bucky Kittinger 已提交
112
      WASM_TEST_HANDLER(test_transaction, send_action_inline_fail);
B
Bucky Kittinger 已提交
113 114 115
      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 已提交
116 117
      WASM_TEST_HANDLER(test_transaction, test_read_transaction);
      WASM_TEST_HANDLER(test_transaction, test_transaction_size);
118 119 120
      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 已提交
121
      WASM_TEST_HANDLER(test_transaction, send_action_sender);
122 123 124
      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 已提交
125 126
      WASM_TEST_HANDLER(test_transaction, send_cf_action);
      WASM_TEST_HANDLER(test_transaction, send_cf_action_fail);
127 128
      WASM_TEST_HANDLER(test_transaction, read_inline_action);
      WASM_TEST_HANDLER(test_transaction, read_inline_cf_action);
129 130 131 132 133 134 135 136 137 138

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

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

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

152
      //unhandled test call
153
      eosio_assert(false, "Unknown Test");
154

M
Matias Romeo 已提交
155 156
   }
}