Skip to content

Commit

Permalink
add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Dec 9, 2024
1 parent 4e76c52 commit 990a1fc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions contrib-contracts/src/merkle_distributor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use starcoin_vm_types::token::stc::stc_type_tag;
use starcoin_vm_types::transaction::{EntryFunction, Package, TransactionPayload};
use starcoin_vm_types::value::MoveValue;
use test_helper::executor::{
association_execute, association_execute_should_success, compile_modules_with_address, compile_modules_with_address_internal, move_abort_code, prepare_genesis
association_execute, association_execute_should_success, compile_modules_with_address,
compile_modules_with_address_internal, move_abort_code, prepare_genesis,
};

#[derive(Serialize, Deserialize, Clone, Debug)]
Expand Down Expand Up @@ -43,7 +44,8 @@ fn test_merkle_distributor() -> Result<()> {

println!("YSG source_files: {:?}", source_files);

let modules = compile_modules_with_address_internal(association_address(), source, &source_files);
let modules =
compile_modules_with_address_internal(association_address(), source, &source_files);

let package = Package::new(modules, None)?;
association_execute_should_success(
Expand Down
11 changes: 7 additions & 4 deletions test-helper/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ pub fn get_balance<S: ChainStateReader>(address: AccountAddress, chain_state: &S
.expect("read balance resource should ok")
}

pub fn compile_modules_with_address_internal(address: AccountAddress, code: &str, libs: &Vec<String>)-> Vec<Module> {
pub fn compile_modules_with_address_internal(
address: AccountAddress,
code: &str,
libs: &Vec<String>,
) -> Vec<Module> {
let (_, compiled_result) =
starcoin_move_compiler::compile_source_string(code, libs, address)
.expect("compile fail");
starcoin_move_compiler::compile_source_string(code, libs, address).expect("compile fail");

compiled_result
.into_iter()
Expand All @@ -121,7 +124,7 @@ pub fn compile_modules_with_address_internal(address: AccountAddress, code: &str
}

pub fn compile_modules_with_address(address: AccountAddress, code: &str) -> Vec<Module> {
compile_modules_with_address_internal(address,code, &stdlib_files())
compile_modules_with_address_internal(address, code, &stdlib_files())
}

pub fn compile_script(code: impl AsRef<str>) -> Result<Vec<u8>> {
Expand Down
2 changes: 1 addition & 1 deletion vm/compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use move_compiler::shared::known_attributes::KnownAttribute;
use move_compiler::shared::{Flags, NumericalAddress};
use once_cell::sync::Lazy;
use regex::{Captures, Regex};
use starcoin_logger::prelude::info;
use starcoin_vm_types::account_address::AccountAddress;
use starcoin_vm_types::compatibility::Compatibility;
use starcoin_vm_types::file_format::CompiledModule;
Expand All @@ -25,7 +26,6 @@ use std::collections::{BTreeMap, HashMap};
use std::fs::OpenOptions;
use std::io::Read;
use std::path::{Path, PathBuf};
use starcoin_logger::prelude::info;

pub mod bytecode_transpose;

Expand Down
1 change: 1 addition & 0 deletions vm/framework/move-stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ smallvec = "1.6.1"
include_dir = { workspace = true }
once_cell = { workspace = true }
tempfile = { workspace = true }
starcoin-logger = { workspace = true }

[dev-dependencies]
dir-diff = "0.3.2"
Expand Down
6 changes: 4 additions & 2 deletions vm/framework/move-stdlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

use include_dir::{include_dir, Dir};
use once_cell::sync::Lazy;
use starcoin_logger::prelude::*;
pub const MOVE_STDLIB_SOURCES_DIR: Dir = include_dir!("sources");

pub static MOVE_STDLIB_SOURCE_FILES: Lazy<Vec<String>> = Lazy::new(|| {
let tempdir = tempfile::tempdir().expect("local dir should be created");
let sources_dir = tempdir.path().join("move-stdlib").join("sources");
std::fs::create_dir_all(sources_dir.as_path()).expect("create dir should success");
println!("restore move-stdlib sources in: {:?}", sources_dir);

MOVE_STDLIB_SOURCES_DIR
.extract(sources_dir.as_path())
.expect("extract should success");
info!("restore move-stdlib sources in: {:?}", sources_dir);
MOVE_STDLIB_SOURCES_DIR
.files()
.iter()
Expand All @@ -41,10 +43,10 @@ pub static STARCOIN_STDLIB_SOURCE_FILES: Lazy<Vec<String>> = Lazy::new(|| {
let tempdir = tempfile::tempdir().expect("local dir should be created");
let sources_dir = tempdir.path().join("starcoin-stdlib").join("sources");
std::fs::create_dir_all(sources_dir.as_path()).expect("create dir should success");
println!("restore starcoin-stdlib sources in: {:?}", sources_dir);
STARCOIN_STDLIB_SOURCES_DIR
.extract(sources_dir.as_path())
.expect("extract should success");
info!("restore starcoin-stdlib sources in: {:?}", sources_dir);
STARCOIN_STDLIB_SOURCES_DIR
.files()
.iter()
Expand Down

0 comments on commit 990a1fc

Please sign in to comment.