def context(score_db):
    context = IconScoreContext(IconScoreContextType.DIRECT)
    context.current_address = score_db.address

    ContextContainer._push_context(context)
    yield context
    ContextContainer._clear_context()
예제 #2
0
def _for_profile_function(range_cnt: int, _create_db_func: callable):
    db = _create_db_func(range_cnt)
    _context = IconScoreContext(IconScoreContextType.DIRECT)
    _context.current_address = db.address
    _context.revision = REVISION
    ContextContainer._push_context(_context)

    array_db = ArrayDB(ARRAY_DB, db, value_type=Address)

    for index in range(range_cnt):
        addr: 'Address' = create_address()
        array_db.put(addr)

    for i in range(range_cnt):
        a = array_db[i]

    ContextContainer._clear_context()
def context():
    ctx = IconScoreContext(IconScoreContextType.DIRECT)
    ctx.tx = Transaction(tx_hash=create_tx_hash(), origin=EOA1)
    ctx.block = Block(block_height=0, block_hash=create_block_hash(), timestamp=0, prev_hash=None)
    ctx.msg = Message(sender=EOA1, value=0)
    ctx.icon_score_mapper = IconScoreMapper()
    ctx.new_icon_score_mapper = {}
    ctx.step_counter = IconScoreStepCounter(1, {}, 1000, False)
    ctx.event_logs = []
    ctx.traces = []
    ctx.current_address = EOA1
    IconScoreContext.storage = ContextStorage(deploy=Mock(spec=Storage), fee=None, icx=None, iiss=None, prep=None,
                                              issue=None, meta=None, rc=None, inv=None)

    ContextContainer._push_context(ctx)
    yield ctx
    ContextContainer._pop_context()