未验证 提交 48ce6805 编写于 作者: T Todd Fleming 提交者: GitHub

Merge pull request #5673 from EOSIO/abi-no-default-version

abi_def: don't default version
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
......
{
"version": "eosio::abi/1.0",
"____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-04-19T09:07:16",
"types": [],
"structs": [{
......
{
"____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-03-29T02:09:11",
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
......
......@@ -107,8 +107,7 @@ struct may_not_exist {
struct abi_def {
abi_def() = default;
abi_def(const vector<type_def>& types, const vector<struct_def>& structs, const vector<action_def>& actions, const vector<table_def>& tables, const vector<clause_pair>& clauses, const vector<error_message>& error_msgs)
:version("eosio::abi/1.1")
,types(types)
:types(types)
,structs(structs)
,actions(actions)
,tables(tables)
......@@ -116,7 +115,7 @@ struct abi_def {
,error_messages(error_msgs)
{}
string version = "eosio::abi/1.1";
string version = "";
vector<type_def> types;
vector<struct_def> structs;
vector<action_def> actions;
......
......@@ -86,6 +86,7 @@ int main(int argc, const char **argv) { abi_def output; try {
vector<string> actions;
int result = Tool.run(create_find_macro_factory(contract, actions, abi_context).get());
if(!result) {
output.version = "eosio::abi/1.0";
result = Tool.run(create_factory(abi_verbose, abi_opt_sfs, abi_context, output, contract, actions).get());
if(!result) {
abi_serializer abis(output, fc::seconds(1)); // No risk to client side serialization taking a long time
......
......@@ -495,6 +495,7 @@ BOOST_AUTO_TEST_CASE(uint_types)
const char* currency_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "transfer",
......@@ -556,6 +557,7 @@ struct abi_gen_helper {
std::string stdc_include_param = std::string("-I") + eosiolib_path + "/musl/upstream/include";
abi_def output;
output.version = "eosio::abi/1.0";
std::string contract;
std::vector<std::string> actions;
......@@ -662,6 +664,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_all_types, abi_gen_helper)
const char* all_types_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "test_struct",
......@@ -809,6 +812,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_double_action, abi_gen_helper)
const char* double_action_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name" : "A",
......@@ -870,7 +874,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_all_indexes, abi_gen_helper)
const char* all_indexes_abi = R"=====(
{
"version": "eosio::abi/1.1",
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "table1",
......@@ -1027,6 +1031,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_full_table_decl, abi_gen_helper)
const char* full_table_decl_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name" : "table1",
......@@ -1125,6 +1130,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_template_base, abi_gen_helper)
const char* template_base_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name" : "base32",
......@@ -1180,6 +1186,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_action_and_table, abi_gen_helper)
const char* action_and_table_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name" : "table_action",
......@@ -1239,6 +1246,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_simple_typedef, abi_gen_helper)
const char* simple_typedef_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name" : "my_base_alias",
"type" : "common_params"
......@@ -1305,6 +1313,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_field_typedef, abi_gen_helper)
const char* field_typedef_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name" : "my_complex_field_alias",
"type" : "complex_field"
......@@ -1380,6 +1389,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_vector_of_POD, abi_gen_helper)
const char* abigen_vector_of_POD_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "table1",
......@@ -1453,6 +1463,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_vector_of_structs, abi_gen_helper)
const char* abigen_vector_of_structs_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "my_struct",
......@@ -1558,6 +1569,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_vector_alias, abi_gen_helper)
const char* abigen_vector_alias_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "array_of_rows",
"type": "row[]"
......@@ -1634,6 +1646,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_eosioabi_macro, abi_gen_helper)
const char* abigen_eosioabi_macro_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "hi",
......@@ -1696,6 +1709,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_contract_inheritance, abi_gen_helper)
const char* abigen_contract_inheritance_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "hi",
......@@ -1777,7 +1791,7 @@ BOOST_FIXTURE_TEST_CASE(abigen_no_eosioabi_macro, abi_gen_helper)
const char* abigen_no_eosioabi_macro_abi = R"=====(
{
"version": "eosio::abi/1.1",
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "hi",
......@@ -2047,6 +2061,7 @@ BOOST_AUTO_TEST_CASE(abi_cycle)
const char* struct_cycle_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "A",
......@@ -2783,6 +2798,7 @@ BOOST_AUTO_TEST_CASE(packed_transaction)
const char* packed_transaction_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "compression_type",
"type": "int64"
......@@ -2865,6 +2881,7 @@ BOOST_AUTO_TEST_CASE(abi_type_repeat)
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "actor_name",
"type": "name"
......@@ -2925,6 +2942,7 @@ BOOST_AUTO_TEST_CASE(abi_struct_repeat)
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "actor_name",
"type": "name"
......@@ -2981,6 +2999,7 @@ BOOST_AUTO_TEST_CASE(abi_action_repeat)
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "actor_name",
"type": "name"
......@@ -3040,6 +3059,7 @@ BOOST_AUTO_TEST_CASE(abi_table_repeat)
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "actor_name",
"type": "name"
......@@ -3102,6 +3122,7 @@ BOOST_AUTO_TEST_CASE(abi_type_def)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
......@@ -3154,6 +3175,7 @@ BOOST_AUTO_TEST_CASE(abi_type_loop)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
......@@ -3197,6 +3219,7 @@ BOOST_AUTO_TEST_CASE(abi_type_redefine)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "account_name"
......@@ -3237,6 +3260,7 @@ BOOST_AUTO_TEST_CASE(abi_type_redefine_to_name)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "name",
"type": "name"
......@@ -3258,6 +3282,7 @@ BOOST_AUTO_TEST_CASE(abi_type_nested_in_vector)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "store_t",
......@@ -3283,6 +3308,7 @@ BOOST_AUTO_TEST_CASE(abi_account_name_in_eosio_abi)
// inifinite loop in types
const char* repeat_abi = R"=====(
{
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "account_name",
"type": "name"
......@@ -3325,6 +3351,7 @@ BOOST_AUTO_TEST_CASE(abi_large_array)
try {
const char* abi_str = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "hi",
......@@ -3362,6 +3389,7 @@ BOOST_AUTO_TEST_CASE(abi_is_type_recursion)
try {
const char* abi_str = R"=====(
{
"version": "eosio::abi/1.0",
"types": [
{
"new_type_name": "a[]",
......@@ -3405,6 +3433,7 @@ BOOST_AUTO_TEST_CASE(abi_recursive_structs)
try {
const char* abi_str = R"=====(
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [
{
......@@ -3500,7 +3529,7 @@ BOOST_AUTO_TEST_CASE(abi_deep_structs_validate)
BOOST_AUTO_TEST_CASE(variants)
{
auto duplicate_variant_abi = R"({
"version": "eosio::abi/1.0",
"version": "eosio::abi/1.1",
"variants": [
{"name": "v1", "types": ["int8", "string", "bool"]},
{"name": "v1", "types": ["int8", "string", "bool"]},
......@@ -3508,14 +3537,14 @@ BOOST_AUTO_TEST_CASE(variants)
})";
auto variant_abi_invalid_type = R"({
"version": "eosio::abi/1.0",
"version": "eosio::abi/1.1",
"variants": [
{"name": "v1", "types": ["int91", "string", "bool"]},
],
})";
auto variant_abi = R"({
"version": "eosio::abi/1.0",
"version": "eosio::abi/1.1",
"types": [
{"new_type_name": "foo", "type": "s"},
{"new_type_name": "bar", "type": "s"},
......@@ -3566,6 +3595,7 @@ BOOST_AUTO_TEST_CASE(variants)
BOOST_AUTO_TEST_CASE(extend)
{
auto abi = R"({
"version": "eosio::abi/1.1",
"structs": [
{"name": "s", "base": "", "fields": [
{"name": "i0", "type": "int8"},
......@@ -3603,6 +3633,7 @@ BOOST_AUTO_TEST_CASE(extend)
BOOST_AUTO_TEST_CASE(version)
{
try {
BOOST_CHECK_THROW( abi_serializer(fc::json::from_string(R"({})").as<abi_def>(), max_serialization_time), unsupported_abi_version_exception );
BOOST_CHECK_THROW( abi_serializer(fc::json::from_string(R"({"version": ""})").as<abi_def>(), max_serialization_time), unsupported_abi_version_exception );
BOOST_CHECK_THROW( abi_serializer(fc::json::from_string(R"({"version": "eosio::abi/9.0"})").as<abi_def>(), max_serialization_time), unsupported_abi_version_exception );
abi_serializer(fc::json::from_string(R"({"version": "eosio::abi/1.0"})").as<abi_def>(), max_serialization_time);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册