def test_send_call_wrong_address(self, _make_id):
        wrong_address = "hx5bfdb090f43a808005ffc27c25b213145e8"
        call_transaction_without_step_limit = CallTransactionBuilder() \
            .from_(self.setting["from"]) \
            .to(wrong_address) \
            .nid(self.setting["nid"]) \
            .step_limit(self.setting["step_limit"]) \
            .nonce(self.setting["nonce"]) \
            .method(self.setting["method"]) \
            .params(self.setting["params_call"]) \
            .build()
        signed_transaction = SignedTransaction(
            call_transaction_without_step_limit, self.wallet)

        with requests_mock.Mocker() as m:
            response_json = {
                'jsonrpc': '2.0',
                'id': 1234,
                'error': {
                    'code': -32601,
                    'message': 'Method not found'
                }
            }

            m.post(self.matcher, json=response_json)
            result_dict = self.icon_service.send_transaction(
                signed_transaction, full_response=True)
            self.assertEqual(result_error_v3.keys(), result_dict.keys())
Пример #2
0
    def test_deploy_wrong_address(self, _make_id):
        wrong_address = "hx5bfdb090f43a808005ffc27c25b213145e8"
        deploy_transaction = DeployTransactionBuilder() \
            .from_(self.setting["from"]) \
            .to(wrong_address) \
            .step_limit(self.setting["step_limit"]) \
            .nid(self.setting["nid"]) \
            .nonce(self.setting["nonce"]) \
            .content_type(self.setting["content_type"]) \
            .content(self.setting["content_install"]) \
            .params(self.setting["params_install"]) \
            .build()
        signed_transaction = SignedTransaction(deploy_transaction, self.wallet)

        with requests_mock.Mocker() as m:
            response_json = {
                'jsonrpc': '2.0',
                'id': 1234,
                'error': {
                    "code": -32600,
                    "message": f'Not a system SCORE {wrong_address}'
                }
            }

            m.post(self.matcher, json=response_json, status_code=400)
            result_dict = self.icon_service.send_transaction(
                signed_transaction, full_response=True)
            self.assertEqual(result_error_v3.keys(), result_dict.keys())
    def test_get_transaction_wrong_hash(self, _make_id):
        with requests_mock.Mocker() as m:
            wrong_tx_hash = "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"
            response_json = {
                "jsonrpc": "2.0",
                "error": {
                    "code": -32602,
                    "message": "Invalid params txHash"
                },
                "id": 1234
            }

            m.post(self.matcher, json=response_json, status_code=400)
            result_dict = self.icon_service.get_block(wrong_tx_hash, full_response=True)
            self.assertEqual(result_dict.keys(), result_error_v3.keys())
    def test_get_score_api_by_wrong_address(self, _make_id):
        with requests_mock.Mocker() as m:
            wrong_address = "cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32"

            response_json: dict = {
                "jsonrpc": "2.0",
                "error": {
                    "code": -32002,
                    "message": f"SCORE not found: {wrong_address}"
                },
                "id": 1234
            }
            m.post(self.matcher, json=response_json, status_code=400)
            result_dict = self.icon_service.get_score_api(wrong_address,
                                                          full_response=True)
            self.assertEqual(result_dict.keys(), result_error_v3.keys())
    def test_get_block_by_wrong_hash(self, _make_id):
        # used invalid hash and got and invalid block

        invalid_block_hash = "0x033f8d96045eb8301fd17cf078c28ae58a3ba329f6ada5cf128ee56dc2af26f7"
        with requests_mock.Mocker() as m:
            response_json = {
                'jsonrpc': '2.0',
                'error': {
                    "code": -32602,
                    "message": "fail wrong block hash"
                },
                'id': 1234
            }

            m.post(self.matcher, json=response_json, status_code=400)
            result_dict = self.icon_service.get_block(invalid_block_hash,
                                                      full_response=True)
            self.assertEqual(result_dict.keys(), result_error_v3.keys())
Пример #6
0
    def test_get_block_by_wrong_height(self, _make_id):
        # used invalid hash and got and invalid block

        invalid_block_height = 5
        with requests_mock.Mocker() as m:
            response_json = {
                "jsonrpc": "2.0",
                "error": {
                    "code": -32602,
                    "message": "fail wrong block height"
                },
                "id": 1234
            }

            m.post(self.matcher, json=response_json, status_code=400)
            result_dict = self.icon_service.get_block(invalid_block_height,
                                                      full_response=True)
            self.assertEqual(result_dict.keys(), result_error_v3.keys())