Skip to content

added a test for the getEstimatedFeesForNextPegoutEvent#385

Open
julianlen wants to merge 31 commits intomainfrom
getEstimatedFees-tests
Open

added a test for the getEstimatedFeesForNextPegoutEvent#385
julianlen wants to merge 31 commits intomainfrom
getEstimatedFees-tests

Conversation

@julianlen
Copy link
Copy Markdown
Contributor

No description provided.

@julianlen julianlen requested a review from a team as a code owner April 9, 2026 16:26
@julianlen julianlen force-pushed the getEstimatedFees-tests branch 2 times, most recently from 4dc87a1 to d1782e7 Compare April 10, 2026 14:15
@julianlen julianlen force-pushed the getEstimatedFees-tests branch from d1782e7 to 30c16f7 Compare April 10, 2026 14:21
@julianlen julianlen force-pushed the getEstimatedFees-tests branch from 41e9b56 to 5356a97 Compare April 13, 2026 13:37
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
jeremy-then
jeremy-then previously approved these changes Apr 13, 2026
Copy link
Copy Markdown
Contributor

@jeremy-then jeremy-then left a comment

Choose a reason for hiding this comment

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

LGTM.

Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Comment thread lib/tests/get_estimated_fees_methods.js Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

missing a bunch of test cases: 0 requests, multiple requests, different pegout amounts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this wasn't the idea, it is an integration test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

98fd3d2

added a second part of each test as discussed checking getEstimatedFees with no pegout requests

Comment thread lib/tests/get_estimated_fees_methods.js Outdated
@julianlen julianlen force-pushed the getEstimatedFees-tests branch from 9a8f182 to e937fc3 Compare April 14, 2026 15:53
@julianlen julianlen force-pushed the getEstimatedFees-tests branch from bedb34f to 6ea1829 Compare April 14, 2026 16:04
Comment thread lib/tests/get_estimated_fees_methods.js
julia-zack
julia-zack previously approved these changes Apr 14, 2026
@@ -0,0 +1,3 @@
const getEstimatedFeesMethodsTests = require('../lib/tests/get_estimated_fees_methods');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

By the name of the file it will run after activateLatestFork, probably not a good idea.

It would be better to have this along with all the other "normal"
test scenarios. Tests that go after the activation of the latest fork are for testing the upcoming yet on development network upgrade

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 15cf620

let btcTxHelper;
let senderInfo;

const shouldReturnGreaterThanZeroErrorMessage = (methodName) =>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like this is only used with the same param always getEstimatedFeesForNextPegOutEvent so it probably doesn't make sense to keep it as method, could simply be a constant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 7855484 (it was used with both methods but for some reason I forgot to changed it to getEstimatedFeesForPegOutAmount)

Comment thread lib/tests/get_estimated_fees_methods.js Outdated
);
expect(peginUtxoInBridgeState).to.not.be.undefined;

await sendFromCow(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to send funds from the cow address? Weren't those funds already received from the peg-in?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 44cefb7

Number(btcToWeis(PEGOUT_SENDER_FUNDING_IN_BTC))
);

await sendTxToBridge(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to get the bridge state after this and assert there is a pegout request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 9bf91f0

Comment thread lib/tests/get_estimated_fees_methods.js Outdated
);
};

const sendPegoutWithEstimatedFees = async (estimatedFees) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const sendPegoutWithEstimatedFees = async (estimatedFees) => {
const sendPegoutWithEstimatedFees = async (estimatedFeesInSatoshis) => {

Adding the unit helps, it can get confusing vey fast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done ea8b9bd

// Ensuring there's no pegout pending in the Bridge contract
// after each test to avoid interference between tests
afterEach(async () => {
await triggerRelease(rskTxHelpers, btcTxHelper);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Get the bridge state and assert there are no pending pegout requests after this?

});

describe('getEstimatedFeesForNextPegOutEvent', () => {
it('should build pegouts from getEstimatedFeesForNextPegOutEvent when one pegout is queued and when none are queued, and process all pegouts', async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow this test.

get estimated fees with 1 request and assert it's > 0. Then add a second request and immediately process the pegouts, why?

Then get estimated fees with 0 requests and assert it's > 0.

Finally send a new pegout request and immediately process it.

It all seems a bit confusing

});

describe('getEstimatedFeesForPegOutAmount', () => {
it('should build pegouts from getEstimatedFeesForPegOutAmount when one pegout is queued and when none are queued, and process all pegouts', async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here.

Also, we should test passsing different values as the param of getEstimatedFeesForPegOutAmount. Perhaps we should have 2 utxos in the Bridge? So for one param it only needs 1 utxo and returns a certain value, for another param it needs 2 utxos to build the transaction so the fees are higher

@sonarqubecloud
Copy link
Copy Markdown

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.

4 participants