Skip to content

Commit 1f941cf

Browse files
committed
Renames variables.
1 parent 334bad1 commit 1f941cf

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

lib/constants/bridge-constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const BRIDGE_ADDRESS = '0x0000000000000000000000000000000001000006';
2+
const FLYOVER_DERIVATION_HASH = '0000000000000000000000000000000000000000000000000000000000000001';
23

34
module.exports = {
4-
BRIDGE_ADDRESS
5+
BRIDGE_ADDRESS,
6+
FLYOVER_DERIVATION_HASH,
57
};

lib/federation-utils.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,29 @@ const getProposedFederationPublicKeys = async (bridge) => {
120120

121121
};
122122

123+
const getProposedFederationInfo = async (bridge) => {
124+
125+
const proposedFederationInfoResponses = await Promise.all([
126+
bridge.methods.getProposedFederationSize().call(),
127+
bridge.methods.getProposedFederationAddress().call(),
128+
bridge.methods.getProposedFederationCreationBlockNumber().call(),
129+
bridge.methods.getProposedFederationCreationTime().call()
130+
]);
131+
132+
const size = Number(proposedFederationInfoResponses[0]);
133+
const address = proposedFederationInfoResponses[1];
134+
const creationBlockNumber = Number(proposedFederationInfoResponses[2]);
135+
const creationTime = Number(proposedFederationInfoResponses[3]);
136+
137+
return {
138+
size,
139+
address,
140+
creationBlockNumber,
141+
creationTime,
142+
};
143+
144+
};
145+
123146
const getRetiringFederationPublicKeys = async (bridge) => {
124147

125148
const retiringFederationKeys = [];
@@ -144,29 +167,6 @@ const getRetiringFederationPublicKeys = async (bridge) => {
144167

145168
};
146169

147-
const getProposedFederationInfo = async (bridge) => {
148-
149-
const proposedFederationInfoResponses = await Promise.all([
150-
bridge.methods.getProposedFederationSize().call(),
151-
bridge.methods.getProposedFederationAddress().call(),
152-
bridge.methods.getProposedFederationCreationBlockNumber().call(),
153-
bridge.methods.getProposedFederationCreationTime().call()
154-
]);
155-
156-
const size = Number(proposedFederationInfoResponses[0]);
157-
const address = proposedFederationInfoResponses[1];
158-
const creationBlockNumber = Number(proposedFederationInfoResponses[2]);
159-
const creationTime = Number(proposedFederationInfoResponses[3]);
160-
161-
return {
162-
size,
163-
address,
164-
creationBlockNumber,
165-
creationTime,
166-
};
167-
168-
};
169-
170170
const getActiveFederationInfo = async (bridge) => {
171171

172172
const activeFederationInfoResponses = await Promise.all([

lib/tests/change-federation.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const BridgeTransactionParser = require('@rsksmart/bridge-transaction-parser');
1717
const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser');
1818
const { btcToWeis, satoshisToBtc } = require('@rsksmart/btc-eth-unit-converter');
1919
const { expect } = require('chai');
20-
const { BRIDGE_ADDRESS } = require('../constants/bridge-constants');
20+
const { BRIDGE_ADDRESS, FLYOVER_DERIVATION_HASH } = require('../constants/bridge-constants');
2121
const {
2222
KEY_TYPE_BTC,
2323
KEY_TYPE_RSK,
@@ -131,8 +131,8 @@ const execute = (description, newFederationConfig, makeDonationPegins = false) =
131131
expectedNewFederationErpRedeemScript = expectedNewFederationErpRedeemScriptBuffer.toString('hex');
132132
expectedNewFederationAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', expectedNewFederationErpRedeemScriptBuffer);
133133

134-
const flyoverPowpegRedeemScript = redeemScriptParser.getFlyoverRedeemScript(expectedNewFederationErpRedeemScriptBuffer, "0000000000000000000000000000000000000000000000000000000000000001");
135-
expectedFlyoverAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverPowpegRedeemScript);
134+
const flyoverNewFederationRedeemScript = redeemScriptParser.getFlyoverRedeemScript(expectedNewFederationErpRedeemScriptBuffer, FLYOVER_DERIVATION_HASH);
135+
expectedFlyoverAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverNewFederationRedeemScript);
136136

137137
initialActiveFederationInfo = await getActiveFederationInfo(bridge);
138138

@@ -307,25 +307,25 @@ const execute = (description, newFederationConfig, makeDonationPegins = false) =
307307
expect(finalBridgeState.pegoutsWaitingForConfirmations.length).to.be.equal(1, 'There should be one pegout waiting for confirmations.');
308308
expect(finalBridgeState.pegoutsWaitingForSignatures.length).to.be.equal(0, 'No pegout should be waiting for signatures.');
309309

310-
const svpPegoutWaitingForConfirmations = finalBridgeState.pegoutsWaitingForConfirmations[0];
310+
const svpFundTxWaitingForConfirmations = finalBridgeState.pegoutsWaitingForConfirmations[0];
311311

312-
const pegoutCreationBlockNumber = Number(svpPegoutWaitingForConfirmations.pegoutCreationBlockNumber);
312+
const pegoutCreationBlockNumber = Number(svpFundTxWaitingForConfirmations.pegoutCreationBlockNumber);
313313

314314
const expectedPegoutCreationBlockNumber = commitFederationCreationBlockNumber + 1;
315315
expect(pegoutCreationBlockNumber).to.be.equal(expectedPegoutCreationBlockNumber, 'The svp fund tx pegout creation block number should be the block that contains the first updateCollections call right after the commitFederation call.');
316316

317-
const rawSvpBtcTransaction = svpPegoutWaitingForConfirmations.btcRawTx;
317+
const rawSvpFundTransaction = svpFundTxWaitingForConfirmations.btcRawTx;
318318

319-
const btcTransaction = bitcoinJsLib.Transaction.fromHex(rawSvpBtcTransaction);
319+
const svpFundTransaction = bitcoinJsLib.Transaction.fromHex(rawSvpFundTransaction);
320320

321-
expect(btcTransaction.outs.length).to.be.equal(3, 'The SVP fund transaction should have 3 outputs.');
321+
expect(svpFundTransaction.outs.length).to.be.equal(3, 'The SVP fund transaction should have 3 outputs.');
322322

323323
const proposedFederationAddress = await bridge.methods.getProposedFederationAddress().call();
324324

325325
// The output addresses should be in the expected order.
326-
const proposedFederationOutput = btcTransaction.outs[0];
327-
const proposedFederationFlyoverOutput = btcTransaction.outs[1];
328-
const activeFederationOutput = btcTransaction.outs[2];
326+
const proposedFederationOutput = svpFundTransaction.outs[0];
327+
const proposedFederationFlyoverOutput = svpFundTransaction.outs[1];
328+
const activeFederationOutput = svpFundTransaction.outs[2];
329329

330330
const actualProposedFederationAddress = bitcoinJsLib.address.fromOutputScript(proposedFederationOutput.script, btcTxHelper.btcConfig.network);
331331
expect(actualProposedFederationAddress).to.be.equal(proposedFederationAddress, 'The proposed federation address in the SVP fund transaction should be the first output.');
@@ -344,21 +344,21 @@ const execute = (description, newFederationConfig, makeDonationPegins = false) =
344344
expect(proposedFederationFlyoverOutput.value).to.be.equal(expectedFlyoverOutputValue, 'The flyover output value should be double the minimum pegout value.');
345345

346346
// Only the svp fund tx hash unsigned value should be in storage
347-
await assertOnlySvpFundTxHashUnsignedIsInStorage(rskTxHelper, btcTransaction.getId());
347+
await assertOnlySvpFundTxHashUnsignedIsInStorage(rskTxHelper, svpFundTransaction.getId());
348348

349349
// The release_requested event should be emitted with the expected values
350350
const releaseRequestedEvent = await rskUtils.findEventInBlock(rskTxHelper, PEGOUT_EVENTS.RELEASE_REQUESTED.name, expectedPegoutCreationBlockNumber);
351351
const expectedReleaseRequestedAmount = expectedProposedFederationOutputValue + expectedFlyoverOutputValue;
352352
expect(Number(releaseRequestedEvent.arguments.amount)).to.be.equal(expectedReleaseRequestedAmount, 'The amount in the release requested event should be the sum of the proposed federation and flyover output values.');
353353
expect(releaseRequestedEvent, 'The release requested event should be emitted.').to.not.be.null;
354-
expect(removePrefix0x(releaseRequestedEvent.arguments.btcTxHash)).to.be.equal(btcTransaction.getId(), 'The btc tx hash in the release requested event should be the tx id of the SVP fund tx.');
354+
expect(removePrefix0x(releaseRequestedEvent.arguments.btcTxHash)).to.be.equal(svpFundTransaction.getId(), 'The btc tx hash in the release requested event should be the tx id of the SVP fund tx.');
355355

356356
// The pegout_transaction_created event should be emitted with the expected values
357357
const pegoutTransactionCreatedEvent = await rskUtils.findEventInBlock(rskTxHelper, PEGOUT_EVENTS.PEGOUT_TRANSACTION_CREATED.name, expectedPegoutCreationBlockNumber);
358358
expect(pegoutTransactionCreatedEvent, 'The pegout transaction created event should be emitted.').to.not.be.null;
359-
expect(removePrefix0x(pegoutTransactionCreatedEvent.arguments.btcTxHash)).to.be.equal(btcTransaction.getId(), 'The btc tx hash in the pegout transaction created event should be the tx id of the SVP fund tx.');
359+
expect(removePrefix0x(pegoutTransactionCreatedEvent.arguments.btcTxHash)).to.be.equal(svpFundTransaction.getId(), 'The btc tx hash in the pegout transaction created event should be the tx id of the SVP fund tx.');
360360

361-
await assertPegoutTransactionCreatedOutpointValues(initialBridgeState, finalBridgeState, btcTransaction, pegoutTransactionCreatedEvent);
361+
await assertPegoutTransactionCreatedOutpointValues(initialBridgeState, finalBridgeState, svpFundTransaction, pegoutTransactionCreatedEvent);
362362

363363
});
364364

0 commit comments

Comments
 (0)