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

Update SDK Tests using the latest change in mock grpc #559

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

yuunlimm
Copy link
Contributor

@yuunlimm yuunlimm commented Oct 21, 2024

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:

  • naming structure of files for diffing all txns, whether we keep using the original version as the folder name(preferred) or not.

Test Plan

Screenshot 2024-10-21 at 8 33 10 AM

Copy link
Contributor Author

yuunlimm commented Oct 21, 2024

@yuunlimm yuunlimm marked this pull request as ready for review October 21, 2024 15:33
@yuunlimm yuunlimm requested review from rtso and a team October 21, 2024 15:33
@yuunlimm yuunlimm changed the title Add Sdk tests (#554) Update SDK Tests using the latest change in mock grpc Oct 21, 2024
.first()
.expect("No transactions found")
.version;
let starting_version = 1;
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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]?

Copy link
Collaborator

@rtso rtso Oct 21, 2024

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

  1. whether mock grpc allows gaps within the transaction batches
  2. stubbing out transaction versions -> you lose contextual information about the transaction
  3. 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.

Copy link
Contributor Author

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.

Comment on lines 76 to 85
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,
];
Copy link
Collaborator

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.

Copy link
Contributor Author

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";
Copy link
Collaborator

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?

Copy link
Contributor Author

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,
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@rtso rtso left a 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!

@yuunlimm yuunlimm force-pushed the 10-16-support_multi_txns_testing branch from 519dbe3 to 264877c Compare October 22, 2024 18:08
@yuunlimm yuunlimm merged commit e825969 into main Oct 23, 2024
7 checks passed
@yuunlimm yuunlimm deleted the 10-16-support_multi_txns_testing branch October 23, 2024 00:11
@yuunlimm yuunlimm restored the 10-16-support_multi_txns_testing branch October 24, 2024 17:15
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