Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
bf230e9c
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,发现更多精彩内容 >>
提交
bf230e9c
编写于
2月 13, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
progress testing system
上级
e2c6a8b0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
75 addition
and
12 deletion
+75
-12
contracts/eosio.system/eosio.system.abi
contracts/eosio.system/eosio.system.abi
+22
-1
contracts/eosio.system/eosio.system.cpp
contracts/eosio.system/eosio.system.cpp
+1
-0
contracts/eosio.system/eosio.system.hpp
contracts/eosio.system/eosio.system.hpp
+13
-10
libraries/chain/apply_context.cpp
libraries/chain/apply_context.cpp
+1
-0
libraries/chain/include/eosio/chain/account_object.hpp
libraries/chain/include/eosio/chain/account_object.hpp
+7
-0
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+5
-1
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+26
-0
未找到文件。
contracts/eosio.system/eosio.system.abi
浏览文件 @
bf230e9c
...
...
@@ -29,7 +29,22 @@
"fields": [
{"name":"value", "type":"string"}
]
},{
"name": "regproducer",
"base": "",
"fields": [
{"name":"producer", "type":"account_name"}
{"name":"producer_key", "type":"bytes"}
]
},{
"name": "stakevote",
"base": "",
"fields": [
{"name":"voter", "type":"account_name"}
{"name":"amount", "type":"asset"}
]
}
],
"actions": [{
"name": "transfer",
...
...
@@ -40,6 +55,12 @@
},{
"name": "nonce",
"type": "nonce"
},{
"name": "regproducer",
"type": "regproducer"
},{
"name": "stakevote",
"type": "stakevote"
}
],
"tables": [{
...
...
@@ -50,4 +71,4 @@
"key_types" : ["name"]
}
]
}
\ No newline at end of file
}
contracts/eosio.system/eosio.system.cpp
浏览文件 @
bf230e9c
...
...
@@ -11,6 +11,7 @@ extern "C" {
/// The apply method implements the dispatch of events to this contract
void
apply
(
uint64_t
code
,
uint64_t
act
)
{
print
(
name
(
code
),
"::"
,
name
(
act
)
);
eosiosystem
::
contract
<
N
(
eosio
)
>::
apply
(
code
,
act
);
}
}
contracts/eosio.system/eosio.system.hpp
浏览文件 @
bf230e9c
...
...
@@ -23,6 +23,7 @@ namespace eosiosystem {
using
eosio
::
bytes
;
using
std
::
map
;
using
std
::
pair
;
using
eosio
::
print
;
template
<
account_name
SystemAccount
>
class
contract
{
...
...
@@ -116,10 +117,10 @@ namespace eosiosystem {
};
ACTION
(
SystemAccount
,
regproducer
)
{
account_name
producer
_to_register
;
account_name
producer
;
bytes
producer_key
;
EOSLIB_SERIALIZE
(
regproducer
,
(
producer
_to_register
)(
producer_key
)
);
EOSLIB_SERIALIZE
(
regproducer
,
(
producer
)(
producer_key
)
);
};
ACTION
(
SystemAccount
,
regproxy
)
{
...
...
@@ -250,7 +251,7 @@ namespace eosiosystem {
/**
* This method will create a producr_config and producer_votes object for 'producer
_to_register
'
* This method will create a producr_config and producer_votes object for 'producer'
*
* @pre producer is not already registered
* @pre producer to register is an account
...
...
@@ -258,7 +259,7 @@ namespace eosiosystem {
*
*/
static
void
on
(
const
regproducer
&
reg
)
{
auto
producer
=
reg
.
producer
_to_register
;
auto
producer
=
reg
.
producer
;
require_auth
(
producer
);
producer_votes_index_type
votes
(
SystemAccount
,
SystemAccount
);
...
...
@@ -279,14 +280,16 @@ namespace eosiosystem {
ACTION
(
SystemAccount
,
stakevote
)
{
account_name
voter
;
system_token_type
amount
_to_stake
;
system_token_type
amount
;
EOSLIB_SERIALIZE
(
stakevote
,
(
voter
)(
amount
_to_stake
)
)
EOSLIB_SERIALIZE
(
stakevote
,
(
voter
)(
amount
)
)
};
static
void
on
(
const
stakevote
&
sv
)
{
eosio_assert
(
sv
.
amount_to_stake
.
quantity
>
0
,
"must stake some tokens"
);
print
(
"on stake vote
\n
"
);
eosio_assert
(
sv
.
amount
.
quantity
>
0
,
"must stake some tokens"
);
require_auth
(
sv
.
voter
);
return
;
account_votes_index_type
avotes
(
SystemAccount
,
SystemAccount
);
...
...
@@ -300,7 +303,7 @@ namespace eosiosystem {
}
uint128_t
old_weight
=
acv
->
staked
.
quantity
;
uint128_t
new_weight
=
old_weight
+
sv
.
amount
_to_stake
.
quantity
;
uint128_t
new_weight
=
old_weight
+
sv
.
amount
.
quantity
;
producer_votes_index_type
votes
(
SystemAccount
,
SystemAccount
);
...
...
@@ -313,10 +316,10 @@ namespace eosiosystem {
avotes
.
update
(
*
acv
,
0
,
[
&
](
auto
av
)
{
av
.
last_update
=
now
();
av
.
staked
+=
sv
.
amount
_to_stake
;
av
.
staked
+=
sv
.
amount
;
});
currency
::
inline_transfer
(
sv
.
voter
,
SystemAccount
,
sv
.
amount_to_stake
,
"stake for voting"
);
// currency::inline_transfer( sv.voter, SystemAccount, sv.amount
, "stake for voting" );
};
ACTION
(
SystemAccount
,
voteproducer
)
{
...
...
libraries/chain/apply_context.cpp
浏览文件 @
bf230e9c
...
...
@@ -116,6 +116,7 @@ bool apply_context::is_account( const account_name& account )const {
void
apply_context
::
require_authorization
(
const
account_name
&
account
)
const
{
for
(
const
auto
&
auth
:
act
.
authorization
)
if
(
auth
.
actor
==
account
)
return
;
wdump
((
act
));
EOS_ASSERT
(
false
,
tx_missing_auth
,
"missing authority of ${account}"
,
(
"account"
,
account
));
}
void
apply_context
::
require_authorization
(
const
account_name
&
account
,
...
...
libraries/chain/include/eosio/chain/account_object.hpp
浏览文件 @
bf230e9c
...
...
@@ -36,6 +36,13 @@ namespace eosio { namespace chain {
fc
::
datastream
<
char
*>
ds
(
abi
.
data
(),
abi
.
size
()
);
fc
::
raw
::
pack
(
ds
,
a
);
}
eosio
::
chain
::
contracts
::
abi_def
get_abi
()
const
{
eosio
::
chain
::
contracts
::
abi_def
a
;
fc
::
datastream
<
const
char
*>
ds
(
abi
.
data
(),
abi
.
size
()
);
fc
::
raw
::
unpack
(
ds
,
a
);
return
a
;
}
};
using
account_id_type
=
account_object
::
id_type
;
...
...
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
bf230e9c
...
...
@@ -29,7 +29,11 @@ namespace eosio { namespace testing {
transaction_trace
push_transaction
(
packed_transaction
&
trx
);
transaction_trace
push_transaction
(
signed_transaction
&
trx
);
action_result
push_action
(
action
&&
cert_act
,
uint64_t
authorizer
);
action_result
push_action
(
action
&&
cert_act
,
uint64_t
authorizer
);
transaction_trace
push_action
(
const
account_name
&
code
,
const
action_name
&
act
,
const
account_name
&
signer
,
const
variant_object
&
data
);
void
set_tapos
(
signed_transaction
&
trx
)
const
;
void
create_accounts
(
vector
<
account_name
>
names
,
bool
multisig
=
false
)
{
...
...
libraries/testing/tester.cpp
浏览文件 @
bf230e9c
...
...
@@ -366,4 +366,30 @@ namespace eosio { namespace testing {
return
s
;
}
transaction_trace
tester
::
push_action
(
const
account_name
&
code
,
const
action_name
&
acttype
,
const
account_name
&
actor
,
const
variant_object
&
data
)
{
try
{
chain
::
contracts
::
abi_serializer
abis
(
control
->
get_database
().
get
<
account_object
,
by_name
>
(
code
).
get_abi
()
);
string
action_type_name
=
abis
.
get_action_type
(
acttype
);
action
act
;
act
.
account
=
code
;
act
.
name
=
acttype
;
act
.
authorization
=
vector
<
permission_level
>
{{
actor
,
config
::
active_name
}};
act
.
data
=
abis
.
variant_to_binary
(
action_type_name
,
data
);
wdump
((
act
));
signed_transaction
trx
;
trx
.
actions
.
emplace_back
(
std
::
move
(
act
));
set_tapos
(
trx
);
trx
.
sign
(
get_private_key
(
actor
,
"active"
),
chain_id_type
());
wdump
((
get_public_key
(
actor
,
"active"
)));;
return
push_transaction
(
trx
);
}
FC_CAPTURE_AND_RETHROW
(
(
code
)(
acttype
)(
actor
)
)
}
}
}
/// eosio::test
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录