-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: add excluded_ids
argument to Query.coinsToSpend
#237
Conversation
5bae419
to
8b396f7
Compare
@@ -255,29 +277,26 @@ mod tests { | |||
|
|||
use super::*; | |||
|
|||
fn gen_test_db(owner: Address, asset_ids: &[AssetId]) -> Database { | |||
static COIN_INDEX: AtomicU8 = AtomicU8::new(0); |
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.
we might want more than a u8 as this coin index may get reused by multiple tests in the future which could easily take up more than 255 coins. Alternately, don't use a static variable here so that the index is local to each test.
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.
I actually want to nuke this in favor of a more proper way to generate seeded databases.
If this was the TS repo I'd write a class TestDatabase extends Database { ... }
with helper methods and put the index counter in there. I'm yet to come up with a similar thing here though.
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.
The main issue is trying to use magic global variables. You could have a stateful db builder object that you initialize each test and call make_coin
as a function on the builder. Then you could have an impl From<TestDbBuilder> for Database
which creates a database and inserts all the data in one go.
Just a couple non-blocking minor nits from me, approved! |
Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
This PR partly implements #185. The unimplemented part was excluding coins in the txpool, but this isn't an immediately necessary feature.