Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
64e0246a
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
64e0246a
编写于
3月 29, 2018
作者:
D
Daniel Larimer
提交者:
GitHub
3月 29, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1911 from EOSIO/deferred-transactions-3
Schedule deferred transactions
上级
595e66d6
a18e3998
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
111 addition
and
166 deletion
+111
-166
contracts/eosiolib/transaction.h
contracts/eosiolib/transaction.h
+2
-2
contracts/eosiolib/transaction.hpp
contracts/eosiolib/transaction.hpp
+1
-1
libraries/chain/apply_context.cpp
libraries/chain/apply_context.cpp
+1
-1
libraries/chain/chain_controller.cpp
libraries/chain/chain_controller.cpp
+52
-18
libraries/chain/include/eosio/chain/apply_context.hpp
libraries/chain/include/eosio/chain/apply_context.hpp
+1
-1
libraries/chain/include/eosio/chain/chain_controller.hpp
libraries/chain/include/eosio/chain/chain_controller.hpp
+3
-3
libraries/chain/include/eosio/chain/config.hpp
libraries/chain/include/eosio/chain/config.hpp
+5
-0
libraries/chain/include/eosio/chain/generated_transaction_object.hpp
...hain/include/eosio/chain/generated_transaction_object.hpp
+2
-2
libraries/chain/include/eosio/chain/transaction.hpp
libraries/chain/include/eosio/chain/transaction.hpp
+4
-4
libraries/chain/include/eosio/chain/transaction_metadata.hpp
libraries/chain/include/eosio/chain/transaction_metadata.hpp
+9
-1
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+8
-7
libraries/fc/include/fc/static_variant.hpp
libraries/fc/include/fc/static_variant.hpp
+1
-1
libraries/fc/src/uint128.cpp
libraries/fc/src/uint128.cpp
+6
-2
tests/api_tests/api_tests.cpp
tests/api_tests/api_tests.cpp
+6
-6
tests/chain_tests/delay_tests.cpp
tests/chain_tests/delay_tests.cpp
+1
-103
tests/wasm_tests/currency_tests.cpp
tests/wasm_tests/currency_tests.cpp
+3
-7
tests/wasm_tests/eosio.system_tests.cpp
tests/wasm_tests/eosio.system_tests.cpp
+6
-7
未找到文件。
contracts/eosiolib/transaction.h
浏览文件 @
64e0246a
...
...
@@ -59,9 +59,9 @@ extern "C" {
* @{
*/
void
send_deferred
(
uint64_t
sender_id
,
time
delay_until
,
char
*
serialized_transaction
,
size_t
size
);
void
send_deferred
(
const
uint128_t
&
sender_id
,
time
delay_until
,
char
*
serialized_transaction
,
size_t
size
);
void
cancel_deferred
(
uint64_t
sender_id
);
void
cancel_deferred
(
const
uint128_t
&
sender_id
);
/**
* access a copy of the currently executing transaction
...
...
contracts/eosiolib/transaction.hpp
浏览文件 @
64e0246a
...
...
@@ -48,7 +48,7 @@ namespace eosio {
class
deferred_transaction
:
public
transaction
{
public:
uint
64
_t
sender_id
;
uint
128
_t
sender_id
;
account_name
sender
;
time
delay_until
;
...
...
libraries/chain/apply_context.cpp
浏览文件 @
64e0246a
...
...
@@ -251,7 +251,7 @@ void apply_context::execute_deferred( deferred_transaction&& trx ) {
}
FC_CAPTURE_AND_RETHROW
((
trx
));
}
void
apply_context
::
cancel_deferred
(
uint
64
_t
sender_id
)
{
void
apply_context
::
cancel_deferred
(
uint
128
_t
sender_id
)
{
results
.
deferred_transaction_requests
.
push_back
(
deferred_reference
(
receiver
,
sender_id
));
}
...
...
libraries/chain/chain_controller.cpp
浏览文件 @
64e0246a
...
...
@@ -249,13 +249,19 @@ bool chain_controller::_push_block(const signed_block& new_block)
* queues.
*/
transaction_trace
chain_controller
::
push_transaction
(
const
packed_transaction
&
trx
,
uint32_t
skip
)
{
try
{
{
try
{
// If this is the first transaction pushed after applying a block, start a new undo session.
// This allows us to quickly rewind to the clean state of the head block, in case a new block arrives.
if
(
!
_pending_block
)
{
_start_pending_block
();
}
return
with_skip_flags
(
skip
,
[
&
]()
{
return
_db
.
with_write_lock
([
&
]()
{
return
_push_transaction
(
trx
);
});
});
}
EOS_CAPTURE_AND_RETHROW
(
transaction_exception
)
}
}
EOS_CAPTURE_AND_RETHROW
(
transaction_exception
)
}
transaction_trace
chain_controller
::
_push_transaction
(
const
packed_transaction
&
packed_trx
)
{
try
{
...
...
@@ -324,18 +330,16 @@ static void record_locks_for_data_access(const vector<action_trace>& action_trac
transaction_trace
chain_controller
::
_push_transaction
(
transaction_metadata
&&
data
)
{
try
{
FC_ASSERT
(
_pending_block
,
" block not started"
);
if
(
_limits
.
max_push_transaction_us
.
count
()
>
0
)
{
data
.
processing_deadline
=
fc
::
time_point
::
now
()
+
_limits
.
max_push_transaction_us
;
auto
newval
=
fc
::
time_point
::
now
()
+
_limits
.
max_push_transaction_us
;
if
(
!
data
.
processing_deadline
||
newval
<
*
data
.
processing_deadline
)
{
data
.
processing_deadline
=
newval
;
}
const
transaction
&
trx
=
data
.
trx
();
// If this is the first transaction pushed after applying a block, start a new undo session.
// This allows us to quickly rewind to the clean state of the head block, in case a new block arrives.
if
(
!
_pending_block
)
{
_start_pending_block
();
}
const
transaction
&
trx
=
data
.
trx
();
auto
temp_session
=
_db
.
start_undo_session
(
true
);
// for now apply the transaction serially but schedule it according to those invariants
...
...
@@ -383,7 +387,7 @@ block_header chain_controller::head_block_header() const
return
block_header
();
}
void
chain_controller
::
_start_pending_block
()
void
chain_controller
::
_start_pending_block
(
bool
skip_deferred
)
{
FC_ASSERT
(
!
_pending_block
);
_pending_block
=
signed_block
();
...
...
@@ -391,10 +395,20 @@ void chain_controller::_start_pending_block()
_pending_block_session
=
_db
.
start_undo_session
(
true
);
_pending_block
->
regions
.
resize
(
1
);
_pending_block_trace
->
region_traces
.
resize
(
1
);
_start_pending_cycle
();
_apply_on_block_transaction
();
_finalize_pending_cycle
();
_start_pending_cycle
();
if
(
!
skip_deferred
)
{
_push_deferred_transactions
(
false
);
if
(
_pending_cycle_trace
&&
_pending_cycle_trace
->
shard_traces
.
size
()
>
0
&&
_pending_cycle_trace
->
shard_traces
.
back
().
transaction_traces
.
size
()
>
0
)
{
_finalize_pending_cycle
();
_start_pending_cycle
();
}
}
}
transaction
chain_controller
::
_get_on_block_transaction
()
...
...
@@ -764,6 +778,7 @@ void chain_controller::__apply_block(const signed_block& next_block)
const
auto
*
gtrx
=
_db
.
find
<
generated_transaction_object
,
by_trx_id
>
(
receipt
.
id
);
if
(
gtrx
!=
nullptr
)
{
auto
trx
=
fc
::
raw
::
unpack
<
deferred_transaction
>
(
gtrx
->
packed_trx
.
data
(),
gtrx
->
packed_trx
.
size
());
FC_ASSERT
(
trx
.
execute_after
<=
head_block_time
()
,
"deffered transaction executed prematurely"
);
_temp
.
emplace
(
trx
,
gtrx
->
published
,
trx
.
sender
,
trx
.
sender_id
,
gtrx
->
packed_trx
.
data
(),
gtrx
->
packed_trx
.
size
()
);
return
&*
_temp
;
}
else
{
...
...
@@ -1726,8 +1741,23 @@ transaction_trace chain_controller::_apply_error( transaction_metadata& meta ) {
return
result
;
}
vector
<
transaction_trace
>
chain_controller
::
push_deferred_transactions
(
bool
flush
)
vector
<
transaction_trace
>
chain_controller
::
push_deferred_transactions
(
bool
flush
,
uint32_t
skip
)
{
try
{
if
(
!
_pending_block
)
{
_start_pending_block
(
true
);
}
return
with_skip_flags
(
skip
,
[
&
]()
{
return
_db
.
with_write_lock
([
&
]()
{
return
_push_deferred_transactions
(
flush
);
});
});
}
FC_CAPTURE_AND_RETHROW
()
}
vector
<
transaction_trace
>
chain_controller
::
_push_deferred_transactions
(
bool
flush
)
{
FC_ASSERT
(
_pending_block
,
" block not started"
);
if
(
flush
&&
_pending_cycle_trace
&&
_pending_cycle_trace
->
shard_traces
.
size
()
>
0
)
{
// TODO: when we go multithreaded this will need a better way to see if there are flushable
// deferred transactions in the shards
...
...
@@ -1761,18 +1791,22 @@ vector<transaction_trace> chain_controller::push_deferred_transactions( bool flu
candidates
.
emplace_back
(
&
gtrx
);
}
auto
deferred_transactions_deadline
=
fc
::
time_point
::
now
()
+
fc
::
microseconds
(
config
::
deffered_transactions_max_time_per_block_us
);
vector
<
transaction_trace
>
res
;
for
(
const
auto
*
trx_p
:
candidates
)
{
if
(
!
is_known_transaction
(
trx_p
->
trx_id
))
{
try
{
auto
trx
=
fc
::
raw
::
unpack
<
deferred_transaction
>
(
trx_p
->
packed_trx
.
data
(),
trx_p
->
packed_trx
.
size
());
transaction_metadata
mtrx
(
trx
,
trx_p
->
published
,
trx
.
sender
,
trx
.
sender_id
,
trx_p
->
packed_trx
.
data
(),
trx_p
->
packed_trx
.
size
());
transaction_metadata
mtrx
(
trx
,
trx_p
->
published
,
trx
.
sender
,
trx
.
sender_id
,
trx_p
->
packed_trx
.
data
(),
trx_p
->
packed_trx
.
size
()
,
deferred_transactions_deadline
);
res
.
push_back
(
_push_transaction
(
std
::
move
(
mtrx
))
);
generated_transaction_idx
.
remove
(
*
trx_p
);
}
FC_CAPTURE_AND_LOG
((
trx_p
->
trx_id
)(
trx_p
->
sender
));
}
else
{
generated_transaction_idx
.
remove
(
*
trx_p
);
}
if
(
deferred_transactions_deadline
<=
fc
::
time_point
::
now
()
)
{
break
;
}
}
return
res
;
}
...
...
libraries/chain/include/eosio/chain/apply_context.hpp
浏览文件 @
64e0246a
...
...
@@ -464,7 +464,7 @@ class apply_context {
void
execute_inline
(
action
&&
a
);
void
execute_context_free_inline
(
action
&&
a
);
void
execute_deferred
(
deferred_transaction
&&
trx
);
void
cancel_deferred
(
uint
64
_t
sender_id
);
void
cancel_deferred
(
uint
128
_t
sender_id
);
/**
* @brief Require @ref account to have approved of this message
...
...
libraries/chain/include/eosio/chain/chain_controller.hpp
浏览文件 @
64e0246a
...
...
@@ -87,8 +87,7 @@ namespace eosio { namespace chain {
void
push_block
(
const
signed_block
&
b
,
uint32_t
skip
=
skip_nothing
);
transaction_trace
push_transaction
(
const
packed_transaction
&
trx
,
uint32_t
skip
=
skip_nothing
);
vector
<
transaction_trace
>
push_deferred_transactions
(
bool
flush
=
false
);
vector
<
transaction_trace
>
push_deferred_transactions
(
bool
flush
=
false
,
uint32_t
skip
=
skip_nothing
);
/**
...
...
@@ -316,6 +315,7 @@ namespace eosio { namespace chain {
transaction_trace
_apply_transaction
(
transaction_metadata
&
data
);
transaction_trace
__apply_transaction
(
transaction_metadata
&
data
);
transaction_trace
_apply_error
(
transaction_metadata
&
data
);
vector
<
transaction_trace
>
_push_deferred_transactions
(
bool
flush
=
false
);
/// Reset the object graph in-memory
void
_initialize_indexes
();
...
...
@@ -414,7 +414,7 @@ namespace eosio { namespace chain {
void
_spinup_db
();
void
_spinup_fork_db
();
void
_start_pending_block
();
void
_start_pending_block
(
bool
skip_deferred
=
false
);
void
_start_pending_cycle
();
void
_start_pending_shard
();
void
_finalize_pending_cycle
();
...
...
libraries/chain/include/eosio/chain/config.hpp
浏览文件 @
64e0246a
...
...
@@ -72,6 +72,11 @@ const static eosio::chain::wasm_interface::vm_type default_wasm_runtime = eosio:
*/
const
static
int
producer_repetitions
=
12
;
/**
* In block production, at the begining of each block we schedule deferred transactions until reach this time
*/
const
static
uint32_t
deffered_transactions_max_time_per_block_us
=
20
*
1000
;
//20ms
/**
* The number of blocks produced per round is based upon all producers having a chance
* to produce all of their consecutive blocks.
...
...
libraries/chain/include/eosio/chain/generated_transaction_object.hpp
浏览文件 @
64e0246a
...
...
@@ -29,7 +29,7 @@ namespace eosio { namespace chain {
id_type
id
;
transaction_id_type
trx_id
;
account_name
sender
;
uint
64_t
sender_id
=
0
;
/// ID given this transaction by the sender
uint
128_t
sender_id
=
0
;
/// ID given this transaction by the sender
time_point
delay_until
;
/// this generated transaction will not be applied until the specified time
time_point
expiration
;
/// this generated transaction will not be applied after this time
time_point
published
;
...
...
@@ -62,7 +62,7 @@ namespace eosio { namespace chain {
ordered_unique
<
tag
<
by_sender_id
>
,
composite_key
<
generated_transaction_object
,
BOOST_MULTI_INDEX_MEMBER
(
generated_transaction_object
,
account_name
,
sender
),
BOOST_MULTI_INDEX_MEMBER
(
generated_transaction_object
,
uint
64
_t
,
sender_id
)
BOOST_MULTI_INDEX_MEMBER
(
generated_transaction_object
,
uint
128
_t
,
sender_id
)
>
>
>
...
...
libraries/chain/include/eosio/chain/transaction.hpp
浏览文件 @
64e0246a
...
...
@@ -214,13 +214,13 @@ namespace eosio { namespace chain {
*/
struct
deferred_transaction
:
public
transaction
{
uint
64
_t
sender_id
;
/// ID assigned by sender of generated, accessible via WASM api when executing normal or error
uint
128
_t
sender_id
;
/// ID assigned by sender of generated, accessible via WASM api when executing normal or error
account_name
sender
;
/// receives error handler callback
time_point_sec
execute_after
;
/// delayed exeuction
deferred_transaction
()
=
default
;
deferred_transaction
(
uint
32
_t
sender_id
,
account_name
sender
,
time_point_sec
execute_after
,
const
transaction
&
txn
)
deferred_transaction
(
uint
128
_t
sender_id
,
account_name
sender
,
time_point_sec
execute_after
,
const
transaction
&
txn
)
:
transaction
(
txn
),
sender_id
(
sender_id
),
sender
(
sender
),
...
...
@@ -229,12 +229,12 @@ namespace eosio { namespace chain {
};
struct
deferred_reference
{
deferred_reference
(
const
account_name
&
sender
,
uint
64
_t
sender_id
)
deferred_reference
(
const
account_name
&
sender
,
uint
128
_t
sender_id
)
:
sender
(
sender
),
sender_id
(
sender_id
)
{}
account_name
sender
;
uint
64
_t
sender_id
;
uint
128
_t
sender_id
;
};
struct
data_access_info
{
...
...
libraries/chain/include/eosio/chain/transaction_metadata.hpp
浏览文件 @
64e0246a
...
...
@@ -16,6 +16,14 @@ class transaction_metadata {
,
sender
(
sender
),
sender_id
(
sender_id
),
raw_data
(
raw_data
),
raw_size
(
raw_size
),
_trx
(
&
t
)
{}
transaction_metadata
(
const
transaction
&
t
,
const
time_point
&
published
,
const
account_name
&
sender
,
uint32_t
sender_id
,
const
char
*
raw_data
,
size_t
raw_size
,
fc
::
time_point
deadline
)
:
id
(
t
.
id
())
,
published
(
published
)
,
sender
(
sender
),
sender_id
(
sender_id
),
raw_data
(
raw_data
),
raw_size
(
raw_size
)
,
processing_deadline
(
deadline
)
,
_trx
(
&
t
)
{}
transaction_metadata
(
const
packed_transaction
&
t
,
chain_id_type
chainid
,
const
time_point
&
published
);
transaction_metadata
(
transaction_metadata
&&
)
=
default
;
...
...
@@ -39,7 +47,7 @@ class transaction_metadata {
// things for processing deferred transactions
optional
<
account_name
>
sender
;
uint
32_t
sender_id
=
0
;
uint
128_t
sender_id
=
0
;
// packed form to pass to contracts if needed
const
char
*
raw_data
=
nullptr
;
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
64e0246a
...
...
@@ -1030,23 +1030,24 @@ class transaction_api : public context_aware_api {
context
.
execute_context_free_inline
(
std
::
move
(
act
));
}
void
send_deferred
(
uint64_t
sender_id
,
const
fc
::
time_point_sec
&
execute_after
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
void
send_deferred
(
const
unsigned
__int128
&
val
,
const
fc
::
time_point_sec
&
execute_after
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
try
{
// TODO: use global properties object for dynamic configuration of this default_max_gen_trx_size
fc
::
uint128_t
sender_id
(
val
>>
64
,
uint64_t
(
val
)
);
const
auto
&
gpo
=
context
.
controller
.
get_global_properties
();
FC_ASSERT
(
data_len
<
gpo
.
configuration
.
max_generated_transaction_size
,
"generated transaction too big"
);
deferred_transaction
dtrx
;
fc
::
raw
::
unpack
<
transaction
>
(
data
,
data_len
,
dtrx
);
dtrx
.
sender
=
context
.
receiver
;
dtrx
.
sender_id
=
sender_id
;
dtrx
.
sender_id
=
(
unsigned
__int128
)
sender_id
;
dtrx
.
execute_after
=
execute_after
;
context
.
execute_deferred
(
std
::
move
(
dtrx
));
}
FC_CAPTURE_AND_RETHROW
((
fc
::
to_hex
(
data
,
data_len
)));
}
void
cancel_deferred
(
uint64_t
sender_id
)
{
context
.
cancel_deferred
(
sender_id
);
void
cancel_deferred
(
const
unsigned
__int128
&
val
)
{
fc
::
uint128_t
sender_id
(
val
>>
64
,
uint64_t
(
val
)
);
context
.
cancel_deferred
(
(
unsigned
__int128
)
sender_id
);
}
};
...
...
@@ -1553,8 +1554,8 @@ REGISTER_INTRINSICS(context_free_transaction_api,
REGISTER_INTRINSICS
(
transaction_api
,
(
send_inline
,
void
(
int
,
int
)
)
(
send_context_free_inline
,
void
(
int
,
int
)
)
(
send_deferred
,
void
(
int
64_t
,
int
,
int
,
int
)
)
(
cancel_deferred
,
void
(
int
64_t
)
)
(
send_deferred
,
void
(
int
,
int
,
int
,
int
)
)
(
cancel_deferred
,
void
(
int
)
)
);
REGISTER_INTRINSICS
(
context_free_api
,
...
...
libraries/fc/include/fc/static_variant.hpp
浏览文件 @
64e0246a
...
...
@@ -195,8 +195,8 @@ class static_variant {
static_assert
(
impl
::
type_info
<
Types
...
>::
no_reference_types
,
"Reference types are not permitted in static_variant."
);
static_assert
(
impl
::
type_info
<
Types
...
>::
no_duplicates
,
"static_variant type arguments contain duplicate types."
);
alignas
(
Types
...)
char
storage
[
impl
::
type_info
<
Types
...
>::
size
];
int
_tag
;
char
storage
[
impl
::
type_info
<
Types
...
>::
size
];
template
<
typename
X
>
void
init
(
const
X
&
x
)
{
...
...
libraries/fc/src/uint128.cpp
浏览文件 @
64e0246a
...
...
@@ -376,8 +376,12 @@ namespace fc
void
to_variant
(
const
uint128
&
var
,
variant
&
vo
)
{
vo
=
std
::
string
(
var
);
}
void
from_variant
(
const
variant
&
var
,
uint128
&
vo
){
vo
=
uint128
(
var
.
as_string
());
}
void
to_variant
(
const
unsigned
__int128
&
var
,
variant
&
vo
)
{
to_variant
(
*
((
uint128
*
)
var
),
vo
);
}
void
from_variant
(
const
variant
&
var
,
unsigned
__int128
&
vo
)
{
from_variant
(
var
,
*
((
uint128
*
)
&
vo
));
}
void
to_variant
(
const
unsigned
__int128
&
var
,
variant
&
vo
)
{
to_variant
(
uint128
(
var
),
vo
);
}
void
from_variant
(
const
variant
&
var
,
unsigned
__int128
&
vo
)
{
uint128
tmp
;
from_variant
(
var
,
tmp
);
vo
=
(
unsigned
__int128
)
tmp
;
}
}
// namespace fc
...
...
tests/api_tests/api_tests.cpp
浏览文件 @
64e0246a
...
...
@@ -363,7 +363,7 @@ BOOST_FIXTURE_TEST_CASE(action_tests, tester) { try {
// test send_action_sender
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_action_sender"
,
fc
::
raw
::
pack
(
N
(
testapi
)));
control
->
push_deferred_transactions
(
true
);
produce_block
(
);
// test_publication_time
uint32_t
pub_time
=
control
->
head_block_time
().
sec_since_epoch
();
...
...
@@ -662,11 +662,11 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, tester) { try {
produce_blocks
(
1
);
//schedule
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
fc
::
raw
::
pack
(
uint64_t
(
1
))
);
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
{}
);
//check that it doesn't get executed immediately
auto
traces
=
control
->
push_deferred_transactions
(
true
);
BOOST_CHECK_EQUAL
(
0
,
traces
.
size
()
);
produce_block
s
(
24
);
produce_block
(
fc
::
seconds
(
2
)
);
//check that it gets executed afterwards
traces
=
control
->
push_deferred_transactions
(
true
);
BOOST_CHECK_EQUAL
(
1
,
traces
.
size
()
);
...
...
@@ -674,7 +674,7 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, tester) { try {
//schedule twice (second deferred transaction should replace first one)
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
{});
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
{});
produce_block
s
(
24
);
produce_block
(
fc
::
seconds
(
2
)
);
//check that only one deferred transaction executed
traces
=
control
->
push_deferred_transactions
(
true
);
BOOST_CHECK_EQUAL
(
1
,
traces
.
size
()
);
...
...
@@ -682,14 +682,14 @@ BOOST_FIXTURE_TEST_CASE(deferred_transaction_tests, tester) { try {
//schedule and cancel
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
{});
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"cancel_deferred_transaction"
,
{});
produce_block
s
(
24
);
produce_block
(
fc
::
seconds
(
2
)
);
traces
=
control
->
push_deferred_transactions
(
true
);
BOOST_CHECK_EQUAL
(
0
,
traces
.
size
()
);
//cancel_deferred() before scheduling transaction should not prevent the transaction from being scheduled (check that previous bug is fixed)
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"cancel_deferred_transaction"
,
{});
CALL_TEST_FUNCTION
(
*
this
,
"test_transaction"
,
"send_deferred_transaction"
,
{});
produce_block
s
(
24
);
produce_block
(
fc
::
seconds
(
2
)
);
traces
=
control
->
push_deferred_transactions
(
true
);
BOOST_CHECK_EQUAL
(
1
,
traces
.
size
()
);
}
FC_LOG_AND_RETHROW
()
}
...
...
tests/chain_tests/delay_tests.cpp
浏览文件 @
64e0246a
...
...
@@ -128,8 +128,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -137,8 +135,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
18
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -146,8 +142,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -155,8 +149,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -276,8 +268,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_parent_permission_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -285,8 +275,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_parent_permission_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
28
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -294,8 +282,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_parent_permission_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -303,8 +289,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_parent_permission_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -430,8 +414,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_walk_parent_permissions_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -439,8 +421,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_walk_parent_permissions_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
38
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -448,8 +428,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_walk_parent_permissions_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -457,8 +435,6 @@ BOOST_AUTO_TEST_CASE( link_delay_direct_walk_parent_permissions_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -573,8 +549,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
16
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -601,8 +575,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -611,8 +583,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -630,8 +600,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transaction_requests
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -639,8 +607,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
15
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -648,8 +614,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -658,8 +622,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
// second transfer finally is performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -780,8 +742,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
16
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -808,8 +768,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -818,8 +776,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -837,8 +793,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transaction_requests
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -846,8 +800,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
15
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -855,8 +807,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -865,8 +815,6 @@ BOOST_AUTO_TEST_CASE( link_delay_permission_change_with_delay_heirarchy_test ) {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
// second transfer finally is performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -986,8 +934,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
16
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1014,8 +960,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1024,8 +968,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1043,8 +985,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transaction_requests
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1052,8 +992,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
15
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1061,8 +999,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1071,8 +1007,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
// second transfer finally is performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1198,8 +1132,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
16
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1226,8 +1158,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1236,8 +1166,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1255,8 +1183,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transaction_requests
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1264,8 +1190,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
15
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1273,8 +1197,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1283,8 +1205,6 @@ BOOST_AUTO_TEST_CASE( link_delay_link_change_heirarchy_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"11.0000 CUR"
),
liquid_balance
);
// second transfer finally is performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1400,8 +1320,6 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1409,8 +1327,6 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
18
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1418,8 +1334,6 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1427,8 +1341,6 @@ BOOST_AUTO_TEST_CASE( mindelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1543,8 +1455,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
16
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1582,9 +1492,7 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
1
,
trace
.
deferred_transaction_requests
.
size
());
const
auto
sender_id_canceled
=
trace
.
deferred_transaction_requests
[
0
].
get
<
deferred_reference
>
().
sender_id
;
BOOST_REQUIRE_EQUAL
(
sender_id_to_cancel
,
sender_id_canceled
);
chain
.
control
->
push_deferred_transactions
(
true
);
BOOST_REQUIRE_EQUAL
(
std
::
string
(
uint128
(
sender_id_to_cancel
)),
std
::
string
(
uint128
(
sender_id_canceled
)));
chain
.
produce_blocks
();
...
...
@@ -1594,8 +1502,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1613,8 +1519,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transaction_requests
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1622,8 +1526,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
(
15
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1631,8 +1533,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 CUR"
),
liquid_balance
);
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
@@ -1641,8 +1541,6 @@ BOOST_AUTO_TEST_CASE( canceldelay_test ) { try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"10.0000 CUR"
),
liquid_balance
);
// second transfer finally is performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
...
...
tests/wasm_tests/currency_tests.cpp
浏览文件 @
64e0246a
...
...
@@ -402,13 +402,12 @@ BOOST_FIXTURE_TEST_CASE( test_proxy, currency_tester ) try {
}
while
(
control
->
head_block_time
()
<
expected_delivery
)
{
control
->
push_deferred_transactions
(
true
);
produce_block
();
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"5.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
alice
)),
asset
::
from_string
(
"0.0000 CUR"
));
}
control
->
push_deferred_transactions
(
true
);
produce_block
(
);
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"0.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
alice
)),
asset
::
from_string
(
"5.0000 CUR"
));
...
...
@@ -459,7 +458,6 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
auto
deferred_id
=
trace
.
deferred_transaction_requests
.
back
().
get
<
deferred_transaction
>
().
id
();
while
(
control
->
head_block_time
()
<
expected_delivery
)
{
control
->
push_deferred_transactions
(
true
);
produce_block
();
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"5.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
bob
)),
asset
::
from_string
(
"0.0000 CUR"
));
...
...
@@ -468,7 +466,6 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
}
fc
::
time_point
expected_redelivery
(
fc
::
seconds
(
control
->
head_block_time
().
sec_since_epoch
())
+
fc
::
seconds
(
10
));
control
->
push_deferred_transactions
(
true
);
produce_block
();
BOOST_REQUIRE_EQUAL
(
chain_has_transaction
(
deferred_id
),
true
);
BOOST_REQUIRE_EQUAL
(
get_transaction_receipt
(
deferred_id
).
status
,
transaction_receipt
::
soft_fail
);
...
...
@@ -494,19 +491,18 @@ BOOST_FIXTURE_TEST_CASE( test_deferred_failure, currency_tester ) try {
}
while
(
control
->
head_block_time
()
<
expected_redelivery
)
{
control
->
push_deferred_transactions
(
true
);
produce_block
();
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"5.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
bob
)),
asset
::
from_string
(
"0.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
bob
)),
asset
::
from_string
(
"0.0000 CUR"
));
}
control
->
push_deferred_transactions
(
true
);
produce_block
(
);
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"0.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
alice
)),
asset
::
from_string
(
"0.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
bob
)),
asset
::
from_string
(
"5.0000 CUR"
));
control
->
push_deferred_transactions
(
true
);
produce_block
(
);
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
proxy
)),
asset
::
from_string
(
"0.0000 CUR"
));
BOOST_REQUIRE_EQUAL
(
get_balance
(
N
(
alice
)),
asset
::
from_string
(
"5.0000 CUR"
));
...
...
tests/wasm_tests/eosio.system_tests.cpp
浏览文件 @
64e0246a
...
...
@@ -207,17 +207,16 @@ BOOST_FIXTURE_TEST_CASE( stake_unstake, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 EOS"
).
amount
,
total
[
"storage_stake"
].
as_uint64
());
BOOST_REQUIRE_EQUAL
(
0
,
total
[
"storage_bytes"
].
as_uint64
());
REQUIRE_MATCHING_OBJECT
(
voter
(
"alice"
,
"0.00 EOS"
),
get_voter_info
(
"alice"
)
);
control
->
push_deferred_transactions
(
true
);
produce_blocks
(
1
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"200.0000 EOS"
),
get_balance
(
"alice"
)
);
//after 2 days balance should not be available yet
produce_block
(
fc
::
hours
(
3
*
24
-
1
)
);
control
->
push_deferred_transactions
(
true
);
produce_blocks
(
1
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"200.0000 EOS"
),
get_balance
(
"alice"
)
);
//after 3 days funds should be released
produce_block
(
fc
::
hours
(
1
)
);
control
->
push_deferred_transactions
(
true
);
produce_blocks
(
1
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1000.0000 EOS"
),
get_balance
(
"alice"
)
);
}
FC_LOG_AND_RETHROW
()
...
...
@@ -502,10 +501,10 @@ BOOST_FIXTURE_TEST_CASE( adding_stake_partial_unstake, eosio_system_tester ) try
//combined amount should be available only in 3 days
produce_block
(
fc
::
days
(
2
)
);
control
->
push_deferred_transactions
(
true
);
produce_blocks
(
1
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"430.0000 EOS"
),
get_balance
(
"alice"
)
);
produce_block
(
fc
::
days
(
1
)
);
control
->
push_deferred_transactions
(
true
);
produce_blocks
(
1
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"790.0000 EOS"
),
get_balance
(
"alice"
)
);
}
FC_LOG_AND_RETHROW
()
...
...
@@ -661,7 +660,7 @@ BOOST_FIXTURE_TEST_CASE( vote_for_producer, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL
(
string
(
key
.
begin
(),
key
.
end
()),
to_string
(
prod
[
"packed_key"
])
);
//carol should receive funds in 3 days
produce_block
(
fc
::
days
(
3
)
);
control
->
push_deferred_transactions
(
true
);
produce_block
(
);
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"3000.0000 EOS"
),
get_balance
(
"carol"
)
);
}
FC_LOG_AND_RETHROW
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录