Struct ckb_testtool::context::Context
source · pub struct Context {
pub cells: HashMap<OutPoint, (CellOutput, Bytes)>,
pub transaction_infos: HashMap<OutPoint, TransactionInfo>,
pub headers: HashMap<Byte32, HeaderView>,
pub epoches: HashMap<Byte32, EpochExt>,
pub cells_by_data_hash: HashMap<Byte32, OutPoint>,
/* private fields */
}Expand description
Verification Context
Fields§
§cells: HashMap<OutPoint, (CellOutput, Bytes)>§transaction_infos: HashMap<OutPoint, TransactionInfo>§headers: HashMap<Byte32, HeaderView>§epoches: HashMap<Byte32, EpochExt>§cells_by_data_hash: HashMap<Byte32, OutPoint>Implementations§
source§impl Context
impl Context
pub fn deploy_contract(&mut self, data: Bytes) -> OutPoint
sourcepub fn deploy_cell(&mut self, data: Bytes) -> OutPoint
pub fn deploy_cell(&mut self, data: Bytes) -> OutPoint
Deploy a cell return the out-point of the cell
sourcepub fn insert_header(&mut self, header: HeaderView)
pub fn insert_header(&mut self, header: HeaderView)
Insert a block header into context
sourcepub fn link_cell_with_block(
&mut self,
out_point: OutPoint,
block_hash: Byte32,
tx_index: usize
)
pub fn link_cell_with_block( &mut self, out_point: OutPoint, block_hash: Byte32, tx_index: usize )
Link a cell with a block to make the load_header_by_cell syscalls works
pub fn get_contract_out_point(&self, data_hash: &Byte32) -> Option<OutPoint>
sourcepub fn get_cell_by_data_hash(&self, data_hash: &Byte32) -> Option<OutPoint>
pub fn get_cell_by_data_hash(&self, data_hash: &Byte32) -> Option<OutPoint>
Get the out-point of a cell by data_hash the cell must has deployed to this context
sourcepub fn create_cell(&mut self, cell: CellOutput, data: Bytes) -> OutPoint
pub fn create_cell(&mut self, cell: CellOutput, data: Bytes) -> OutPoint
Create a cell with data return the out-point
sourcepub fn create_cell_with_out_point(
&mut self,
out_point: OutPoint,
cell: CellOutput,
data: Bytes
)
pub fn create_cell_with_out_point( &mut self, out_point: OutPoint, cell: CellOutput, data: Bytes )
Create cell with specified out-point and cell data
pub fn insert_cell( &mut self, out_point: OutPoint, cell: CellOutput, data: Bytes )
sourcepub fn get_cell(&self, out_point: &OutPoint) -> Option<(CellOutput, Bytes)>
pub fn get_cell(&self, out_point: &OutPoint) -> Option<(CellOutput, Bytes)>
Get cell output and data by out-point
sourcepub fn build_script_with_hash_type(
&mut self,
out_point: &OutPoint,
hash_type: ScriptHashType,
args: Bytes
) -> Option<Script>
pub fn build_script_with_hash_type( &mut self, out_point: &OutPoint, hash_type: ScriptHashType, args: Bytes ) -> Option<Script>
Build script with out_point, hash_type, args return none if the out-point is not exist
sourcepub fn build_script(
&mut self,
out_point: &OutPoint,
args: Bytes
) -> Option<Script>
pub fn build_script( &mut self, out_point: &OutPoint, args: Bytes ) -> Option<Script>
Build script with out_point, args (hash_type = ScriptHashType::Data1) return none if the out-point is not exist
sourcepub fn complete_tx(&mut self, tx: TransactionView) -> TransactionView
pub fn complete_tx(&mut self, tx: TransactionView) -> TransactionView
Complete cell deps for a transaction this function searches context cells; generate cell dep for referenced scripts.
pub fn capture_debug(&self) -> bool
sourcepub fn set_capture_debug(&mut self, capture_debug: bool)
pub fn set_capture_debug(&mut self, capture_debug: bool)
Capture debug output, default value is false
sourcepub fn captured_messages(&self) -> Vec<Message> ⓘ
pub fn captured_messages(&self) -> Vec<Message> ⓘ
return captured messages