test_api.cpp 6.6 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 21 22 23 24 25
extern "C" {

    void init()  {

    }

26
   void apply( unsigned long long, unsigned long long action ) {
P
Pravin 已提交
27
      //eosio::print("==> CONTRACT: ", code, " ", action, "\n");
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 54
      WASM_TEST_HANDLER(test_action, require_notice);
      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 59 60 61
      WASM_TEST_HANDLER(test_action, test_abort);
      WASM_TEST_HANDLER(test_action, test_current_receiver);
      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;
68 69 70
      } else if ( action == N(cf_action) ) {
         test_action::test_cf_action();
         return;
K
Kevin Heifner 已提交
71 72
      }

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

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

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

      //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 已提交
136
      WASM_TEST_HANDLER(test_fixedpoint, test_division_by_0);
137 138 139 140 141 142

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

B
Bucky Kittinger 已提交
145 146 147
      // test checktime
      WASM_TEST_HANDLER(test_checktime, checktime_pass);
      WASM_TEST_HANDLER(test_checktime, checktime_failure);
148
/*      
149
      // test softfloat
150 151 152 153 154
      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);
155
*/
156

157
      //unhandled test call
158
      eosio_assert(false, "Unknown Test");
159

M
Matias Romeo 已提交
160 161
   }
}