-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EOSIO#395 from EOSIO/feature/auto
Feature/auto
- Loading branch information
Showing
24 changed files
with
1,670 additions
and
130 deletions.
There are no files selected for viewing
Submodule eosio_llvm
updated
7 files
+2 −3 | include/llvm/IR/Attributes.td | |
+10 −1 | include/llvm/Object/Wasm.h | |
+51 −7 | lib/Object/WasmObjectFile.cpp | |
+97 −10 | lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | |
+6 −1 | lib/Transforms/EosioApply/EosioApply.cpp | |
+1 −1 | tools/clang | |
+1 −1 | tools/lld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
#include <set> | ||
#include <stack> | ||
#include "system.hpp" | ||
|
||
namespace eosio { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <boost/test/unit_test.hpp> | ||
#include <eosio/testing/tester.hpp> | ||
#include <eosio/chain/abi_serializer.hpp> | ||
|
||
#include <Runtime/Runtime.h> | ||
|
||
#include <fc/variant_object.hpp> | ||
|
||
#include <contracts.hpp> | ||
|
||
using namespace eosio; | ||
using namespace eosio::testing; | ||
using namespace eosio::chain; | ||
using namespace eosio::testing; | ||
using namespace fc; | ||
|
||
using mvo = fc::mutable_variant_object; | ||
|
||
BOOST_AUTO_TEST_SUITE(codegen_tests) | ||
|
||
BOOST_FIXTURE_TEST_CASE( simple_tests, tester ) try { | ||
create_accounts( { N(test), N(eosio.token), N(someone) } ); | ||
produce_block(); | ||
|
||
set_code( N(eosio.token), contracts::transfer_wasm() ); | ||
set_abi( N(eosio.token), contracts::transfer_abi().data() ); | ||
|
||
set_code( N(someone), contracts::transfer_wasm() ); | ||
set_abi( N(someone), contracts::transfer_abi().data() ); | ||
|
||
set_code( N(test), contracts::simple_wasm() ); | ||
set_abi( N(test), contracts::simple_abi().data() ); | ||
produce_blocks(); | ||
push_action(N(test), N(test1), N(test), | ||
mvo() | ||
("nm", "bucky")); | ||
|
||
BOOST_CHECK_THROW(push_action(N(test), N(test1), N(test), mvo()("nm", "notbucky")), | ||
fc::exception); | ||
|
||
push_action(N(test), N(test2), N(test), | ||
mvo() | ||
("arg0", 33) | ||
("arg1", "some string")); | ||
BOOST_CHECK_THROW(push_action(N(test), N(test2), N(test), mvo() ("arg0", 30)("arg1", "some string")), fc::exception); | ||
BOOST_CHECK_THROW(push_action(N(test), N(test2), N(test), mvo() ("arg0", 33)("arg1", "not some string")), fc::exception); | ||
|
||
set_abi( N(test), contracts::simple_wrong_abi().data() ); | ||
produce_blocks(); | ||
|
||
BOOST_CHECK_THROW(push_action(N(test), N(test3), N(test), mvo() ("arg0", 33) ("arg1", "some string")), fc::exception); | ||
|
||
set_abi( N(test), contracts::simple_abi().data() ); | ||
produce_blocks(); | ||
|
||
push_action(N(test), N(test4), N(test), mvo() ("to", "someone")); | ||
push_action(N(test), N(test5), N(test), mvo() ("to", "someone")); | ||
push_action(N(test), N(testa), N(test), mvo() ("to", "someone")); | ||
BOOST_CHECK_THROW(push_action(N(test), N(testb), N(test), mvo() ("to", "someone")), fc::exception); | ||
|
||
} FC_LOG_AND_RETHROW() | ||
|
||
BOOST_FIXTURE_TEST_CASE( simple_eosio_tests, tester ) try { | ||
set_code( N(eosio), contracts::simple_wasm() ); | ||
set_abi( N(eosio), contracts::simple_wrong_abi().data() ); | ||
produce_blocks(); | ||
push_action(N(eosio), N(test1), N(eosio), | ||
mvo() | ||
("nm", "bucky")); | ||
|
||
BOOST_CHECK_THROW(push_action(N(eosio), N(test1), N(eosio), mvo()("nm", "notbucky")), | ||
fc::exception); | ||
|
||
push_action(N(eosio), N(test2), N(eosio), | ||
mvo() | ||
("arg0", 33) | ||
("arg1", "some string")); | ||
BOOST_CHECK_THROW(push_action(N(eosio), N(test2), N(eosio), mvo() ("arg0", 30)("arg1", "some string")), fc::exception); | ||
BOOST_CHECK_THROW(push_action(N(eosio), N(test2), N(eosio), mvo() ("arg0", 33)("arg1", "not some string")), fc::exception); | ||
|
||
push_action(N(eosio), N(test3), N(eosio), | ||
mvo() | ||
("arg0", 33) | ||
("arg1", "some string")); | ||
|
||
} FC_LOG_AND_RETHROW() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
add_contract(malloc_tests malloc_tests malloc_tests.cpp) | ||
add_contract(malloc_tests old_malloc_tests malloc_tests.cpp) | ||
add_contract(simple_tests simple_tests simple_tests.cpp) | ||
add_contract(transfer_contract transfer_contract transfer.cpp) | ||
|
||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrong.abi ${CMAKE_CURRENT_BINARY_DIR}/simple_wrong.abi COPYONLY ) | ||
|
||
target_link_libraries(old_malloc_tests PUBLIC --use-freeing-malloc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <eosiolib/eosio.hpp> | ||
#include "transfer.hpp" | ||
|
||
using namespace eosio; | ||
|
||
class [[eosio::contract]] simple_tests : public contract { | ||
public: | ||
using contract::contract; | ||
|
||
[[eosio::action]] | ||
void test1(name nm) { | ||
check(nm == "bucky"_n, "not bucky"); | ||
} | ||
|
||
[[eosio::action]] | ||
void test2(int arg0, std::string arg1) { | ||
check(arg0 == 33, "33 does not match"); | ||
check(arg1 == "some string", "some string does not match"); | ||
} | ||
|
||
[[eosio::action("test4")]] | ||
void test4(name to) { | ||
transfer_contract::transfer_action trans("eosio.token"_n, {_self, "active"_n}); | ||
trans.send(_self, to, asset{100, {"TST", 4}}, "memo"); | ||
} | ||
|
||
[[eosio::action]] | ||
void test5(name to) { | ||
transfer_contract::transfer_action trans("someone"_n, {_self, "active"_n}); | ||
trans.send(_self, to, asset{100, {"TST", 4}}, "memo"); | ||
} | ||
|
||
[[eosio::action]] | ||
void testa(name to) { | ||
transfer_contract::transfer2_action trans("someone"_n, {_self, "active"_n}); | ||
trans.send(_self, to, asset{100, {"TST", 4}}, "memo"); | ||
} | ||
|
||
[[eosio::action]] | ||
void testb(name to) { | ||
transfer_contract::transfer3_action trans("someone"_n, {_self, "active"_n}); | ||
trans.send(_self, to, asset{100, {"TST", 4}}, "memo"); | ||
} | ||
|
||
[[eosio::on_notify("eosio.token::transfer")]] | ||
void on_transfer(name from, name to, asset quant, std::string memo) { | ||
check(_code == "eosio.token"_n, "should be eosio.token"); | ||
print_f("On notify : % % % %", from, to, quant, memo); | ||
} | ||
|
||
[[eosio::on_notify("*::transfer")]] | ||
void on_transfer2(name from, name to, asset quant, std::string memo) { | ||
check(_code != "eosio.token"_n, "should not be eosio.token"); | ||
print_f("On notify 2 : % % % %", from, to, quant, memo); | ||
} | ||
|
||
[[eosio::on_notify("*::transfer2")]] | ||
void on_transfer3(name from, name to, asset quant, std::string memo) { | ||
print_f("On notify 3 : % % % %", from, to, quant, memo); | ||
} | ||
|
||
}; | ||
|
||
extern "C" void pre_dispatch(name self, name original_receiver, name action) { | ||
print_f("pre_dispatch : % % %\n", self, original_receiver, action); | ||
} | ||
|
||
extern "C" void post_dispatch(name self, name original_receiver, name action) { | ||
print_f("post_dispatch : % % %\n", self, original_receiver, action); | ||
std::set<name> valid_actions = {"test1"_n, "test2"_n, "test4"_n, "test5"_n}; | ||
check(valid_actions.count(action) == 0, "valid action should have dispatched"); | ||
check(self == "eosio"_n, "should only be eosio for action failures"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Tue Jan 22 18:06:02 2019", | ||
"version": "eosio::abi/1.1", | ||
"types": [], | ||
"structs": [ | ||
{ | ||
"name": "test1", | ||
"base": "", | ||
"fields": [ | ||
{ | ||
"name": "nm", | ||
"type": "name" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "test2", | ||
"base": "", | ||
"fields": [ | ||
{ | ||
"name": "arg0", | ||
"type": "int32" | ||
}, | ||
{ | ||
"name": "arg1", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"name": "test1", | ||
"type": "test1", | ||
"ricardian_contract": "" | ||
}, | ||
{ | ||
"name": "test2", | ||
"type": "test2", | ||
"ricardian_contract": "" | ||
}, | ||
{ | ||
"name": "test3", | ||
"type": "test2", | ||
"ricardian_contract": "" | ||
} | ||
|
||
], | ||
"tables": [], | ||
"ricardian_clauses": [], | ||
"variants": [] | ||
} |
Oops, something went wrong.