提交 eabf962d 编写于 作者: B Brian Johnson

Removed unbuilt tests and contracts.

上级 0263edaa
......@@ -28,21 +28,6 @@ target_include_directories( chain_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_t
target_include_directories( chain_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_plugin/include )
add_dependencies(chain_test asserter test_api exchange currency proxy identity identity_test stltest infinite)
# WASM only tests
#file(GLOB SLOW_TESTS "slow_tests/*.cpp")
#add_executable( slow_test ${SLOW_TESTS} ${COMMON_SOURCES} )
#target_link_libraries( slow_test eos_native_contract eosio_chain chainbase eos_utilities eos_egenesis_none chain_plugin producer_plugin fc ${PLATFORM_SPECIFIC_LIBS} )
#target_include_directories( slow_test PUBLIC ${CMAKE_BINARY_DIR}/contracts )
#add_dependencies(slow_test currency exchange)
#add_subdirectory(api_tests/memory_test)
#add_subdirectory(api_tests/extended_memory_test)
#add_subdirectory(api_tests/table_abi_test)
#file(GLOB API_TESTS "api_tests/*.cpp")
#add_executable( api_test ${API_TESTS} ${COMMON_SOURCES} )
#target_link_libraries( api_test eos_native_contract eosio_chain chainbase eos_utilities eos_egenesis_none chain_plugin producer_plugin fc ${PLATFORM_SPECIFIC_LIBS} )
#target_include_directories( api_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CMAKE_SOURCE_DIR}/contracts ${CMAKE_CURRENT_BINARY_DIR}/api_tests )
#add_dependencies(api_test test_api memory_test extended_memory_test table_abi_test)
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/sync/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/sync/test.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/dawn_515/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/dawn_515/test.sh COPYONLY)
......
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <boost/test/unit_test.hpp>
#include <eos/chain/chain_controller.hpp>
#include <eos/chain/exceptions.hpp>
#include <eos/chain/account_object.hpp>
#include <eos/chain/key_value_object.hpp>
#include <eos/chain/block_summary_object.hpp>
#include <eos/utilities/tempdir.hpp>
#include <fc/crypto/digest.hpp>
#include "../common/database_fixture.hpp"
#include <Inline/BasicTypes.h>
#include <IR/Module.h>
#include <IR/Validate.h>
#include <WAST/WAST.h>
#include <WASM/WASM.h>
#include <Runtime/Runtime.h>
#include <proxy/proxy.wast.hpp>
using namespace eosio;
using namespace chain;
void Set_Proxy_Owner( testing_blockchain& chain, account_name proxy, account_name owner ) {
eosio::chain::signed_transaction trx;
trx.scope = sort_names({proxy,owner});
transaction_emplace_message(trx, "proxy",
vector<types::account_permission>({ }),
"setowner", owner);
trx.expiration = chain.head_block_time() + 100;
transaction_set_reference_block(trx, chain.head_block_id());
idump((trx));
chain.push_transaction(trx);
}
// declared in slow_test.cpp
namespace slow_tests {
void SetCode( testing_blockchain& chain, account_name account, const char* wast );
}
BOOST_AUTO_TEST_SUITE(deferred_tests)
BOOST_FIXTURE_TEST_CASE(opaque_proxy, testing_fixture)
{ try {
Make_Blockchain(chain);
chain.produce_blocks(1);
Make_Account(chain, newguy);
Make_Account(chain, proxy);
chain.produce_blocks(1);
slow_tests::SetCode(chain, "proxy", proxy_wast);
//chain.produce_blocks(1);
Set_Proxy_Owner(chain, "proxy", "newguy");
chain.produce_blocks(7);
Transfer_Asset(chain, inita, proxy, asset(100));
chain.produce_blocks(1);
BOOST_CHECK_EQUAL(chain.get_liquid_balance("newguy"), asset(0));
BOOST_CHECK_EQUAL(chain.get_liquid_balance("inita"), asset(100000-300));
BOOST_CHECK_EQUAL(chain.get_liquid_balance("proxy"), asset(100));
chain.produce_blocks(1);
BOOST_CHECK_EQUAL(chain.get_liquid_balance("newguy"), asset(100));
BOOST_CHECK_EQUAL(chain.get_liquid_balance("inita"), asset(100000-300));
BOOST_CHECK_EQUAL(chain.get_liquid_balance("proxy"), asset(0));
BOOST_CHECK_EQUAL(chain.head_block_num(), 12);
BOOST_CHECK(chain.fetch_block_by_number(12).valid());
BOOST_CHECK(!chain.fetch_block_by_number(12)->cycles.empty());
BOOST_CHECK(!chain.fetch_block_by_number(12)->cycles.front().empty());
BOOST_CHECK_EQUAL(chain.fetch_block_by_number(12)->cycles.front().front().generated_input.size(), 1);
} FC_LOG_AND_RETHROW() }
BOOST_AUTO_TEST_SUITE_END()
此差异已折叠。
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
extern "C" {
typedef long long uint64_t;
typedef unsigned int uint32_t;
typedef uint64_t AccountName;
int load( const void* keyptr, int keylen, void* valueptr, int valuelen );
void store( const void* keyptr, int keylen, const void* valueptr, int valuelen );
int read_message( void* dest, int destsize );
int remove( const void* key, int keyLength );
void printi( uint64_t );
void print( const char* str );
void assert( int test, const char* message );
void* memcpy( void* dest, const void* src, uint32_t size );
uint64_t name_to_int64( const char* name );
bool loopControl(int i);
/*
void* malloc( unsigned int size ) {
static char dynamic_memory[1024*8];
static int start = 0;
int old_start = start;
start += 8*((size+7)/8);
assert( start < sizeof(dynamic_memory), "out of memory" );
return &dynamic_memory[old_start];
}
*/
}
template<typename Key, typename Value>
int load( const Key& key, Value& v ) { return load( &key, sizeof(Key), &v, sizeof(Value) ); }
template<typename Key, typename Value>
void store( const Key& key, const Value& v ) { store( &key, sizeof(key), &v, sizeof(v) ); }
template<typename Key>
void remove( const Key& key ) { remove( &key, sizeof(key) ); }
template<typename Message>
void read_message( Message& m ) { read_message( &m, sizeof(Message) ); }
/// END BUILT IN LIBRARY.... everything below this is "user contract"
extern "C" {
struct transfer {
uint64_t from;
uint64_t to;
uint64_t amount;
char memo[];
};
static_assert( sizeof(transfer) == 3*sizeof(uint64_t), "unexpected padding" );
struct Balance {
uint64_t balance;
};
void init() {
static Balance initial = { uint64_t(10)*1000*1000ll*1000ll };
static AccountName simplecoin;
simplecoin = name_to_int64( "simplecoin" );
print( "on_init called with "); printi( initial.balance ); print( "\n");
store( simplecoin, initial );
}
void apply_simplecoin_transfer() {
static transfer message;
static Balance from_balance;
static Balance to_balance;
to_balance.balance = 0;
read_message( message );
load( message.from, from_balance );
load( message.to, to_balance );
assert( from_balance.balance >= message.amount, "insufficient funds" );
int i = 0;
bool cont = true;
while (cont) {
cont = loopControl(i++);
}
from_balance.balance -= message.amount;
to_balance.balance += message.amount;
if( from_balance.balance )
store( message.from, from_balance );
else
remove( message.from );
store( message.to, to_balance );
}
} // extern "C"
const char* wast_apply = R"====((module
(type $FUNCSIG$ji (func (param i32) (result i64)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$vj (func (param i64)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
(import "env" "eos_assert" (func $eos_assert (param i32 i32)))
(import "env" "load" (func $load (param i32 i32 i32 i32) (result i32)))
(import "env" "loopControl" (func $loopControl (param i32) (result i32)))
(import "env" "name_to_int64" (func $name_to_int64 (param i32) (result i64)))
(import "env" "print" (func $print (param i32)))
(import "env" "printi" (func $printi (param i64)))
(import "env" "readMessage" (func $readMessage (param i32 i32) (result i32)))
(import "env" "remove" (func $remove (param i32 i32) (result i32)))
(import "env" "store" (func $store (param i32 i32 i32 i32)))
(table 0 anyfunc)
(memory $0 1)
(data (i32.const 16) "\00\e4\0bT\02\00\00\00")
(data (i32.const 32) "simplecoin\00")
(data (i32.const 48) "on_init called with \00")
(data (i32.const 80) "\n\00")
(data (i32.const 128) "insufficient funds\00")
(export "memory" (memory $0))
(export "init" (func $init))
(export "apply_simplecoin_transfer" (func $apply_simplecoin_transfer))
(func $init
(i64.store offset=24
(i32.const 0)
(call $name_to_int64
(i32.const 32)
)
)
(call $print
(i32.const 48)
)
(call $printi
(i64.load offset=16
(i32.const 0)
)
)
(call $print
(i32.const 80)
)
(call $store
(i32.const 24)
(i32.const 8)
(i32.const 16)
(i32.const 8)
)
)
(func $apply_simplecoin_transfer
(local $0 i32)
(local $1 i64)
(local $2 i64)
(local $3 i32)
(set_local $3
(i32.const 0)
)
(i64.store offset=120
(i32.const 0)
(i64.const 0)
)
(drop
(call $readMessage
(i32.const 88)
(i32.const 24)
)
)
(drop
(call $load
(i32.const 88)
(i32.const 8)
(i32.const 112)
(i32.const 8)
)
)
(drop
(call $load
(i32.const 96)
(i32.const 8)
(i32.const 120)
(i32.const 8)
)
)
(call $eos_assert
(i64.ge_s
(i64.load offset=112
(i32.const 0)
)
(i64.load offset=104
(i32.const 0)
)
)
(i32.const 128)
)
(loop $label$0
(set_local $0
(call $loopControl
(get_local $3)
)
)
(set_local $3
(i32.add
(get_local $3)
(i32.const 1)
)
)
(br_if $label$0
(get_local $0)
)
)
(i64.store offset=112
(i32.const 0)
(tee_local $2
(i64.sub
(i64.load offset=112
(i32.const 0)
)
(tee_local $1
(i64.load offset=104
(i32.const 0)
)
)
)
)
)
(i64.store offset=120
(i32.const 0)
(i64.add
(get_local $1)
(i64.load offset=120
(i32.const 0)
)
)
)
(block $label$1
(block $label$2
(br_if $label$2
(i64.eqz
(get_local $2)
)
)
(call $store
(i32.const 88)
(i32.const 8)
(i32.const 112)
(i32.const 8)
)
(br $label$1)
)
(drop
(call $remove
(i32.const 88)
(i32.const 8)
)
)
)
(call $store
(i32.const 96)
(i32.const 8)
(i32.const 120)
(i32.const 8)
)
)
))====";
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
extern "C" {
typedef long long uint64_t;
typedef unsigned int uint32_t;
typedef uint64_t AccountName;
int load( const void* keyptr, int keylen, void* valueptr, int valuelen );
void store( const void* keyptr, int keylen, const void* valueptr, int valuelen );
int read_message( void* dest, int destsize );
int remove( const void* key, int keyLength );
void printi( uint64_t );
void print( const char* str );
void assert( int test, const char* message );
void* memcpy( void* dest, const void* src, uint32_t size );
uint64_t name_to_int64( const char* name );
/*
void* malloc( unsigned int size ) {
static char dynamic_memory[1024*8];
static int start = 0;
int old_start = start;
start += 8*((size+7)/8);
assert( start < sizeof(dynamic_memory), "out of memory" );
return &dynamic_memory[old_start];
}
*/
}
template<typename Key, typename Value>
int load( const Key& key, Value& v ) { return load( &key, sizeof(Key), &v, sizeof(Value) ); }
template<typename Key, typename Value>
void store( const Key& key, const Value& v ) { store( &key, sizeof(key), &v, sizeof(v) ); }
template<typename Key>
void remove( const Key& key ) { remove( &key, sizeof(key) ); }
template<typename Message>
void read_message( Message& m ) { read_message( &m, sizeof(Message) ); }
/// END BUILT IN LIBRARY.... everything below this is "user contract"
extern "C" {
struct transfer {
uint64_t from;
uint64_t to;
uint64_t amount;
char memo[];
};
static_assert( sizeof(transfer) == 3*sizeof(uint64_t), "unexpected padding" );
struct Balance {
uint64_t balance;
};
void init() {
static Balance initial = { uint64_t(10)*1000*1000ll*1000ll };
static AccountName simplecoin;
simplecoin = name_to_int64( "simplecoin" );
print( "on_init called with "); printi( initial.balance ); print( "\n");
store( simplecoin, initial );
}
void apply_simplecoin_transfer() {
static transfer message;
static Balance from_balance;
static Balance to_balance;
to_balance.balance = 0;
read_message( message );
load( message.from, from_balance );
load( message.to, to_balance );
assert( from_balance.balance >= message.amount, "insufficient funds" );
from_balance.balance -= message.amount;
to_balance.balance += message.amount;
if( from_balance.balance )
store( message.from, from_balance );
else
remove( message.from );
store( message.to, to_balance );
}
} // extern "C"
const char* simplecoin_wast = R"====((module
(type $FUNCSIG$ji (func (param i32) (result i64)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$vj (func (param i64)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
(import "env" "eos_assert" (func $eos_assert (param i32 i32)))
(import "env" "load" (func $load (param i32 i32 i32 i32) (result i32)))
(import "env" "name_to_int64" (func $name_to_int64 (param i32) (result i64)))
(import "env" "print" (func $print (param i32)))
(import "env" "printi" (func $printi (param i64)))
(import "env" "readMessage" (func $readMessage (param i32 i32) (result i32)))
(import "env" "remove" (func $remove (param i32 i32) (result i32)))
(import "env" "store" (func $store (param i32 i32 i32 i32)))
(table 0 anyfunc)
(memory $0 1)
(data (i32.const 16) "\00\e4\0bT\02\00\00\00")
(data (i32.const 32) "simplecoin\00")
(data (i32.const 48) "on_init called with \00")
(data (i32.const 80) "\n\00")
(data (i32.const 128) "insufficient funds\00")
(export "memory" (memory $0))
(export "init" (func $init))
(export "apply_simplecoin_transfer" (func $apply_simplecoin_transfer))
(func $init
(i64.store offset=24
(i32.const 0)
(call $name_to_int64
(i32.const 32)
)
)
(call $print
(i32.const 48)
)
(call $printi
(i64.load offset=16
(i32.const 0)
)
)
(call $print
(i32.const 80)
)
(call $store
(i32.const 24)
(i32.const 8)
(i32.const 16)
(i32.const 8)
)
)
(func $apply_simplecoin_transfer
(local $0 i64)
(local $1 i64)
(i64.store offset=120
(i32.const 0)
(i64.const 0)
)
(drop
(call $readMessage
(i32.const 88)
(i32.const 24)
)
)
(drop
(call $load
(i32.const 88)
(i32.const 8)
(i32.const 112)
(i32.const 8)
)
)
(drop
(call $load
(i32.const 96)
(i32.const 8)
(i32.const 120)
(i32.const 8)
)
)
(call $eos_assert
(i64.ge_s
(i64.load offset=112
(i32.const 0)
)
(i64.load offset=104
(i32.const 0)
)
)
(i32.const 128)
)
(i64.store offset=112
(i32.const 0)
(tee_local $1
(i64.sub
(i64.load offset=112
(i32.const 0)
)
(tee_local $0
(i64.load offset=104
(i32.const 0)
)
)
)
)
)
(i64.store offset=120
(i32.const 0)
(i64.add
(get_local $0)
(i64.load offset=120
(i32.const 0)
)
)
)
(block $label$0
(block $label$1
(br_if $label$1
(i64.eqz
(get_local $1)
)
)
(call $store
(i32.const 88)
(i32.const 8)
(i32.const 112)
(i32.const 8)
)
(br $label$0)
)
(drop
(call $remove
(i32.const 88)
(i32.const 8)
)
)
)
(call $store
(i32.const 96)
(i32.const 8)
(i32.const 120)
(i32.const 8)
)
)
))====";
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册