Пример #1
0
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
Пример #3
0
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
Пример #4
0
    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
Пример #5
0
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
Пример #6
0
    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
Пример #7
0
    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
Пример #8
0
def context():
    context = IconScoreContext(IconScoreContextType.DIRECT)
    context.tx_batch = TransactionBatch()
    context.block_batch = BlockBatch()
    yield context