Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-bitcoin
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
parity
parity-bitcoin
Commits
cbdb97a0
Commit
cbdb97a0
authored
5 years ago
by
Svyatoslav Nikolsky
Browse files
Options
Downloads
Patches
Plain Diff
(failing) blocks_write_able_to_reorganize
parent
1790ad00
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sync/src/blocks_writer.rs
+19
-0
19 additions, 0 deletions
sync/src/blocks_writer.rs
sync/src/lib.rs
+1
-1
1 addition, 1 deletion
sync/src/lib.rs
with
20 additions
and
1 deletion
sync/src/blocks_writer.rs
+
19
−
0
View file @
cbdb97a0
...
...
@@ -209,4 +209,23 @@ mod tests {
assert!
(
blocks_target
.append_block
(
test_data
::
block_h1
()
.into
())
.is_ok
());
assert_eq!
(
db
.best_block
()
.number
,
1
);
}
#[test]
fn
blocks_write_able_to_reorganize
()
{
// (1) b0 ---> (2) b1
// \--> (3) b2 ---> (4 - reorg) b3
let
b0
=
test_data
::
block_builder
()
.header
()
.build
()
.build
();
let
b1
=
test_data
::
block_builder
()
.header
()
.nonce
(
1
.into
())
.parent
(
b0
.hash
())
.build
()
.build
();
let
b2
=
test_data
::
block_builder
()
.header
()
.nonce
(
2
.into
())
.parent
(
b0
.hash
())
.build
()
.build
();
let
b3
=
test_data
::
block_builder
()
.header
()
.parent
(
b2
.hash
())
.build
()
.build
();
let
db
=
Arc
::
new
(
BlockChainDatabase
::
init_test_chain
(
vec!
[
b0
.into
()]));
let
mut
blocks_target
=
BlocksWriter
::
new
(
db
.clone
(),
ConsensusParams
::
new
(
Network
::
Testnet
),
VerificationParameters
{
verification_level
:
VerificationLevel
::
NO_VERIFICATION
,
verification_edge
:
0u8
.into
(),
});
assert_eq!
(
blocks_target
.append_block
(
b1
.into
()),
Ok
(()));
assert_eq!
(
blocks_target
.append_block
(
b2
.into
()),
Ok
(()));
assert_eq!
(
blocks_target
.append_block
(
b3
.into
()),
Ok
(()));
}
}
This diff is collapsed.
Click to expand it.
sync/src/lib.rs
+
1
−
1
View file @
cbdb97a0
...
...
@@ -48,7 +48,7 @@ use primitives::hash::H256;
use
verification
::
BackwardsCompatibleChainVerifier
as
ChainVerifier
;
/// Sync errors.
#[derive(Debug)]
#[derive(Debug
,
PartialEq
)]
pub
enum
Error
{
/// Too many orphan blocks.
TooManyOrphanBlocks
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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