Skip to content

test: Add sync test for esplora and electrum#51

Merged
ItoroD merged 1 commit intobitcoindevkit:masterfrom
ItoroD:add-client-sync-tests
Mar 5, 2026
Merged

test: Add sync test for esplora and electrum#51
ItoroD merged 1 commit intobitcoindevkit:masterfrom
ItoroD:add-client-sync-tests

Conversation

@ItoroD
Copy link
Copy Markdown
Collaborator

@ItoroD ItoroD commented Mar 4, 2026

This pr addresses #44

@ItoroD ItoroD requested a review from thunderbiscuit as a code owner March 4, 2026 12:38
Copy link
Copy Markdown
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

Looking good! Thanks for adding those in. Just a few suggestions.

regtestEnv.mine(2)

//Wait 40 second for mining to complete and for electrum to index the new blocks before scanning
Thread.sleep(40000)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is inside a coroutine, you can use the delay() API, slightly more ergonomic. Within that your argument can then use the Duration type, so as to look like this:

delay(8.seconds)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

looks like 8 works

regtestEnv.send(newAddress.toString(), 0.12345678, 2.0)
regtestEnv.mine(2)

//Wait 40 second for mining to complete and for electrum to index the new blocks before scanning
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In my local tests I can easily bring it down to 8 seconds. Does that work for you too? I think 40 is too much probably.

Worth noting that it would be great to have some better way to deal with this, either here or in the regtest-toolbox library (we can open up an issue there maybe?).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Worth noting that it would be great to have some better way to deal with this, either here or in the regtest-toolbox library (we can open up an issue there maybe?).

I agree. (I have a few thoughts)

regtestEnv.mine(2)

//Wait 40 second for mining to complete and for esplora to index the new blocks before scanning
Thread.sleep(40000)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as the Electrum test. I think delay(X.seconds) would work nicely here, and we can bring it down a bit from the 40 probably.

wallet.persist(conn)

val balance = wallet.balance().total.toSat()
assert(balance > 0uL)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A nice message returning the balance would be good I think. Something like:

assert(balance > 0uL)
    "Balance should be greater than zero, but was $balance"
}

@ItoroD ItoroD force-pushed the add-client-sync-tests branch from 72c6787 to f299cca Compare March 5, 2026 08:56
Copy link
Copy Markdown
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

ACK f299cca.

@ItoroD ItoroD merged commit f299cca into bitcoindevkit:master Mar 5, 2026
1 check passed
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