Skip to content

Commit

Permalink
[smoke-test] Removing clean state dependency of some tests (#2143)
Browse files Browse the repository at this point in the history
Refines #2140 to fix flakiness.

Co-authored-by: Wolfgang Grieskamp <[email protected]>
  • Loading branch information
wrwg and Wolfgang Grieskamp authored Jul 22, 2022
1 parent f950804 commit 1aa3d87
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 9 deletions.
13 changes: 11 additions & 2 deletions testsuite/smoke-test/src/aptos/error_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ async fn submit_and_check_err<F: Fn(TransactionBuilder) -> 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]
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions testsuite/smoke-test/src/aptos/module_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AptosCoin>(addr)
}
}
6 changes: 3 additions & 3 deletions testsuite/smoke-test/src/aptos/string_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -48,7 +48,7 @@ async fn get_resource(ctx: &mut AptosContext<'_>) -> Result<Resource> {
.client()
.get_account_resource(
ctx.root_account().address(),
"0xA550C18::HelloWorld::ModuleData",
"0xA550C18::HelloWorldForStringArgs::ModuleData",
)
.await?;
Ok(resp.into_inner().unwrap())
Expand All @@ -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![],
Expand Down
6 changes: 6 additions & 0 deletions testsuite/smoke-test/src/aptos/string_args_modules/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "hello"
version = "0.0.0"

[dependencies]
AptosFramework = { local = "../../../../../aptos-move/framework/aptos-framework" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module 0xA550C18::HelloWorld {
module 0xA550C18::HelloWorldForStringArgs {
use std::string::{Self, String};
use std::signer;
use aptos_framework::coin;
Expand Down

0 comments on commit 1aa3d87

Please sign in to comment.