From 1aa3d871f7666f880908c49227fd2d75d095574b Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Thu, 21 Jul 2022 17:34:44 -0700 Subject: [PATCH] [smoke-test] Removing clean state dependency of some tests (#2143) Refines #2140 to fix flakiness. Co-authored-by: Wolfgang Grieskamp --- .../smoke-test/src/aptos/error_report.rs | 13 +++++++++++-- .../smoke-test/src/aptos/module_publish.rs | 6 +++--- .../Move.toml | 0 .../module_publish_modules/sources/hello.move | 19 +++++++++++++++++++ testsuite/smoke-test/src/aptos/string_args.rs | 6 +++--- .../src/aptos/string_args_modules/Move.toml | 6 ++++++ .../sources/hello.move | 2 +- 7 files changed, 43 insertions(+), 9 deletions(-) rename testsuite/smoke-test/src/aptos/{move_modules => module_publish_modules}/Move.toml (100%) create mode 100644 testsuite/smoke-test/src/aptos/module_publish_modules/sources/hello.move create mode 100644 testsuite/smoke-test/src/aptos/string_args_modules/Move.toml rename testsuite/smoke-test/src/aptos/{move_modules => string_args_modules}/sources/hello.move (93%) diff --git a/testsuite/smoke-test/src/aptos/error_report.rs b/testsuite/smoke-test/src/aptos/error_report.rs index fcf5bbb4c0be8..63cbce8d84572 100644 --- a/testsuite/smoke-test/src/aptos/error_report.rs +++ b/testsuite/smoke-test/src/aptos/error_report.rs @@ -31,7 +31,12 @@ async fn submit_and_check_err TransactionBuilder>( "{:?}", ctx.client().submit_and_wait(&txn).await.unwrap_err() ); - assert!(err.contains(expected), "{}", err); + assert!( + err.contains(expected), + "expected = {}, err = {}", + expected, + err + ) } #[async_trait::async_trait] @@ -75,10 +80,14 @@ impl AptosTest for ErrorReport { "SEQUENCE_NUMBER_TOO_OLD", ) .await; + let root_account_sequence_number = ctx.root_account().sequence_number(); submit_and_check_err( &local_account, ctx, - |t| t.sender(aptos_root_address()).sequence_number(1), + |t| { + t.sender(aptos_root_address()) + .sequence_number(root_account_sequence_number) + }, "INVALID_AUTH_KEY", ) .await; diff --git a/testsuite/smoke-test/src/aptos/module_publish.rs b/testsuite/smoke-test/src/aptos/module_publish.rs index 49bbfb0817556..9f433ac31dd70 100644 --- a/testsuite/smoke-test/src/aptos/module_publish.rs +++ b/testsuite/smoke-test/src/aptos/module_publish.rs @@ -15,15 +15,15 @@ impl Test for ModulePublish { #[async_trait::async_trait] impl AptosTest for ModulePublish { async fn run<'t>(&self, ctx: &mut AptosContext<'t>) -> Result<()> { - let base_path = - std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/aptos/move_modules/"); + let base_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("src/aptos/module_publish_modules/"); // module publish should call init_module by default to create the resource move_test_helpers::publish_code(ctx, base_path.clone()).await?; ctx.client() .get_account_resource( ctx.root_account().address(), - "0xA550C18::HelloWorld::ModuleData", + "0xA550C18::HelloWorldForModulePublish::ModuleData", ) .await .unwrap(); diff --git a/testsuite/smoke-test/src/aptos/move_modules/Move.toml b/testsuite/smoke-test/src/aptos/module_publish_modules/Move.toml similarity index 100% rename from testsuite/smoke-test/src/aptos/move_modules/Move.toml rename to testsuite/smoke-test/src/aptos/module_publish_modules/Move.toml diff --git a/testsuite/smoke-test/src/aptos/module_publish_modules/sources/hello.move b/testsuite/smoke-test/src/aptos/module_publish_modules/sources/hello.move new file mode 100644 index 0000000000000..99d79745966ad --- /dev/null +++ b/testsuite/smoke-test/src/aptos/module_publish_modules/sources/hello.move @@ -0,0 +1,19 @@ +module 0xA550C18::HelloWorldForModulePublish { + use aptos_framework::coin; + use aptos_framework::aptos_coin::AptosCoin; + + struct ModuleData has key, store { + global_counter: u64, + } + + fun init_module(sender: &signer) { + move_to( + sender, + ModuleData { global_counter: 0 } + ); + } + + public fun foo(addr: address): u64 { + coin::balance(addr) + } +} diff --git a/testsuite/smoke-test/src/aptos/string_args.rs b/testsuite/smoke-test/src/aptos/string_args.rs index b075d67fda948..06aa9ef64bee1 100644 --- a/testsuite/smoke-test/src/aptos/string_args.rs +++ b/testsuite/smoke-test/src/aptos/string_args.rs @@ -21,7 +21,7 @@ impl Test for StringArgs { impl AptosTest for StringArgs { async fn run<'t>(&self, ctx: &mut AptosContext<'t>) -> Result<()> { let base_path = - std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/aptos/move_modules/"); + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/aptos/string_args_modules/"); let txn_factory = move_test_helpers::publish_code(ctx, base_path).await?; // After publish, expect state == "init" @@ -48,7 +48,7 @@ async fn get_resource(ctx: &mut AptosContext<'_>) -> Result { .client() .get_account_resource( ctx.root_account().address(), - "0xA550C18::HelloWorld::ModuleData", + "0xA550C18::HelloWorldForStringArgs::ModuleData", ) .await?; Ok(resp.into_inner().unwrap()) @@ -59,7 +59,7 @@ fn encode_hello_world_hi(msg: &str) -> TransactionPayload { TransactionPayload::ScriptFunction(ScriptFunction::new( ModuleId::new( AccountAddress::from_hex_literal("0xA550C18").unwrap(), - ident_str!("HelloWorld").to_owned(), + ident_str!("HelloWorldForStringArgs").to_owned(), ), ident_str!("hi").to_owned(), vec![], diff --git a/testsuite/smoke-test/src/aptos/string_args_modules/Move.toml b/testsuite/smoke-test/src/aptos/string_args_modules/Move.toml new file mode 100644 index 0000000000000..70189b41ee665 --- /dev/null +++ b/testsuite/smoke-test/src/aptos/string_args_modules/Move.toml @@ -0,0 +1,6 @@ +[package] +name = "hello" +version = "0.0.0" + +[dependencies] +AptosFramework = { local = "../../../../../aptos-move/framework/aptos-framework" } diff --git a/testsuite/smoke-test/src/aptos/move_modules/sources/hello.move b/testsuite/smoke-test/src/aptos/string_args_modules/sources/hello.move similarity index 93% rename from testsuite/smoke-test/src/aptos/move_modules/sources/hello.move rename to testsuite/smoke-test/src/aptos/string_args_modules/sources/hello.move index 8916c52a1f153..48e4814122cc3 100644 --- a/testsuite/smoke-test/src/aptos/move_modules/sources/hello.move +++ b/testsuite/smoke-test/src/aptos/string_args_modules/sources/hello.move @@ -1,4 +1,4 @@ -module 0xA550C18::HelloWorld { +module 0xA550C18::HelloWorldForStringArgs { use std::string::{Self, String}; use std::signer; use aptos_framework::coin;