-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
114d361
commit 32088d7
Showing
22 changed files
with
649 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright © Aptos Foundation | ||
// Parts of the project are originally copyright © Meta Platforms, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use super::{new_test_context, new_test_context_with_db_sharding_and_internal_indexer}; | ||
use aptos_api_test_context::current_function_name; | ||
use serde_json::json; | ||
use std::time::Duration; | ||
use tokio::time::sleep; | ||
|
||
static MODULE_EVENT_MIGRATION: u64 = 57; | ||
|
||
const SLEEP_DURATION: Duration = Duration::from_millis(250); | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_feature_enable_disable() { | ||
let mut context = new_test_context(current_function_name!()); | ||
context.enable_feature(MODULE_EVENT_MIGRATION).await; | ||
assert!(context.is_feature_enabled(MODULE_EVENT_MIGRATION).await); | ||
context.disable_feature(MODULE_EVENT_MIGRATION).await; | ||
assert!(!context.is_feature_enabled(MODULE_EVENT_MIGRATION).await); | ||
context.enable_feature(MODULE_EVENT_MIGRATION).await; | ||
assert!(context.is_feature_enabled(MODULE_EVENT_MIGRATION).await); | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
async fn test_event_v2_translation_simulation() { | ||
// let context = &mut new_test_context(current_function_name!()); | ||
let context = | ||
&mut new_test_context_with_db_sharding_and_internal_indexer(current_function_name!()); | ||
|
||
let account1 = &mut context.create_account().await; | ||
sleep(SLEEP_DURATION).await; | ||
|
||
let account2 = &mut context.create_account().await; | ||
sleep(SLEEP_DURATION).await; | ||
|
||
context.enable_feature(MODULE_EVENT_MIGRATION).await; | ||
sleep(SLEEP_DURATION).await; | ||
|
||
let payload = json!({ | ||
"type": "entry_function_payload", | ||
"function": "0x1::coin::transfer", | ||
"type_arguments": ["0x1::aptos_coin::AptosCoin"], | ||
"arguments": [ | ||
account1.address().to_hex_literal(), "100" | ||
] | ||
}); | ||
let resp = context.simulate_transaction(account2, payload, 200).await; | ||
sleep(SLEEP_DURATION).await; | ||
|
||
// The V2 event should not appear. | ||
assert!(!resp[0]["events"] | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.any(|x| x["type"] == "0x1::coin::CoinDeposit")); | ||
|
||
// The translated V1 event should appear. | ||
assert!(resp[0]["events"] | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.any(|x| x["type"] == "0x1::coin::DepositEvent" | ||
&& x["guid"]["creation_number"] == "2" | ||
&& x["guid"]["account_address"] == account1.address().to_hex_literal())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.