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
bed577d9
Commit
bed577d9
authored
Oct 23, 2018
by
kay kurokawa
Committed by
Brannon King
Oct 31, 2018
Browse files
add some tests for new CClaimTrieCache functions in claimtriecache_tests.cpp
parent
f86eb540
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/claimtriecache_tests.cpp
View file @
bed577d9
#include "claimtrie.h"
#include "main.h"
#include "nameclaim.h"
#include "uint256.h"
#include "test/test_bitcoin.h"
...
...
@@ -22,6 +23,12 @@ public:
{
return
CClaimTrieCache
::
recursivePruneName
(
tnCurrent
,
nPos
,
sName
,
pfNullified
);
}
bool
insertSupportIntoMap
(
const
std
::
string
&
name
,
CSupportValue
support
,
bool
fCheckTakeover
)
const
{
return
CClaimTrieCache
::
insertSupportIntoMap
(
name
,
support
,
fCheckTakeover
);
}
int
cacheSize
()
{
return
cache
.
size
();
...
...
@@ -187,6 +194,48 @@ BOOST_AUTO_TEST_CASE(merkle_hash_multiple_test)
BOOST_CHECK
(
pclaimTrie
->
checkConsistency
());
}
BOOST_AUTO_TEST_CASE
(
basic_insertion_info_test
)
{
// test basic claim insertions and that get methods retreives information properly
BOOST_CHECK
(
pclaimTrie
->
empty
());
CClaimTrieCacheTest
ctc
(
pclaimTrie
);
// create and insert claim
CClaimValue
unused
;
uint256
hash0
(
uint256S
(
"0000000000000000000000000000000000000000000000000000000000000001"
));
CMutableTransaction
tx1
=
BuildTransaction
(
hash0
);
uint160
claimId
=
ClaimIdHash
(
tx1
.
GetHash
(),
0
);
COutPoint
claimOutPoint
(
tx1
.
GetHash
(),
0
);
CAmount
amount
(
10
);
int
height
=
0
;
int
validHeight
=
0
;
CClaimValue
claimVal
(
claimOutPoint
,
claimId
,
amount
,
height
,
validHeight
);
ctc
.
insertClaimIntoTrie
(
"test"
,
claimVal
);
// try getClaimsForName, getEffectiveAmountForClaim, getInfoForName
claimsForNameType
res
=
ctc
.
getClaimsForName
(
"test"
);
BOOST_CHECK
(
res
.
claims
.
size
()
==
1
);
BOOST_CHECK
(
res
.
claims
[
0
]
==
claimVal
);
BOOST_CHECK_EQUAL
(
10
,
ctc
.
getEffectiveAmountForClaim
(
"test"
,
claimId
));
CClaimValue
claim
;
BOOST_CHECK
(
ctc
.
getInfoForName
(
"test"
,
claim
));
BOOST_CHECK
(
claim
==
claimVal
);
// insert a support
CAmount
supportAmount
(
10
);
uint256
hash1
(
uint256S
(
"0000000000000000000000000000000000000000000000000000000000000002"
));
CMutableTransaction
tx2
=
BuildTransaction
(
hash1
);
COutPoint
supportOutPoint
(
tx2
.
GetHash
(),
0
);
CSupportValue
support
(
supportOutPoint
,
claimId
,
supportAmount
,
height
,
validHeight
);
ctc
.
insertSupportIntoMap
(
"test"
,
support
,
false
);
// try getEffectiveAmount
BOOST_CHECK_EQUAL
(
20
,
ctc
.
getEffectiveAmountForClaim
(
"test"
,
claimId
));
}
BOOST_AUTO_TEST_CASE
(
recursive_prune_test
)
{
CClaimTrieCacheTest
cc
(
pclaimTrie
);
...
...
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