Skip to content
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

Send a legacy PegIn transaction from a Multisig address #2901

Open
wants to merge 3 commits into
base: pegin-it-registerBtcTx-negativeHeight
Choose a base branch
from

Conversation

julianlen
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Dec 20, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@julianlen julianlen force-pushed the pegin-it-differentSenders branch 3 times, most recently from 17f7ceb to 62e95ab Compare December 20, 2024 18:26
@julianlen julianlen force-pushed the pegin-it-differentSenders branch from 62e95ab to c9394d9 Compare December 26, 2024 14:35
@julianlen julianlen marked this pull request as ready for review December 26, 2024 14:40
@julianlen julianlen requested a review from a team as a code owner December 26, 2024 14:40
@julianlen
Copy link
Contributor Author

Before reviewing this PR check #2888

Comment on lines +190 to +195
Set<PegoutsWaitingForConfirmations.Entry> pegoutEntries = bridgeStorageProvider.getPegoutsWaitingForConfirmations().getEntries();
int expectedPegoutsWaitingForConfirmations = 1;
assertEquals(expectedPegoutsWaitingForConfirmations, pegoutEntries.size());

Optional<PegoutsWaitingForConfirmations.Entry> pegOutWaitingForConfirmationOptional = pegoutEntries.stream().findFirst();
assertTrue(pegOutWaitingForConfirmationOptional.isPresent());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do the findFirst or size strategy for both of them. For consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, I use both approaches to say: that it's the only one and it's exactly the one I am expecting

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the size assertion indirectly ensures that there is exactly one pegout entry, making the second assertion somewhat redundant. Not a big deal, but you can simplify the code to have a single assert while maintaining clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I always wonder whether asserting an isPresent with an optional makes sense. The list of PegoutsWaitingForConfirmations.Entry may have a list of empty optionals

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have checked that it has a size 1 it is guaranteed that the Optional is present.

Comment on lines 236 to 241
private void setupChainWithBtcTransaction(BtcTransaction bitcoinTransaction) throws BlockStoreException {
pmtWithTransactions = createValidPmtForTransactions(List.of(bitcoinTransaction.getHash()), btcNetworkParams);
btcBlockWithPmtHeight = bridgeConstants.getBtcHeightWhenPegoutTxIndexActivates() + bridgeConstants.getPegoutTxIndexGracePeriodInBtcBlocks();
int chainHeight = btcBlockWithPmtHeight + bridgeConstants.getBtc2RskMinimumAcceptableConfirmations();
recreateChainFromPmt(btcBlockStoreWithCache, chainHeight, pmtWithTransactions, btcBlockWithPmtHeight, btcNetworkParams);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to have this be changing state class per test? Would it be possible or does it make sense to return assigments to local variables per test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean having pmtWithTransactions and btcBlockWithPmtHeight as local variables in each test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems that it makes more sense to have this at per test level rather than at a per class level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link

sonarqubecloud bot commented Jan 6, 2025

Copy link
Contributor

@apancorb apancorb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just left the minor comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants