Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
fda49ec8
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,发现更多精彩内容 >>
提交
fda49ec8
编写于
2月 01, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
contradicaitons handling in identity contract + unit test for that
上级
2191a85e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
69 addition
and
5 deletion
+69
-5
contracts/identity/identity.hpp
contracts/identity/identity.hpp
+19
-4
tests/wasm_tests/identity_tests.cpp
tests/wasm_tests/identity_tests.cpp
+50
-1
未找到文件。
contracts/identity/identity.hpp
浏览文件 @
fda49ec8
...
...
@@ -211,13 +211,19 @@ namespace identity {
certs_table
certs
(
ident
);
certrow
row
;
bool
ok
=
certs
.
primary_lower_bound
(
row
,
N
(
owner
),
1
,
0
);
account_name
owner
=
0
;
while
(
ok
&&
row
.
property
==
N
(
owner
)
&&
row
.
trusted
)
{
if
(
sizeof
(
account_name
)
==
row
.
data
.
size
())
{
account_name
account
=
*
reinterpret_cast
<
account_name
*>
(
row
.
data
.
data
());
if
(
ident
==
get_claimed_identity
(
account
))
{
if
(
is_trusted
(
row
.
certifier
)
)
{
// the certifier is still trusted
return
account
;
if
(
!
owner
||
owner
==
account
)
{
owner
=
account
;
}
else
{
//contradiction found: different owners certified for the same identity
return
0
;
}
}
else
if
(
DeployToAccount
==
current_receiver
()){
//the certifier is no longer trusted, need to unset the flag
row
.
trusted
=
0
;
...
...
@@ -230,6 +236,11 @@ namespace identity {
// bad row - skip it
}
ok
=
certs
.
primary_upper_bound
(
row
,
row
.
property
,
row
.
trusted
,
row
.
certifier
);
//ok = certs.next_primary(row, row);
}
if
(
owner
)
{
//owner found, no contradictions among certifications flaged as trusted
return
owner
;
}
// trusted certification not found
// let's see if some of untrusted certifications became trusted
...
...
@@ -243,7 +254,12 @@ namespace identity {
row
.
trusted
=
1
;
certs
.
store
(
row
,
0
);
//assuming 0 means bill to the same account
}
return
account
;
if
(
!
owner
||
owner
==
account
)
{
owner
=
account
;
}
else
{
//contradiction found: different owners certified for the same identity
return
0
;
}
}
}
else
{
// bad row - skip it
...
...
@@ -251,8 +267,7 @@ namespace identity {
ok
=
certs
.
primary_upper_bound
(
row
,
row
.
property
,
row
.
trusted
,
row
.
certifier
);
//ok = certs.next_primary(row, row);
}
return
0
;
return
owner
;
}
static
identity_name
get_identity_for_account
(
account_name
acnt
)
{
...
...
tests/wasm_tests/identity_tests.cpp
浏览文件 @
fda49ec8
...
...
@@ -614,7 +614,56 @@ BOOST_FIXTURE_TEST_CASE( owner_certification_becomes_trusted, identity_tester )
//but effectively bob's certification should became trusted
BOOST_REQUIRE_EQUAL(N(alice), get_owner_for_identity(identity_val));
} FC_LOG_AND_RETHROW() //owner_certification_becomes_trusted
} FC_LOG_AND_RETHROW() //owner_certification_becomes_trusted
BOOST_FIXTURE_TEST_CASE( ownership_contradiction, identity_tester ) try {
BOOST_REQUIRE_EQUAL(success(), create_identity("alice", identity_val));
//alice claims identity
BOOST_REQUIRE_EQUAL(success(), certify("alice", identity_val, vector<fc::variant>{ mutable_variant_object()
("property", "owner")
("type", "account")
("data", to_uint8_vector(N(alice)))
("memo", "claiming onwership")
("confidence", 100)
}));
// block producer certifies alice's ownership
BOOST_REQUIRE_EQUAL(success(), certify("inita", identity_val, vector<fc::variant>{ mutable_variant_object()
("property", "owner")
("type", "account")
("data", to_uint8_vector(N(alice)))
("memo", "")
("confidence", 100)
}));
BOOST_REQUIRE_EQUAL( true, get_certrow(identity_val, "owner", 1, "inita").is_object() );
//now alice is the official owner of the identity
BOOST_REQUIRE_EQUAL(N(alice), get_owner_for_identity(identity_val));
//bob claims identity
BOOST_REQUIRE_EQUAL(success(), certify("bob", identity_val, vector<fc::variant>{ mutable_variant_object()
("property", "owner")
("type", "account")
("data", to_uint8_vector(N(bob)))
("memo", "claiming onwership")
("confidence", 100)
}));
//another block producer certifies bob's identity (to the identity already certified to alice)
BOOST_REQUIRE_EQUAL(success(), certify("initb", identity_val, vector<fc::variant>{ mutable_variant_object()
("property", "owner")
("type", "account")
("data", to_uint8_vector(N(bob)))
("memo", "")
("confidence", 100)
}));
BOOST_REQUIRE_EQUAL( true, get_certrow(identity_val, "owner", 1, "initb").is_object() );
//now neither alice or bob are official owners, because we have 2 trusted certifications in contradiction to each other
BOOST_REQUIRE_EQUAL(0, get_owner_for_identity(identity_val));
} FC_LOG_AND_RETHROW() //ownership_contradiction
BOOST_AUTO_TEST_SUITE_END()
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录