Skip to content

Commit

Permalink
add a test for resource group
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjiao committed Jan 21, 2025
1 parent ef78b75 commit 513803f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
37 changes: 35 additions & 2 deletions executor/tests/script_function_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use starcoin_vm_types::transaction::{
use starcoin_vm_types::vm_status::KeptVMStatus;
use std::ops::Sub;
use test_helper::executor::{
compile_ir_script, compile_modules_with_address, compile_script, execute_and_apply,
prepare_genesis,
association_execute_should_success, compile_ir_script, compile_modules_with_address,
compile_script, execute_and_apply, prepare_genesis,
};
use test_helper::txn::create_account_txn_sent_as_association;

Expand Down Expand Up @@ -463,3 +463,36 @@ fn test_transaction_arg_verify() -> Result<()> {
);
Ok(())
}

// this test aims to check if resource group works well
#[stest::test]
fn test_object_metadata() -> Result<()> {
let (chain_state, net) = prepare_genesis();

let script = prepare_script(
SyntaxChoice::Source,
r#"
script{
use std::option;
use std::string;
use starcoin_std::debug;
use starcoin_framework::object;
use starcoin_framework::coin;
use starcoin_framework::starcoin_coin::STC;
fun test_metadata(_account: &signer) {
debug::print(&string::utf8(b"test_metadata | entered"));
let metadata = coin::paired_metadata<STC>();
assert!(option::is_some(&metadata), 10000);
let metdata_obj = option::destroy_some(metadata);
assert!(object::is_object(object::object_address(&metdata_obj)), 10001);
debug::print(&string::utf8(b"test_metadata | exited"));
}
}
"#,
)?;
let payload = TransactionPayload::Script(Script::new(script, vec![], vec![]));
let output = association_execute_should_success(&net, &chain_state, payload)?;
assert_eq!(KeptVMStatus::Executed, output.status().status().unwrap());
Ok(())
}
3 changes: 0 additions & 3 deletions vm/vm-runtime/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ pub fn get_resource_group_member_from_metadata(
struct_tag,
metadata.len()
);
if metadata.is_empty() && struct_tag.name.as_ident_str().as_str() == "ObjectCore" {
panic!("let's see the backtrace");
}
let metadata = starcoin_framework::get_metadata(metadata)?;
eprintln!(
"get_resource_group_member_from_metadata {} metadata struct_attributes {:?}",
Expand Down

0 comments on commit 513803f

Please sign in to comment.