Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
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
Operate
Environments
Monitor
Incidents
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
648194e4
Commit
648194e4
authored
6 years ago
by
Pascal Engélibert
Browse files
Options
Downloads
Patches
Plain Diff
[ref] blockchain: remove expects
parent
56ad07ae
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!117
WIP: Resolve "Add block checking (checking all rules of the unit protocol)"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/blockchain/blockchain/src/dubp/check/mod.rs
+14
-12
14 additions, 12 deletions
lib/modules/blockchain/blockchain/src/dubp/check/mod.rs
with
14 additions
and
12 deletions
lib/modules/blockchain/blockchain/src/dubp/check/mod.rs
+
14
−
12
View file @
648194e4
...
@@ -92,7 +92,7 @@ pub fn verify_block_validity<W: WebOfTrust>(
...
@@ -92,7 +92,7 @@ pub fn verify_block_validity<W: WebOfTrust>(
if
previous_block_opt
.is_none
()
{
if
previous_block_opt
.is_none
()
{
return
Err
(
BlockError
::
InvalidBlock
(
InvalidBlockError
::
NoPreviousBlock
));
return
Err
(
BlockError
::
InvalidBlock
(
InvalidBlockError
::
NoPreviousBlock
));
}
}
let
previous_block
=
previous_block_opt
.
expect
(
"safe unwrap"
);
let
previous_block
=
previous_block_opt
.
unwrap_or_else
(||
panic!
(
dbg!
(
"dev error"
))
);
// Block version must not decrease
// Block version must not decrease
if
previous_block
.version
>
block
.version
{
if
previous_block
.version
>
block
.version
{
...
@@ -110,12 +110,13 @@ pub fn verify_block_validity<W: WebOfTrust>(
...
@@ -110,12 +110,13 @@ pub fn verify_block_validity<W: WebOfTrust>(
}
}
// BR_G100 - issuer is member
// BR_G100 - issuer is member
match
readers
::
identity
::
get_identity
(
identities_db
,
&
block
.issuers
[
0
])
?
if
let
entities
::
identity
::
DALIdentityState
::
Member
(
_
)
=
.expect
(
"safe unwrap"
)
readers
::
identity
::
get_identity
(
identities_db
,
&
block
.issuers
[
0
])
?
.unwrap_or_else
(||
panic!
(
dbg!
(
"dev error"
)))
.state
.state
{
{
entities
::
identity
::
DALIdentityState
::
Member
(
_
)
=>
{
}
}
else
{
_
=>
return
Err
(
invalid_rule_error
(
InvalidRuleError
::
NotMemberIssuer
))
,
return
Err
(
invalid_rule_error
(
InvalidRuleError
::
NotMemberIssuer
))
;
}
}
// BR_G04 - issuers count
// BR_G04 - issuers count
...
@@ -154,15 +155,15 @@ mod tests {
...
@@ -154,15 +155,15 @@ mod tests {
use
durs_blockchain_dal
::
entities
::
identity
::
*
;
use
durs_blockchain_dal
::
entities
::
identity
::
*
;
#[test]
#[test]
fn
test_verify_blocks
()
{
fn
test_verify_blocks
()
->
Result
<
(),
BlockError
>
{
let
blocks_dbs
=
BlocksV10DBs
::
open
(
None
);
let
blocks_dbs
=
BlocksV10DBs
::
open
(
None
);
let
wot_dbs
=
WotsV10DBs
::
open
(
None
);
let
wot_dbs
=
WotsV10DBs
::
open
(
None
);
let
wot_index
:
HashMap
<
PubKey
,
NodeId
>
=
HashMap
::
new
();
let
wot_index
:
HashMap
<
PubKey
,
NodeId
>
=
HashMap
::
new
();
let
idty_a
=
identity
::
gen_mock_idty
(
pubkey
(
'A'
),
Block
Id
(
0
));
let
idty_a
=
identity
::
gen_mock_idty
(
pubkey
(
'A'
),
Block
Number
(
0
));
let
pubkey_a
=
idty_a
.issuers
()[
0
];
let
pubkey_a
=
idty_a
.issuers
()[
0
];
let
idty_b
=
identity
::
gen_mock_idty
(
pubkey
(
'B'
),
Block
Id
(
0
));
let
idty_b
=
identity
::
gen_mock_idty
(
pubkey
(
'B'
),
Block
Number
(
0
));
let
pubkey_b
=
idty_b
.issuers
()[
0
];
let
pubkey_b
=
idty_b
.issuers
()[
0
];
let
mut
blocks
=
gen_empty_timed_blocks
(
2
,
300
);
let
mut
blocks
=
gen_empty_timed_blocks
(
2
,
300
);
...
@@ -173,7 +174,7 @@ mod tests {
...
@@ -173,7 +174,7 @@ mod tests {
blocks
[
0
]
.identities
.push
(
idty_a
.clone
());
blocks
[
0
]
.identities
.push
(
idty_a
.clone
());
blocks
[
0
]
.identities
.push
(
idty_b
.clone
());
blocks
[
0
]
.identities
.push
(
idty_b
.clone
());
verify_genesis_block_validity
(
&
blocks
[
0
])
.expect
(
"Fail to valid genesis block"
)
;
verify_genesis_block_validity
(
&
blocks
[
0
])
?
;
blocks_dbs
blocks_dbs
.blockchain_db
.blockchain_db
...
@@ -238,7 +239,8 @@ mod tests {
...
@@ -238,7 +239,8 @@ mod tests {
&
wot_dbs
.certs_db
,
&
wot_dbs
.certs_db
,
&
wot_index
,
&
wot_index
,
&
wot_dbs
.wot_db
,
&
wot_dbs
.wot_db
,
)
)
?
;
.expect
(
"Fail to valid block"
);
Ok
(())
}
}
}
}
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