-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adds 'should create multiple pegouts with mixed values same and above… #163
Changes from 1 commit
9d7372e
bc9cb09
1fce5b7
bb4a7eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,8 +36,8 @@ const { sendPegin, | |
fundRskAccountThroughAPegin, | ||
createExpectedReleaseRequestRejectedEvent, | ||
} = require('../2wp-utils'); | ||
const { getBtcAddressBalanceInSatoshis } = require('../btc-utils'); | ||
const { ensure0x, removePrefix0x } = require('../utils'); | ||
const { getBtcAddressBalanceInSatoshis, base58AddressToHexString } = require('../btc-utils'); | ||
const { ensure0x, removePrefix0x, wait } = require('../utils'); | ||
const { getBridgeState } = require('@rsksmart/bridge-state-data-parser'); | ||
const bitcoinJsLib = require('bitcoinjs-lib'); | ||
const { deployCallReleaseBtcContract } = require('../contractDeployer'); | ||
|
@@ -962,6 +962,21 @@ const execute = (description, getRskHost) => { | |
|
||
// Assert | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check the Bridge state at this point? To assert there are 3 pegout requests created There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
|
||
const bridgeStateAfterPegoutRequestsReceived = await getBridgeState(rskTxHelper.getClient()); | ||
const pegoutRequests = bridgeStateAfterPegoutRequestsReceived.pegoutRequests; | ||
|
||
expect(pegoutRequests.length).to.be.equal(3); | ||
|
||
// They could be in any order, so we need to find them. | ||
const pegoutRequest1 = findPegoutRequest(pegoutRequests, pegoutTransaction1.transactionHash); | ||
const pegoutRequest2 = findPegoutRequest(pegoutRequests, pegoutTransaction2.transactionHash); | ||
const pegoutRequest3 = findPegoutRequest(pegoutRequests, pegoutTransaction3.transactionHash); | ||
|
||
// Assert that the pegout requests are in the Bridge | ||
assertBridgePegoutRequest(pegoutRequest1, base58AddressToHexString(senderRecipientInfo1.btcSenderAddressInfo.address), pegout1ValueInSatoshis, pegoutTransaction1.transactionHash); | ||
assertBridgePegoutRequest(pegoutRequest2, base58AddressToHexString(senderRecipientInfo2.btcSenderAddressInfo.address), pegout2ValueInSatoshis, pegoutTransaction2.transactionHash); | ||
assertBridgePegoutRequest(pegoutRequest3, base58AddressToHexString(senderRecipientInfo3.btcSenderAddressInfo.address), pegout3ValueInSatoshis, pegoutTransaction3.transactionHash); | ||
|
||
let bridgeStateAfterPegoutCreation; | ||
|
||
// Callback to get the bridge state after the pegout is created | ||
|
@@ -1278,6 +1293,22 @@ const getAddressUtxo = (outputs, address) => { | |
}); | ||
}; | ||
|
||
const assertBridgePegoutRequest = (pegoutRequest, btcDestinationAddressHash160, amountInSatoshis, rskTxHash) => { | ||
expect(pegoutRequest.destinationAddressHash160).to.be.equal(btcDestinationAddressHash160); | ||
expect(Number(pegoutRequest.amountInSatoshis)).to.be.equal(amountInSatoshis); | ||
expect(ensure0x(pegoutRequest.rskTxHash)).to.be.equal(rskTxHash); | ||
}; | ||
|
||
/** | ||
* | ||
* @param {Array<PegoutRequest>} bridgePegoutRequests the pegout requests array from the bridge state | ||
* @param {string} rskTxHash the tx hash of the pegout request | ||
* @returns {PegoutRequest | undefined} the pegout request object from the bridge state, or undefined if not found | ||
*/ | ||
const findPegoutRequest = (bridgePegoutRequests, rskTxHash) => { | ||
return bridgePegoutRequests.find(pegoutRequest => ensure0x(pegoutRequest.rskTxHash) === rskTxHash); | ||
}; | ||
|
||
module.exports = { | ||
execute, | ||
}; |
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.
toHexString
doesn't say much. Maybe we should call thistoHash160
? If that is the case, not sure what the hex string is representing hereThere 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.
Updated.