-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[transaction test] refactoring publishing flow to test_context #6529
Conversation
a45ba8e
to
4591e5c
Compare
@@ -815,38 +817,35 @@ async fn test_get_txn_execute_failed_by_entry_function_invalid_function_name() { | |||
.await; | |||
} | |||
|
|||
#[ignore] // Re-enable when change is moved to new publish flow | |||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | |||
async fn test_get_txn_execute_failed_by_entry_function_execution_failure() { |
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.
Are you planning to update other module publishing tests in this same PR or a separate one?
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'll do that in the following PR.
...sts__transactions_test__test_get_txn_execute_failed_by_entry_function_execution_failure.json
Outdated
Show resolved
Hide resolved
@@ -288,6 +289,7 @@ dependencies = [ | |||
"aptos-types", | |||
"aptos-vm", | |||
"aptos-vm-validator", | |||
"bcs 0.1.4 (git+https://github.com/aptos-labs/bcs.git?rev=d31fab9d81748e2594be5cd5cdf845786a30562d)", |
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.
Where did this come from?
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'm not sure... I don't think I need this? how should I remove?
c2130ee
to
62ea52e
Compare
In the last commit
|
ff280da
to
35d4056
Compare
@@ -296,8 +295,15 @@ impl TestContext { | |||
TransactionFactory::new(self.context.chain_id()) | |||
} | |||
|
|||
pub fn root_account(&self) -> LocalAccount { | |||
LocalAccount::new(aptos_test_root_address(), self.root_key.private_key(), 0) | |||
pub async fn root_account(&self) -> LocalAccount { |
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.
Why not just avoid fetching the sequence number altogether by storing it in the test_context? This would avoid having to make this root_account function async as well.
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.
but in this way we have to make new_text_context() an async func. I think it's fine either way.
self.commit_mempool_txns(1).await; | ||
account | ||
} | ||
pub async fn create_user_account(&self, account: &LocalAccount) -> SignedTransaction { |
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.
Is this still useful if create_account already takes care of submitting the tx? Can we remove this somehow?
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 it's still useful because we test different things during submitting the txn. that being said, I think we can replace some with the new create_account(). I don't want to keep growing this PR. I can do it in the following ones.
self.create_user_account_by(&mut tc, account) | ||
} | ||
|
||
pub fn mint_user_account(&self, account: &LocalAccount) -> SignedTransaction { | ||
let mut tc = self.root_account(); | ||
pub async fn mint_user_account(&self, account: &LocalAccount) -> SignedTransaction { |
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.
Same here. This is already part of create_account now
api/test-context/src/test_context.rs
Outdated
account_address: &AccountAddress, | ||
resource: &str, | ||
) -> Option<Value> { | ||
let request = format!("/accounts/{}/resources", account_address); |
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.
Why not use the API for fetching a specific resource instead of fetching them all then filtering for the right one?
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.
If we use context.get() it throws an error when the resource doesn't exist.
self.get(&request).await | ||
} | ||
|
||
pub fn build_package( |
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.
Do we need separate build_package and publish_package?
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.
it comes from #6055. In that PR the author split the function into 2, I moved those functions here.
api/test-context/src/test_context.rs
Outdated
@@ -438,18 +512,29 @@ impl TestContext { | |||
.unwrap(); | |||
} | |||
|
|||
pub async fn get_sequence_number(&self, account: AccountAddress) -> u64 { | |||
let account_resource = self | |||
.api_get_account_resource(account, "0x1", "account", "Account") |
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.
Do you know why we need to pass "0x1", "account", "Account" to api_get_account_resource? The account resource is always at the same path
35d4056
to
57b3c2e
Compare
.await; | ||
self.commit_mempool_txns(1).await; | ||
account | ||
} |
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.
nit: add an empty line in between functions
@@ -0,0 +1,9 @@ | |||
[package] | |||
name = "TransactationTests" |
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.
TransactionTests
Please run |
c4a88a7
to
a1887a6
Compare
…ewrite the test test_get_txn_execute_failed_by_entry_function_execution_failure
a1887a6
to
cd9744b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
Description
In this PR I move some helper functions from resource_groups.rs to text_context.rs to be shared forward.
Test Plan
Test 2 modified tests to make sure they work as before
also add RUST_MIN_STACK=4297152 in the command to avoid the stack overflow error
RUST_MIN_STACK=4297152 cargo test test_read_resource_group
RUST_MIN_STACK=4297152 cargo test test_get_txn_execute_failed_by_invalid_entry_function
Here's the list of the current tests in transaction_tests.rs
https://www.notion.so/aptoslabs/2eb26689160a46379ebe0ab6327679ac?v=27ededd87b5d4e328d42c9cf8eab6dc6