Skip to content

Commit

Permalink
refactor(federation): resolve minor comments
Browse files Browse the repository at this point in the history
  • Loading branch information
apancorb committed Jan 27, 2025
1 parent 4257af5 commit aea897a
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void whenAllActivationsArePresentAndFederationChanges_shouldSuccesfullyChangeFed
endMigration(activations);

assertMigrationHasEnded(newFederation);
assertLastRetiredFederationP2SHMatchesWithOriginalFederation(
assertLastRetiredFederationP2SHScriptMatchesWithOriginalFederation(
FederationType.P2SH_ERP, originalFederation, activations);
}

Expand Down Expand Up @@ -542,7 +542,8 @@ private void assertMigrationHasEnded(Federation newFederation) {
assertNull(bridgeSupport.getRetiringFederationAddress());
}

private void assertLastRetiredFederationP2SHMatchesWithOriginalFederation(FederationType federationType, Federation originalFederation, ActivationConfig.ForBlock activations) {
private void assertLastRetiredFederationP2SHScriptMatchesWithOriginalFederation(
FederationType federationType, Federation originalFederation, ActivationConfig.ForBlock activations) {
var lastRetiredFederationP2SHScriptOptional =
federationStorageProvider.getLastRetiredFederationP2SHScript(activations);
assertTrue(lastRetiredFederationP2SHScriptOptional.isPresent());
Expand Down Expand Up @@ -573,7 +574,7 @@ private void verifySigHashes(ActivationConfig.ForBlock activations) throws Excep
.toList();

pegoutsTxs.forEach(
pegoutTx -> verifyPegoutTxSigHashIndex(pegoutTx, activations));
pegoutTx -> assertPegoutTxSigHashesAreSaved(pegoutTx, activations));
}

private void verifyPegoutTransactionCreatedEventWasEmitted(ActivationConfig.ForBlock activations) throws Exception {
Expand Down Expand Up @@ -636,15 +637,16 @@ private void verifyPegouts(ActivationConfig.ForBlock activations) throws Excepti
}
}

private void verifyPegoutTxSigHashIndex(BtcTransaction pegoutTx, ActivationConfig.ForBlock activations) {
private void assertPegoutTxSigHashesAreSaved(BtcTransaction pegoutTx, ActivationConfig.ForBlock activations) {
var lastPegoutSigHash = BitcoinUtils.getFirstInputSigHash(pegoutTx);
assertTrue(lastPegoutSigHash.isPresent());

if (activations.isActive(ConsensusRule.RSKIP379)) {
assertTrue(bridgeStorageProvider.hasPegoutTxSigHash(lastPegoutSigHash.get()));
} else {
assertFalse(bridgeStorageProvider.hasPegoutTxSigHash(lastPegoutSigHash.get()));
}
assertTrue(bridgeStorageProvider.hasPegoutTxSigHash(lastPegoutSigHash.get()));
}

private void assertPegoutTxSigHashesAreNotSaved(BtcTransaction pegoutTx, ActivationConfig.ForBlock activations) {
var lastPegoutSigHash = BitcoinUtils.getFirstInputSigHash(pegoutTx);
assertTrue(lastPegoutSigHash.isPresent());
assertFalse(bridgeStorageProvider.hasPegoutTxSigHash(lastPegoutSigHash.get()));
}

private void verifyPegoutTransactionCreatedEvent(BtcTransaction pegoutTx) {
Expand Down

0 comments on commit aea897a

Please sign in to comment.