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

Adds 'should do a basic legacy pegin with the value above minimum' test #92

Conversation

jeremy-then
Copy link
Contributor

Adds a basic legacy pegin test with a value above minimum.
Besides the value above minimum, this pegin does the same checks as this test in this pr: #87

@jeremy-then jeremy-then self-assigned this Sep 24, 2024
@jeremy-then jeremy-then requested a review from a team as a code owner September 24, 2024 00:40
@jeremy-then jeremy-then force-pushed the add-legacy-pegin-test-above-minimum branch from be67f49 to a67efec Compare September 25, 2024 17:30
Base automatically changed from create-new-2wp-file to rits-refactors-9-2024-integration September 25, 2024 20:42
lib/tests/2wp.js Outdated
Comment on lines 102 to 83
const initialBridgeBalance = Number(await rskTxHelper.getBalance(BRIDGE_ADDRESS));
const initialBridgeUtxosBalance = await getBridgeUtxosBalance(rskTxHelper);
const initialFederationAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, federationAddress);
const senderRecipientInfo = await createSenderRecipientInfo(rskTxHelper, btcTxHelper);
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is gonna get repeated quite a lot, pre and post peg-in/peg-out. What do you think of extracting it to a method? The method could return an object with the different balances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

lib/tests/2wp.js Outdated
Comment on lines 118 to 119
const isBtcTxHashAlreadyProcessed = await bridge.methods.isBtcTxHashAlreadyProcessed(btcPeginTxHash).call();
expect(isBtcTxHashAlreadyProcessed).to.be.true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this maybe be part of ensurePeginIsRegistered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends. Somethings we want to assert that this is false. Inside ensurePeginIsRegistered it should always be true. But we can put it inside the ensurePeginIsRegistered and when needed, assert from the test that it is false.

lib/tests/2wp.js Outdated
Comment on lines 122 to 126
const recipient1RskAddressChecksumed = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(senderRecipientInfo.rskRecipientRskAddressInfo.address));
const expectedEvent = createExpectedPeginBtcEvent(PEGIN_EVENTS.PEGIN_BTC, recipient1RskAddressChecksumed, btcPeginTxHash, peginValueInSatoshis);
const btcTxHashProcessedHeight = Number(await bridge.methods.getBtcTxHashProcessedHeight(btcPeginTxHash).call());
const peginBtcEvent = await findEventInBlock(rskTxHelper, expectedEvent.name, btcTxHashProcessedHeight);
expect(peginBtcEvent).to.be.deep.equal(expectedEvent);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could also go into it's own method, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@jeremy-then jeremy-then changed the base branch from rits-refactors-9-2024-integration to refactor-federation-and-bridge-balances-check September 26, 2024 00:05
@jeremy-then jeremy-then force-pushed the add-legacy-pegin-test-above-minimum branch 2 times, most recently from dff4eb6 to 697367e Compare September 26, 2024 01:56
Base automatically changed from refactor-federation-and-bridge-balances-check to rits-refactors-9-2024-integration September 26, 2024 16:06
lib/tests/2wp.js Outdated
const senderRecipientInfo = await createSenderRecipientInfo(rskTxHelper, btcTxHelper);
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
// Value above minimum
const peginValueInSatoshis = minimumPeginValueInSatoshis + Number(btcToSatoshis(0.1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const peginValueInSatoshis = minimumPeginValueInSatoshis + Number(btcToSatoshis(0.1));
const peginValueInSatoshis = minimumPeginValueInSatoshis + 1;

Maybe make just above the minimum? To be sure

@jeremy-then jeremy-then force-pushed the add-legacy-pegin-test-above-minimum branch from 697367e to f700fbe Compare September 26, 2024 18:57
Copy link

@marcos-iov marcos-iov merged commit 24ffe3e into rits-refactors-9-2024-integration Sep 26, 2024
4 checks passed
@marcos-iov marcos-iov deleted the add-legacy-pegin-test-above-minimum branch September 26, 2024 19:38
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