def setUp(self): db = Mock(spec=IconScoreDatabase) db.address = create_address(AddressPrefix.CONTRACT) context = IconScoreContext() traces = Mock(spec=list) context.tx = Mock(spec=Transaction) context.block = Mock(spec=Block) context.cumulative_step_used = Mock(spec=int) context.cumulative_step_used.attach_mock(Mock(), '__add__') context.step_counter = Mock(spec=IconScoreStepCounter) context.event_logs = Mock(spec=list) context.logs_bloom = Mock(spec=BloomFilter) context.traces = traces ContextContainer._push_context(context) context.icon_score_manager = Mock() context.icon_score_manager.get_owner = Mock(return_value=None) context.icon_score_manager.get_tx_hashes_by_score_address = \ Mock(return_value=(create_tx_hash(), create_tx_hash())) context.internal_call = InternalCall(context) context.internal_call._other_score_call = Mock() context.internal_call.icx_engine = Mock(spec=IcxEngine) context.icon_score_mapper = Mock() context.icon_score_mapper.get_icon_score = Mock( return_value=TestScore(db)) context.internal_call._validate_score_blacklist = Mock( return_value=False) self._score = TestScore(db)
def setUp(self): db = Mock(spec=IconScoreDatabase) db.address = create_address(AddressPrefix.CONTRACT) context = IconScoreContext() context.icon_score_deploy_engine = Mock() traces = Mock(spec=list) context.tx = Mock(spec=Transaction) context.block = Mock(spec=Block) context.cumulative_step_used = Mock(spec=int) context.cumulative_step_used.attach_mock(Mock(), '__add__') context.step_counter = Mock(spec=IconScoreStepCounter) context.event_logs = [] context.traces = traces context.tx_batch = TransactionBatch() ContextContainer._push_context(context) InternalCall._other_score_call = Mock() IconScoreContext.icx_engine = Mock(spec=IcxEngine) IconScoreContext.icon_score_deploy_engine = Mock( spec=IconScoreDeployEngine) context.icon_score_mapper = Mock() context.icon_score_mapper.get_icon_score = Mock( return_value=TestScore(db)) self._score = TestScore(db)
def setUp(self): address = Address.from_data(AddressPrefix.CONTRACT, os.urandom(20)) db = Mock(spec=IconScoreDatabase) db.attach_mock(address, 'address') context = IconScoreContext() traces = Mock(spec=list) step_counter = Mock(spec=IconScoreStepCounter) IconScoreContext.engine = ContextEngine(icx=Mock(IcxEngine), deploy=Mock(DeployEngine), fee=None, iiss=None, prep=None, issue=None) IconScoreContext.storage = ContextStorage(icx=Mock(IcxStorage), deploy=Mock(DeployStorage), fee=None, iiss=None, prep=None, issue=None, rc=None, meta=None) IconScoreContext.icx_engine = Mock(spec=IcxEngine) context.type = IconScoreContextType.INVOKE context.func_type = IconScoreFuncType.WRITABLE context.tx_batch = TransactionBatch() context.event_logs = [] context.traces = traces context.step_counter = step_counter context.get_owner = Mock() ContextContainer._push_context(context) self._mock_score = EventlogScore(db)
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 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()
def context(score_db): context = IconScoreContext() context.icon_score_deploy_engine = Mock() traces = Mock(spec=list) context.tx = Mock(spec=Transaction) context.block = Mock(spec=Block) context.cumulative_step_used = Mock(spec=int) context.cumulative_step_used.attach_mock(Mock(), '__add__') context.step_counter = Mock(spec=IconScoreStepCounter) context.event_logs = [] context.traces = traces context.tx_batch = TransactionBatch() IconScoreContext.engine = ContextEngine(icx=Mock(spec=IcxEngine), deploy=Mock(spec=DeployEngine)) IconScoreContext.storage = ContextStorage(deploy=Mock(spec=DeployStorage)) context.icon_score_mapper = Mock() return context
def setUp(self): address = Address.from_data(AddressPrefix.CONTRACT, b'address') db = Mock(spec=IconScoreDatabase) db.attach_mock(address, 'address') context = IconScoreContext() traces = Mock(spec=list) step_counter = Mock(spec=IconScoreStepCounter) context.type = IconScoreContextType.INVOKE context.func_type = IconScoreFuncType.WRITABLE context.tx_batch = TransactionBatch() context.event_logs = [] context.traces = traces context.step_counter = step_counter context.get_owner = Mock() context.internal_call.icx_engine = Mock(spec=IcxEngine) ContextContainer._push_context(context) self._mock_score = EventlogScore(db)