Skip to content

Commit

Permalink
refactor: Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyytop committed Mar 11, 2021
1 parent 038362b commit b76c791
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 59 deletions.
9 changes: 3 additions & 6 deletions contracts/info-type/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use alloc::vec::Vec;
use ckb_std::{
ckb_constants::Source,
ckb_types::{bytes::Bytes, packed::*, prelude::*},
high_level::{
load_cell_data, load_cell_type, load_input_since, load_script,
QueryIter,
},
high_level::{load_cell_data, load_cell_type, load_input_since, load_script, QueryIter},
};
use core::result::Result;

Expand Down Expand Up @@ -77,8 +74,8 @@ fn check_info_cell_data() -> Result<(), Error> {
return Err(Error::TimeInfoDataLenError);
}
Ok(())
},
Err(_) => Err(Error::TimeInfoTypeNotExist)
}
Err(_) => Err(Error::TimeInfoTypeNotExist),
}
}

Expand Down
48 changes: 24 additions & 24 deletions tests/src/index_state_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ fn test_create_index_state_cells_success() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -251,9 +251,9 @@ fn test_update_index_state_cells_success() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -284,9 +284,9 @@ fn test_update_full_index_state_cells_success() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -315,9 +315,9 @@ fn test_error_index_state_len() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -346,9 +346,9 @@ fn test_error_info_amount() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -380,9 +380,9 @@ fn test_error_index_out_of_bound() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -413,9 +413,9 @@ fn test_error_args_invalid() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -468,9 +468,9 @@ fn test_error_index_not_increase() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 0,
is_lock_script: false,
is_output: true,
script_index: 0,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down
36 changes: 18 additions & 18 deletions tests/src/info_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ fn test_error_create_info_cell_data_len() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: true,
script_index: 1,
is_lock_script: false,
is_output: true,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -478,9 +478,9 @@ fn test_error_index_state_cell_data_len() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: false,
script_index: 1,
is_lock_script: false,
is_output: false,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -602,9 +602,9 @@ fn test_error_output_block_number_not_bigger() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: false,
script_index: 1,
is_lock_script: false,
is_output: false,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -656,9 +656,9 @@ fn test_error_output_block_number_since() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: false,
script_index: 1,
is_lock_script: false,
is_output: false,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -710,9 +710,9 @@ fn test_error_output_timestamp_not_bigger() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: false,
script_index: 1,
is_lock_script: false,
is_output: false,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down Expand Up @@ -764,9 +764,9 @@ fn test_error_output_timestamp_since() {

// dump raw test tx files
let setup = RunningSetup {
is_lock_script: false,
is_output: false,
script_index: 1,
is_lock_script: false,
is_output: false,
script_index: 1,
native_binaries: HashMap::default(),
};
write_native_setup(
Expand Down
20 changes: 9 additions & 11 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
#[macro_use]
extern crate lazy_static;

use ckb_standalone_debugger::transaction::{
MockCellDep, MockInfo, MockInput, MockTransaction, ReprMockTransaction,
};
use ckb_testtool::context::Context;
use ckb_tool::ckb_error::Error;
use ckb_tool::ckb_script::ScriptError;
use ckb_tool::ckb_types::bytes::Bytes;
use ckb_x64_simulator::RunningSetup;
use serde_json::to_string_pretty;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use ckb_testtool::context::Context;
use ckb_standalone_debugger::transaction::{
MockCellDep, MockInfo, MockInput, MockTransaction, ReprMockTransaction,
};
use ckb_x64_simulator::RunningSetup;
use serde_json::to_string_pretty;

use ckb_tool::ckb_types::{
core::{DepType, TransactionView},
};
use ckb_tool::ckb_types::core::{DepType, TransactionView};

#[cfg(test)]
mod info_tests;
Expand Down Expand Up @@ -150,8 +148,8 @@ fn build_mock_transaction(tx: &TransactionView, context: &Context) -> MockTransa
})
.collect();
let mock_info = MockInfo {
inputs: mock_inputs,
cell_deps: mock_cell_deps,
inputs: mock_inputs,
cell_deps: mock_cell_deps,
header_deps: vec![],
};
MockTransaction {
Expand Down

0 comments on commit b76c791

Please sign in to comment.