Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
5731e0fb
Commit
5731e0fb
authored
2 years ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
wip add position of duplicate
parent
cd65d4bd
No related branches found
No related tags found
No related merge requests found
Pipeline
#19181
failed
2 years ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
live-tests/tests/sanity_gdev.rs
+28
-15
28 additions, 15 deletions
live-tests/tests/sanity_gdev.rs
with
28 additions
and
15 deletions
live-tests/tests/sanity_gdev.rs
+
28
−
15
View file @
5731e0fb
...
@@ -21,7 +21,7 @@ use countmap::CountMap;
...
@@ -21,7 +21,7 @@ use countmap::CountMap;
use
hex_literal
::
hex
;
use
hex_literal
::
hex
;
use
sp_core
::
crypto
::
AccountId32
;
use
sp_core
::
crypto
::
AccountId32
;
use
sp_core
::{
blake2_128
,
ByteArray
,
H256
};
use
sp_core
::{
blake2_128
,
ByteArray
,
H256
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
{
HashMap
,
HashSet
}
;
use
subxt
::
config
::
SubstrateConfig
as
GdevConfig
;
use
subxt
::
config
::
SubstrateConfig
as
GdevConfig
;
const
DEFAULT_ENDPOINT
:
&
str
=
"ws://localhost:9944"
;
const
DEFAULT_ENDPOINT
:
&
str
=
"ws://localhost:9944"
;
...
@@ -182,6 +182,11 @@ mod verifier {
...
@@ -182,6 +182,11 @@ mod verifier {
}
}
}
}
/// like assert but just push error
fn
error
(
&
mut
self
,
error
:
String
)
{
self
.errors
.push
(
error
);
}
/// check accounts sufficients and consumers (specific to duniter-account pallet)
/// check accounts sufficients and consumers (specific to duniter-account pallet)
async
fn
verify_accounts
(
&
mut
self
,
accounts
:
&
HashMap
<
AccountId32
,
AccountInfo
>
)
{
async
fn
verify_accounts
(
&
mut
self
,
accounts
:
&
HashMap
<
AccountId32
,
AccountInfo
>
)
{
for
(
account_id
,
account_info
)
in
accounts
{
for
(
account_id
,
account_info
)
in
accounts
{
...
@@ -229,18 +234,20 @@ mod verifier {
...
@@ -229,18 +234,20 @@ mod verifier {
)
{
)
{
// counts occurence of owner key
// counts occurence of owner key
let
mut
countmap
=
CountMap
::
<
AccountId32
,
u8
>
::
new
();
let
mut
countmap
=
CountMap
::
<
AccountId32
,
u8
>
::
new
();
// list owner key with multiple occurences
let
mut
duplicates
=
HashSet
::
new
();
for
(
idty_index
,
idty_value
)
in
identities
{
for
(
idty_index
,
idty_value
)
in
identities
{
countmap
.insert_or_increment
(
idty_value
.owner_key
.clone
());
countmap
.insert_or_increment
(
idty_value
.owner_key
.clone
());
if
let
Some
(
count
)
=
countmap
.get_count
(
&
idty_value
.owner_key
)
{
if
let
Some
(
count
)
=
countmap
.get_count
(
&
idty_value
.owner_key
)
{
if
count
>
1
{
if
count
>
1
{
self
.assert
(
self
.error
(
format!
(
false
,
"address {} is the owner_key of {count} identities"
,
format!
(
"owner_key {} is present {count} times"
,
idty_value
.owner_key
idty_value
.owner_key
),
));
);
if
count
==
2
{
duplicates
.insert
(
idty_value
.owner_key
.clone
());
}
}
}
}
}
...
@@ -283,6 +290,15 @@ mod verifier {
...
@@ -283,6 +290,15 @@ mod verifier {
}
}
}
}
}
}
for
(
idty_index
,
idty_value
)
in
identities
{
if
duplicates
.contains
(
&
idty_value
.owner_key
)
{
self
.error
(
format!
(
"duplicate key {} at position {idty_index}"
,
idty_value
.owner_key
));
}
}
}
}
/// check the identity hashmap (length, identity existence, hash matches owner key)
/// check the identity hashmap (length, identity existence, hash matches owner key)
...
@@ -343,13 +359,10 @@ mod verifier {
...
@@ -343,13 +359,10 @@ mod verifier {
self
.assert
(
idty_index
==
index_of
,
self
.assert
(
idty_index
==
index_of
,
format!
(
"identity number {idty_index} with owner key {0} is mapped to identity index {index_of}"
,
idty_value
.owner_key
));
format!
(
"identity number {idty_index} with owner key {0} is mapped to identity index {index_of}"
,
idty_value
.owner_key
));
}
else
{
}
else
{
self
.assert
(
self
.error
(
format!
(
false
,
format!
(
"identity with owner key {} is not present in hashmap"
,
"identity with owner key {} is not present in hashmap"
,
idty_value
.owner_key
idty_value
.owner_key
),
));
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment