def context(): context = IconScoreContext(IconScoreContextType.DIRECT) context.tx_batch = TransactionBatch() context.block_batch = BlockBatch() ContextContainer._push_context(context) yield context ContextContainer._pop_context()
def _create_context(context_type: IconScoreContextType) -> IconScoreContext: context = IconScoreContext(context_type) if context.type == IconScoreContextType.INVOKE: context.block_batch = BlockBatch() context.tx_batch = TransactionBatch() return context
def _create_context(context_type: IconScoreContextType) -> IconScoreContext: context = IconScoreContext(context_type) if context.type == IconScoreContextType.INVOKE: context.block_batch = BlockBatch() context.tx_batch = TransactionBatch() mock_block: 'Mock' = Mock(spec=Block) mock_block.attach_mock(Mock(return_value=0), 'height') context.block = mock_block return context
def setUp(self): self.db_name = 'fee.db' self.address = create_address(AddressPrefix.EOA) db = ContextDatabase.from_path(self.db_name) self.assertIsNotNone(db) self.storage = FeeStorage(db) context = IconScoreContext(IconScoreContextType.DIRECT) context.tx_batch = TransactionBatch() context.block_batch = BlockBatch() self.context = context
def get_default_context(): context = IconScoreContext() block = Block() context.block = block context.icon_score_mapper = score_mapper context.traces = [] context.validate_score_blacklist = Mock(return_value=True) context.tx = Transaction() context.msg = Message() context.get_icon_score = get_icon_score context.block_batch = None context.tx_batch = None return context
def setUp(self): self.db_name = 'icx.db' db = ContextDatabase.from_path(self.db_name) self.assertIsNotNone(db) self.storage = IcxStorage(db) context = IconScoreContext(IconScoreContextType.DIRECT) context.tx_batch = TransactionBatch() mock_block: 'Mock' = Mock(spec=Block) mock_block.attach_mock(Mock(return_value=0), 'height') context.block = mock_block context.block_batch = BlockBatch() self.context = context
def setUp(self): state_db_root_path = 'state_db' self.state_db_root_path = state_db_root_path rmtree(state_db_root_path) os.mkdir(state_db_root_path) address = Address.from_data(AddressPrefix.CONTRACT, b'score') context = IconScoreContext(IconScoreContextType.INVOKE) context.block_batch = BlockBatch() context.tx_batch = TransactionBatch() db_path = os.path.join(state_db_root_path, 'db') context_db = ContextDatabase.from_path(db_path, True) meta_context_db = MetaContextDatabase(context_db.key_value_db) self.context_db = context_db self.meta_context_db = meta_context_db self.address = address self.context = context
def context(): context = IconScoreContext(IconScoreContextType.DIRECT) context.tx_batch = TransactionBatch() context.block_batch = BlockBatch() yield context