Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
bd6e7380
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,发现更多精彩内容 >>
提交
bd6e7380
编写于
3月 27, 2018
作者:
B
Brian Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added test case for changing the link away from a permission with a delay.
上级
5a183899
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
210 addition
and
1 deletion
+210
-1
tests/chain_tests/delay_tests.cpp
tests/chain_tests/delay_tests.cpp
+210
-1
未找到文件。
tests/chain_tests/delay_tests.cpp
浏览文件 @
bd6e7380
...
...
@@ -610,7 +610,216 @@ 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
);
// first transfer will finally performed
// first transfer will finally be performed
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"99.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"1.0000 CUR"
),
liquid_balance
);
// this transfer is performed right away since delay is removed
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"10.0000 CUR"
)
(
"memo"
,
"hi"
)
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transactions
.
size
());
chain
.
control
->
push_deferred_transactions
(
true
);
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"89.0000 CUR"
),
liquid_balance
);
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
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"89.0000 CUR"
),
liquid_balance
);
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
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"89.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
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
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"84.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"16.0000 CUR"
),
liquid_balance
);
}
FC_LOG_AND_RETHROW
()
}
/// schedule_test
// test moving link with delay on permission
BOOST_AUTO_TEST_CASE
(
link_delay_link_change_test
)
{
try
{
tester
chain
;
const
auto
&
tester_account
=
N
(
tester
);
chain
.
set_code
(
config
::
system_account_name
,
eosio_system_wast
);
chain
.
set_abi
(
config
::
system_account_name
,
eosio_system_abi
);
chain
.
produce_blocks
();
chain
.
create_account
(
N
(
currency
));
chain
.
produce_blocks
(
10
);
chain
.
set_code
(
N
(
currency
),
currency_wast
);
chain
.
set_abi
(
N
(
currency
),
currency_abi
);
chain
.
produce_blocks
();
chain
.
create_account
(
N
(
tester
));
chain
.
create_account
(
N
(
tester2
));
chain
.
produce_blocks
(
10
);
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
updateauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"permission"
,
"first"
)
(
"parent"
,
"active"
)
(
"data"
,
authority
(
chain
.
get_public_key
(
tester_account
,
"first"
)))
(
"delay"
,
10
));
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
linkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"type"
,
"transfer"
)
(
"requirement"
,
"first"
));
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
updateauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"permission"
,
"second"
)
(
"parent"
,
"active"
)
(
"data"
,
authority
(
chain
.
get_public_key
(
tester_account
,
"second"
)))
(
"delay"
,
0
));
chain
.
produce_blocks
();
chain
.
push_action
(
N
(
currency
),
N
(
create
),
N
(
currency
),
mutable_variant_object
()
(
"issuer"
,
"currency"
)
(
"maximum_supply"
,
"9000000.0000 CUR"
)
(
"can_freeze"
,
0
)
(
"can_recall"
,
0
)
(
"can_whitelist"
,
0
)
);
chain
.
push_action
(
N
(
currency
),
name
(
"issue"
),
N
(
currency
),
fc
::
mutable_variant_object
()
(
"to"
,
"currency"
)
(
"quantity"
,
"1000000.0000 CUR"
)
(
"memo"
,
"for stuff"
)
);
auto
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
currency
),
fc
::
mutable_variant_object
()
(
"from"
,
"currency"
)
(
"to"
,
"tester"
)
(
"quantity"
,
"100.0000 CUR"
)
(
"memo"
,
"hi"
)
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
executed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
deferred_transactions
.
size
());
chain
.
produce_blocks
();
auto
liquid_balance
=
get_currency_balance
(
chain
,
N
(
currency
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"999900.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
// this transaction will be delayed 20 sec
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"1.0000 CUR"
)
(
"memo"
,
"hi"
),
30
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
delayed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
1
,
trace
.
deferred_transactions
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
action_traces
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
canceled_deferred
.
size
());
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
currency
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"999900.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// this transaction will be delayed 20 sec
chain
.
push_action
(
config
::
system_account_name
,
contracts
::
linkauth
::
get_name
(),
tester_account
,
fc
::
mutable_variant_object
()
(
"account"
,
"tester"
)
(
"code"
,
"currency"
)
(
"type"
,
"transfer"
)
(
"requirement"
,
"second"
),
30
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
delayed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
1
,
trace
.
deferred_transactions
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
action_traces
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
canceled_deferred
.
size
());
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
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
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"0.0000 CUR"
),
liquid_balance
);
// this transaction will be delayed 20 sec
trace
=
chain
.
push_action
(
N
(
currency
),
name
(
"transfer"
),
N
(
tester
),
fc
::
mutable_variant_object
()
(
"from"
,
"tester"
)
(
"to"
,
"tester2"
)
(
"quantity"
,
"5.0000 CUR"
)
(
"memo"
,
"hi"
),
30
);
BOOST_REQUIRE_EQUAL
(
transaction_receipt
::
delayed
,
trace
.
status
);
BOOST_REQUIRE_EQUAL
(
1
,
trace
.
deferred_transactions
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
action_traces
.
size
());
BOOST_REQUIRE_EQUAL
(
0
,
trace
.
canceled_deferred
.
size
());
chain
.
produce_blocks
();
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
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
));
BOOST_REQUIRE_EQUAL
(
asset
::
from_string
(
"100.0000 CUR"
),
liquid_balance
);
liquid_balance
=
get_currency_balance
(
chain
,
N
(
tester2
));
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
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录