Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lbry
lbrycrd
Commits
8b3f2e8b
Commit
8b3f2e8b
authored
Dec 05, 2018
by
kay kurokawa
Committed by
Kay Kurokawa
Dec 06, 2018
Browse files
Add tests to trigger
https://github.com/lbryio/lbrycrd/issues/243
parent
9f80a4ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/claimtriebranching_tests.cpp
View file @
8b3f2e8b
...
...
@@ -176,6 +176,7 @@ struct ClaimTrieChainFixture{
fRequireStandard
=
false
;
ENTER_CRITICAL_SECTION
(
cs_main
);
BOOST_CHECK
(
pclaimTrie
->
nCurrentHeight
==
chainActive
.
Height
()
+
1
);
pclaimTrie
->
setExpirationTime
(
originalExpiration
);
// in case it was changed during the test
num_txs_for_next_block
=
0
;
num_txs
=
0
;
coinbase_txs_used
=
0
;
...
...
@@ -1020,6 +1021,65 @@ BOOST_AUTO_TEST_CASE(hardfork_support_test)
}
/*
activation_fall_through and supports_fall_through
Tests for where claims/supports in queues would be undone properly in a decrement.
See https://github.com/lbryio/lbrycrd/issues/243 for more details
*/
BOOST_AUTO_TEST_CASE
(
activations_fall_through
)
{
ClaimTrieChainFixture
fixture
;
CMutableTransaction
tx1
=
fixture
.
MakeClaim
(
fixture
.
GetCoinbase
(),
"A"
,
"1"
,
1
);
fixture
.
IncrementBlocks
(
3
);
BOOST_CHECK
(
pclaimTrie
->
nProportionalDelayFactor
==
1
);
CMutableTransaction
tx2
=
fixture
.
MakeClaim
(
fixture
.
GetCoinbase
(),
"A"
,
"2"
,
3
);
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
fixture
.
IncrementBlocks
(
3
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
fixture
.
DecrementBlocks
(
3
);
fixture
.
Spend
(
tx1
);
// this will trigger early activation on tx2 claim
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
fixture
.
DecrementBlocks
(
1
);
//reorg the early activation
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
fixture
.
Spend
(
tx1
);
fixture
.
IncrementBlocks
(
1
);
// this should not cause tx2 to activate again and crash
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
}
BOOST_AUTO_TEST_CASE
(
supports_fall_through
)
{
ClaimTrieChainFixture
fixture
;
CMutableTransaction
tx1
=
fixture
.
MakeClaim
(
fixture
.
GetCoinbase
(),
"A"
,
"1"
,
3
);
CMutableTransaction
tx2
=
fixture
.
MakeClaim
(
fixture
.
GetCoinbase
(),
"A"
,
"2"
,
1
);
CMutableTransaction
tx3
=
fixture
.
MakeClaim
(
fixture
.
GetCoinbase
(),
"A"
,
"3"
,
2
);
fixture
.
IncrementBlocks
(
3
);
BOOST_CHECK
(
pclaimTrie
->
nProportionalDelayFactor
==
1
);
CMutableTransaction
sx2
=
fixture
.
MakeSupport
(
fixture
.
GetCoinbase
(),
tx2
,
"A"
,
3
);
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
fixture
.
IncrementBlocks
(
3
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
fixture
.
DecrementBlocks
(
3
);
fixture
.
Spend
(
tx1
);
// this will trigger early activation
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
fixture
.
DecrementBlocks
(
1
);
// reorg the early activation
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
//tx2 support should not be active
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx1
));
//tx2 support should not be active
fixture
.
IncrementBlocks
(
1
);
BOOST_CHECK
(
is_best_claim
(
"A"
,
tx2
));
//tx2 support should be active now
}
/*
claim/support expiration for hard fork, but with checks for disk procedures
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment