-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests validating 32 byte chainwork checkpoints can be processed once RSKIP454 is activated #2865
base: use-serializeAndDeserializeCompactV2-in-RepositoryBtcBlockStoreWithCache
Are you sure you want to change the base?
Conversation
…nce RSKIP454 is activated
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
|
||
InputStream checkpointsStream = bridgeSupport.getCheckPoints(); | ||
CheckpointManager manager = new CheckpointManager(bridgeTestNetConstants.getBtcParams(), checkpointsStream); | ||
long time = bridgeSupport.getActiveFederation().getCreationTime().toEpochMilli() - 604800L; // The magic number is a substraction CheckpointManager does when getting the checkpoints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long time = bridgeSupport.getActiveFederation().getCreationTime().toEpochMilli() - 604800L; // The magic number is a substraction CheckpointManager does when getting the checkpoints. | |
long checkpointManagerSubstraction = 604800L; | |
long time = bridgeSupport.getActiveFederation().getCreationTime().toEpochMilli() - checkpointManagerSubstraction; |
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored.
@@ -192,17 +199,114 @@ void testInitialChainHeadWithoutBtcCheckpoints() throws Exception { | |||
void testInitialChainHeadWithBtcCheckpoints() throws Exception { | |||
BridgeConstants bridgeTestNetConstants = BridgeTestNetConstants.getInstance(); | |||
|
|||
BridgeSupport bridgeSupport = arrangeBridgeSupport(bridgeTestNetConstants, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add tests for mainnet, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only one testing testnet. The rest of new tests are for mainnnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
BridgeSupport bridgeSupport = arrangeBridgeSupport(bridgeTestNetConstants, | ||
activationsBeforeForks); | ||
|
||
// Force instantiation of blockstore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing exactly what's being said. Check this:
private StoredBlock getBtcBlockchainChainHead() throws IOException, BlockStoreException { |
Basically, we are testing how checkpoints are read and then store in the RepositoryBtcBlockStoreWithCache
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my concern is: why is this needed? maybe an explanatory comment to add a bit more context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
"12-byte-chainwork-mix-format.production.checkpoints" | ||
} | ||
) | ||
void testInitialChainHeadWithBtcCheckpoints_whenCheckpointsWith12BytesChainWork_before_RSKIP454_ok( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void testInitialChainHeadWithBtcCheckpoints_whenCheckpointsWith12BytesChainWork_before_RSKIP454_ok( | |
void initialChainHeadWithBtcCheckpoints_whenCheckpointsWith12BytesChainWork_beforeRSKIP454_ok( |
no need to add test to name a test i think :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
assertEquals(checkpoint.getHeight(), bridgeSupport.getBtcBlockchainBestChainHeight()); | ||
} | ||
|
||
private BridgeSupport arrangeBridgeSupport(BridgeConstants bridgeTestNetConstants, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big fan of this. Can't we set the bridgeSupport
in the general setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to build the bridgeSupport
using different bridgeConstants and different activations depending on the use case. This is why I don't put it there, but I'm reorganizing the tests, and let's see if you find it easier to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
"12-byte-chainwork-mix-format.production.checkpoints" | ||
} | ||
) | ||
void testInitialChainHeadWithBtcCheckpoints_whenCheckpointsWith12BytesChainWork_before_RSKIP454_ok( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add the arrange, act, assert sections as we've been doing? I find the tests a bit hard to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
- Put magical number into meaningful constant variable - Put assertion blocks into methods with meaningful names
Description
Add tests validating 32 byte chainwork checkpoints can be processed once RSKIP454 is activated
How Has This Been Tested?
Unit tests
Types of changes
Checklist: