-
Notifications
You must be signed in to change notification settings - Fork 79
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
Update SDK Tests using the latest change in mock grpc #559
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
.first() | ||
.expect("No transactions found") | ||
.version; | ||
let starting_version = 1; |
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.
Having user define starting version themself might get confusing, how do they know to always start at 1? We can have a function that takes in the vec of transactions they want to test and returns a TransactionStreamConfig already set up with the right configuration that will work with the mock grpc.
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.
yeah that makes sense, I also thought it would be a devEx gap. then, it would also makes more sense to name the folder with original version for us too, when the custom file name isn't specified.
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.
one downside of stubbing out txn_versions would confuse users when they write their validation logic. we would have to tell them to use version 1, 2, 3, to query db.
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.
hmm what if instead of stubbing, the mock grpc just returns the transactions sorted in order of version?
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.
so then user uses [txn3, txn1, txn5] as an input, then grpc retruns [txn1, txn3, txn5]?
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.
Yeah exactly. I guess we have to choose between
- whether mock grpc allows gaps within the transaction batches
- stubbing out transaction versions -> you lose contextual information about the transaction
- require that scenario test txn's have no gaps (this is hard since there's no guarantee when submitting txn's that there won't be a gap)
Taking a step back, I think the goal here is to be able to test multiple txn's in a single test, so I think #1 could work here. The risk I see with #1 is if the user is writing a multi-txn test and their processor panics if it sees gaps within a txn batch. I think this is a minimal risk; as a mitigation, the user could always fallback to using single-txn test case.
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.
yeah the goal of this test is to processors not to test grpc, so it makes sense to allow mock grpc with gaps.
pub const ALL_IMPORTED_TESTNET_TXNS: &[&[u8]] = &[ | ||
IMPORTED_TESTNET_TXNS_1_GENESIS, | ||
IMPORTED_TESTNET_TXNS_2_NEW_BLOCK_EVENT, | ||
IMPORTED_TESTNET_TXNS_3_EMPTY_TXN, | ||
IMPORTED_TESTNET_TXNS_278556781_V1_COIN_REGISTER_FA_METADATA, | ||
IMPORTED_TESTNET_TXNS_1255836496_V2_FA_METADATA_, | ||
IMPORTED_TESTNET_TXNS_5523474016_VALIDATOR_TXN, | ||
IMPORTED_TESTNET_TXNS_5979639459_COIN_REGISTER, | ||
IMPORTED_TESTNET_TXNS_5992795934_FA_ACTIVITIES, | ||
]; |
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.
For the intentional tests, what are your thoughts on splitting these transactions up into separate test cases? Right now the test name is testnet_events_processor_db_output_diff_test
but we could make it more contextual and include what scenario it's actually testing.
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.
yeah i can split this into a separate test case.
|
||
#[cfg(test)] | ||
pub mod events_processor_tests; | ||
#[cfg(test)] | ||
pub mod fungible_asset_processor_tests; | ||
|
||
#[allow(dead_code)] | ||
pub const DEFAULT_OUTPUT_FOLDER: &str = "sdk_expected_db_output_files/"; | ||
pub const DEFAULT_OUTPUT_FOLDER: &str = "sdk_expected_db_output_files2"; |
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.
Did you mean to change this?
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 wanted to show what the new folder structure would look like so that we can compare. However, since we are going to keep the original version as a folder name, you can ignore this!
@@ -1,10 +1,10 @@ | |||
[ | |||
{ | |||
"transaction_version": 21, | |||
"transaction_version": 8, |
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.
Maybe we even stub out transaction_version, transaction_timestamp, and transaction_epoch, since these are not relevant to the test. Can add as a TODO
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.
yeah wanted to hear your opinion on these, wasn't sure if they would really care about those.
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 think your point of using the txn_version to debug a failed test is valid, so we should probably keep for now.
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.
Minor comments, stamping to unblock!
519dbe3
to
264877c
Compare
Description
update tests based on the latest change in sdk testing framework where it stubs out the txn version in mock grpc to avoid having gaps.
TODO:
Test Plan