How to use require_that method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

TestRPC.py

Source:TestRPC.py Github

copy

Full Screen

...35 return payload36 def get_response(self, payload):37 response = requests.post(TESTRPC_URL, json=payload).json()38 lcc.log_debug(str(response))39 if require_that("json-rpc response", response, has_length(3)):40 require_that_in(response, "id", is_integer(), "jsonrpc", equal_to("2.0"))41 return response42 def transfer(self):43 payload = self.rpc_call(44 "personal_sendTransaction", [{45 "from": self.account_address,46 "to": self.new_account_address,47 "value": self.value48 }, ""]49 )50 trx_hash = self.get_response(payload)["result"]51 return trx_hash52 def create_contract(self):53 payload = self.rpc_call(54 "personal_sendTransaction", [{55 "from": self.account_address,56 "data": self.contract,57 }, ""]58 )59 trx_hash = self.get_response(payload)["result"]60 return trx_hash61 def validate_transaction(self, transaction):62 if require_that("transactions", transaction, has_length(14)):63 if not self.type_validator.is_SHA3_256(transaction["blockHash"]):64 lcc.log_error("Wrong format of 'blockHash', got: '{}'".format(transaction["blockHash"]))65 else:66 lcc.log_info("'blockHash' has correct format: eth_hash")67 if not self.type_validator.is_eth_hash(transaction["blockNumber"]):68 lcc.log_error("Wrong format of 'blockNumber', got: '{}'".format(transaction["blockNumber"]))69 else:70 lcc.log_info("'blockNumber' has correct format: eth_hash")71 if not self.type_validator.is_eth_hash(transaction["gas"]):72 lcc.log_error("Wrong format of 'gas', got: '{}'".format(transaction["gas"]))73 else:74 lcc.log_info("'gas' has correct format: eth_hash")75 if not self.type_validator.is_eth_hash(transaction["gasPrice"]):76 lcc.log_error("Wrong format of 'gasPrice', got: '{}'".format(transaction["gasPrice"]))77 else:78 lcc.log_info("'gasPrice' has correct format: eth_hash")79 if not self.type_validator.is_SHA3_256(transaction["hash"]):80 lcc.log_error("Wrong format of 'hash', got: '{}'".format(transaction["hash"]))81 else:82 lcc.log_info("'hash' has correct format: eth_hash")83 if not self.type_validator.is_eth_hash(transaction["nonce"]):84 lcc.log_error("Wrong format of 'nonce', got: '{}'".format(transaction["nonce"]))85 else:86 lcc.log_info("'nonce' has correct format: eth_hash")87 if not self.type_validator.is_eth_hash(transaction["to"]):88 lcc.log_error("Wrong format of 'to', got: '{}'".format(transaction["to"]))89 else:90 lcc.log_info("'to' has correct format: eth_hash")91 if not self.type_validator.is_eth_hash(transaction["transactionIndex"]):92 lcc.log_error("Wrong format of 'transactionIndex', got: '{}'".format(transaction["transactionIndex"]))93 else:94 lcc.log_info("'transactionIndex' has correct format: eth_hash")95 check_that("value", transaction["value"], equal_to(self.value))96 if not self.type_validator.is_eth_hash(transaction["v"]):97 lcc.log_error("Wrong format of 'v', got: '{}'".format(transaction["v"]))98 else:99 lcc.log_info("'v' has correct format: eth_hash")100 if not self.type_validator.is_eth_hash(transaction["r"]):101 lcc.log_error("Wrong format of 'r', got: '{}'".format(transaction["r"]))102 else:103 lcc.log_info("'r' has correct format: eth_hash")104 if not self.type_validator.is_eth_hash(transaction["s"]):105 lcc.log_error("Wrong format of 's', got: '{}'".format(transaction["s"]))106 else:107 lcc.log_info("'s' has correct format: eth_hash")108 def validate_block(self, result):109 if require_that("'result'", result, has_length(19)):110 if not self.type_validator.is_eth_hash(result["number"]):111 lcc.log_error("Wrong format of 'number', got: '{}'".format(result["number"]))112 else:113 lcc.log_info("'number' has correct format: hash")114 if not self.type_validator.is_eth_hash(result["hash"]):115 lcc.log_error("Wrong format of 'hash', got: '{}'".format(result["hash"]))116 else:117 lcc.log_info("'hash' has correct format: hash")118 if not self.type_validator.is_eth_hash(result["parentHash"]):119 lcc.log_error("Wrong format of 'parentHash', got: '{}'".format(result["parentHash"]))120 else:121 lcc.log_info("'parentHash' has correct format: hash")122 if not self.type_validator.is_eth_hash(result["nonce"]):123 lcc.log_error("Wrong format of 'nonce', got: '{}'".format(result["nonce"]))124 else:125 lcc.log_info("'nonce' has correct format: hash")126 if not self.type_validator.is_eth_hash(result["sha3Uncles"]):127 lcc.log_error("Wrong format of 'sha3Uncles', got: '{}'".format(result["sha3Uncles"]))128 else:129 lcc.log_info("'result' has correct format: hash")130 if not self.type_validator.is_eth_hash(result["logsBloom"]):131 lcc.log_error("Wrong format of 'logsBloom', got: '{}'".format(result["logsBloom"]))132 else:133 lcc.log_info("'result' has correct format: hash")134 if not self.type_validator.is_eth_hash(result["transactionsRoot"]):135 lcc.log_error("Wrong format of 'transactionsRoot', got: '{}'".format(result["transactionsRoot"]))136 else:137 lcc.log_info("'transactionsRoot' has correct format: hash")138 if not self.type_validator.is_eth_hash(result["stateRoot"]):139 lcc.log_error("Wrong format of 'stateRoot', got: '{}'".format(result["stateRoot"]))140 else:141 lcc.log_info("'stateRoot' has correct format: hash")142 if not self.type_validator.is_eth_hash(result["receiptsRoot"]):143 lcc.log_error("Wrong format of 'receiptsRoot', got: '{}'".format(result["receiptsRoot"]))144 else:145 lcc.log_info("'receiptsRoot' has correct format: hash")146 if not self.type_validator.is_eth_hash(result["miner"]):147 lcc.log_error("Wrong format of 'miner', got: '{}'".format(result["miner"]))148 else:149 lcc.log_info("'miner' has correct format: hash")150 if not self.type_validator.is_eth_hash(result["difficulty"]):151 lcc.log_error("Wrong format of 'difficulty', got: '{}'".format(result["difficulty"]))152 else:153 lcc.log_info("'difficulty' has correct format: hash")154 if not self.type_validator.is_eth_hash(result["totalDifficulty"]):155 lcc.log_error("Wrong format of 'totalDifficulty', got: '{}'".format(result["totalDifficulty"]))156 else:157 lcc.log_info("'totalDifficulty' has correct format: hash")158 if not self.type_validator.is_eth_hash(result["extraData"]):159 lcc.log_error("Wrong format of 'extraData', got: '{}'".format(result["extraData"]))160 else:161 lcc.log_info("'extraData' has correct format: hash")162 if not self.type_validator.is_eth_hash(result["size"]):163 lcc.log_error("Wrong format of 'size', got: '{}'".format(result["size"]))164 else:165 lcc.log_info("'size' has correct format: hash")166 if not self.type_validator.is_eth_hash(result["gasLimit"]):167 lcc.log_error("Wrong format of 'gasLimit', got: '{}'".format(result["gasLimit"]))168 else:169 lcc.log_info("'gasLimit' has correct format: hash")170 if not self.type_validator.is_eth_hash(result["gasUsed"]):171 lcc.log_error("Wrong format of 'gasUsed', got: '{}'".format(result["gasUsed"]))172 else:173 lcc.log_info("'gasUsed' has correct format: hash")174 if not self.type_validator.is_eth_hash(result["timestamp"]):175 lcc.log_error("Wrong format of 'timestamp', got: '{}'".format(result["timestamp"]))176 else:177 lcc.log_info("'timestamp' has correct format: hash")178 if check_that("uncles", result["uncles"], is_list()):179 if len(result["transactions"]) > 0:180 for transaction in result["transactions"]:181 self.validate_transaction(transaction)182 def setup_suite(self):183 self.passphrase = "Account"184 self.null_trx_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"185 self.account_address = "0x000000000000000000000000000000000000000a"186 self.contract_address = "0x0100000000000000000000000000000000000001"187 self.time = "0xffff"188 self.SHA3_trx_hash = "0x68656c6c6f20776f726c64"189 self.value = "0xffff"190 self.contract = self.get_byte_code("code_contract_Callee", "code")191 self.initial_account = "0x000000000000000000000000000000000000000b"192 self.invalid_hex_encoded_signature = \193 "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"194 def teardown_suite(self):195 pass196 @lcc.test("Check connection to ECHO test node")197 def main_check(self):198 message = {199 'code': -32600,200 'message': 'Missing or invalid method'201 }202 payload = self.rpc_call("", "")203 response = requests.post(TESTRPC_URL, json=payload).json()204 if require_that("json-rpc response", response, has_length(3)):205 require_that_in(response, "id", is_none(), "jsonrpc", equal_to("2.0"), "error", equal_to(message))206 @lcc.test("Check method 'miner_stop'")207 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")208 def miner_stop(self):209 payload = self.rpc_call("miner_stop", ["0x0"])210 response = self.get_response(payload)211 require_that("'result'", response["result"], is_none())212 @lcc.test("Check method 'miner_start'")213 @lcc.depends_on("TestRPC.TestRPC.TestRPC.miner_stop")214 def miner_start(self):215 payload = self.rpc_call("miner_start", ["0x0"])216 response = self.get_response(payload)217 require_that("'result'", response["result"], is_none())218 @lcc.test("Check method 'eth_mining'")219 @lcc.depends_on("TestRPC.TestRPC.TestRPC.miner_start")220 def eth_mining(self):221 payload = self.rpc_call("eth_mining", [])222 response = self.get_response(payload)223 require_that("'result'", response["result"], is_true())224 @lcc.test("Check method 'personal_newAccount'")225 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")226 def personal_new_account(self):227 payload = self.rpc_call("personal_newAccount", [self.passphrase])228 response = self.get_response(payload)229 if not self.type_validator.is_eth_address(response["result"]):230 lcc.log_error("Wrong format of 'result', got: {}".format(response["result"]))231 else:232 lcc.log_info("'result' has correct format: address")233 self.new_account_address = response["result"]234 return self.new_account_address235 @lcc.test("Check method 'personal_listAccounts'")236 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")237 def personal_list_accounts(self):238 payload = self.rpc_call("personal_listAccounts", [])239 results = self.get_response(payload)["result"]240 for result in results:241 if not self.type_validator.is_eth_address(result):242 lcc.log_error("Wrong format of 'result', got: {}".format(result))243 else:244 lcc.log_info("'result' has correct format: address")245 @lcc.test("Check method 'personal_listRawAccounts'")246 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")247 def personal_list_raw_accounts(self):248 payload = self.rpc_call("personal_listRawAccounts", [])249 results = self.get_response(payload)["result"]250 lcc.set_step("Check initialized accounts")251 for result in results[:2]:252 if not self.type_validator.is_eth_address(result["address"]):253 lcc.log_error("Wrong format of 'address', got: {}".format(result["address"]))254 else:255 lcc.log_info("'result' has correct format: address")256 if not self.type_validator.is_privkey(result["privkey"]):257 lcc.log_error("Wrong format of 'privkey', got: {}".format(result["privkey"]))258 else:259 lcc.log_info("'result' has correct format: privkey")260 check_that("passphrase", result["passphrase"], equal_to(""))261 lcc.set_step("Check created accounts")262 for result in results[2:]:263 if not self.type_validator.is_eth_address(result["address"]):264 lcc.log_error("Wrong format of 'address', got: {}".format(result["address"]))265 else:266 lcc.log_info("'result' has correct format: address")267 if not self.type_validator.is_privkey(result["privkey"]):268 lcc.log_error("Wrong format of 'privkey', got: {}".format(result["privkey"]))269 else:270 lcc.log_info("'result' has correct format: privkey")271 check_that("passphrase", result["passphrase"], equal_to(self.passphrase))272 @lcc.test("Check method 'eth_accounts'")273 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")274 def eth_accounts(self):275 payload = self.rpc_call("eth_accounts", [])276 results = self.get_response(payload)["result"]277 for account_address in results:278 if not self.type_validator.is_eth_address(account_address):279 lcc.log_error("Wrong format of 'address', got: {}".format(account_address))280 else:281 lcc.log_info("'result' has correct format: address")282 @lcc.test("Check method 'personal_lockAccount'")283 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")284 def personal_lock_account(self):285 payload = self.rpc_call("personal_lockAccount", [self.account_address])286 response = self.get_response(payload)287 require_that("'result'", response["result"], is_true())288 @lcc.test("Check method 'personal_unlockAccount'")289 @lcc.depends_on("TestRPC.TestRPC.TestRPC.personal_lock_account")290 def personal_unlock_account(self):291 payload = self.rpc_call("personal_unlockAccount", [self.account_address, self.passphrase, self.time])292 response = self.get_response(payload)293 require_that("'result'", response["result"], is_false())294 @lcc.test("Check method 'personal_sendTransaction'")295 @lcc.depends_on("TestRPC.TestRPC.TestRPC.personal_new_account")296 def personal_send_transaction(self):297 payload = self.rpc_call(298 "personal_sendTransaction", [{299 "from": self.account_address,300 "to": self.new_account_address,301 "value": self.value302 }, ""]303 )304 response = self.get_response(payload)305 if not self.type_validator.is_hex(response["result"]):306 lcc.log_error("Wrong format of 'result', got: '{}'".format(response["result"]))307 else:308 lcc.log_info("'result' has correct format: hex")309 @lcc.test("Check method 'eth_sign'")310 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")311 def eth_sign(self):312 payload = self.rpc_call("eth_sign", [self.initial_account, "0xdeadbaaf"])313 response = self.get_response(payload)314 require_that("'result'", response["result"], not_equal_to(self.invalid_hex_encoded_signature))315 if not self.type_validator.is_hex(response["result"]):316 lcc.log_error("Wrong format of 'result', got: '{}'".format(response["result"]))317 else:318 lcc.log_info("'result' has correct format: hex")319 @lcc.disabled()320 @lcc.test("Check method 'eth_sendTransaction'")321 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")322 def eth_send_transaction(self):323 payload = self.rpc_call(324 "eth_sendTransaction", [{325 "from": "0x0000000000000000000000000000000000000006",326 "to": "0x0000000000000000000000000000000000000007",327 "value": "0xfff"328 }]329 )330 response = self.get_response(payload)331 require_that("'result'", response["result"], not_equal_to(self.null_trx_hash))332 if not self.type_validator.is_hex(response["result"]):333 lcc.log_error("Wrong format of 'result', got: '{}'".format(response["result"]))334 else:335 lcc.log_info("'result' has correct format: hex")336 @lcc.test("Check method 'web3_clientVersion'")337 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")338 def web3_client_version(self):339 payload = self.rpc_call("web3_clientVersion", [])340 response = self.get_response(payload)341 client_version_parts = response["result"].split("/")342 require_that("'first part of web3 client version", client_version_parts[0], equal_to("ECHO"))343 echo_version_parts = client_version_parts[1].split(".")344 require_that("'version of echo splitted by dot have length", len(echo_version_parts), greater_than(2))345 require_that("'third part of web3 client version", client_version_parts[2], equal_to("Linux.64-bit"))346 @lcc.test("Check method 'web3_sha3'")347 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")348 def web3_sha3(self):349 payload = self.rpc_call("web3_sha3", [self.SHA3_trx_hash])350 response = self.get_response(payload)351 if not self.type_validator.is_SHA3_256(response["result"]):352 lcc.log_error("Wrong format of 'result', got: '{}'".format(response["result"]))353 else:354 lcc.log_info("'result' has correct format: hex")355 @lcc.test("Check method 'net_version'")356 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")357 def net_version(self):358 payload = self.rpc_call("net_version", [])359 response = self.get_response(payload)360 require_that("'result'", response["result"], equal_to("255"))361 @lcc.test("Check method 'net_listening'")362 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")363 def net_listening(self):364 payload = self.rpc_call("net_listening", [])365 response = self.get_response(payload)366 require_that("'result'", response["result"], is_true())367 @lcc.test("Check method 'net_peerCount'")368 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")369 def net_peer_count(self):370 payload = self.rpc_call("net_peerCount", [])371 response = self.get_response(payload)372 require_that("'result'", response["result"], equal_to("0x00"))373 @lcc.test("Check method 'eth_protocolVersion'")374 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")375 def eth_protocol_version(self):376 payload = self.rpc_call("eth_protocolVersion", [])377 response = self.get_response(payload)378 require_that("'result'", response["result"], equal_to("0x3f"))379 @lcc.test("Check method 'eth_syncing'")380 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")381 def eth_syncing(self):382 payload = self.rpc_call("eth_syncing", [])383 response = self.get_response(payload)384 require_that("'result'", response["result"], is_false())385 @lcc.test("Check method 'eth_coinbase'")386 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")387 def eth_coinbase(self):388 payload = self.rpc_call("eth_coinbase", [])389 response = self.get_response(payload)390 require_that("'result'", response["result"], equal_to(self.account_address))391 @lcc.test("Check method 'eth_gasPrice'")392 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")393 def eth_gas_price(self):394 payload = self.rpc_call("eth_gasPrice", [])395 response = self.get_response(payload)396 require_that("'result'", response["result"], equal_to("0x01"))397 @lcc.test("Check method 'eth_block_number'")398 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")399 def eth_block_number(self):400 payload = self.rpc_call("eth_blockNumber", [])401 response = self.get_response(payload)402 if not self.type_validator.is_eth_block_number(response["result"]):403 lcc.log_error("Wrong format of 'eth_blockNumber', got: '{}'".format(response["result"]))404 else:405 lcc.log_info("'result' has correct format: eth_blockNumber")406 @lcc.test("Check method 'eth_getBalance'")407 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")408 def eth_get_balance(self):409 payload = self.rpc_call("eth_getBalance", [self.account_address, "latest"])410 response = self.get_response(payload)411 if not self.type_validator.is_eth_balance(response["result"]):412 lcc.log_error("Wrong format of 'eth_balance', got: '{}'".format(response["result"]))413 else:414 lcc.log_info("'result' has correct format: eth_balance")415 @lcc.disabled()416 @lcc.test("Check method 'eth_getStorageAt'")417 @lcc.depends_on("TestRPC.TestRPC.TestRPC.personal_send_transaction")418 def eth_get_storage_at(self):419 self.create_contract()420 payload = self.rpc_call(421 "eth_getStorageAt",422 [self.contract_address, "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "latest"]423 )424 response = self.get_response(payload)425 require_that("'result'", response["result"], not_equal_to(self.null_trx_hash))426 @lcc.test("Check method 'eth_getTransactionCount'")427 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")428 def eth_get_transaction_count(self):429 payload = self.rpc_call("eth_getTransactionCount", [self.account_address, "latest"])430 response = self.get_response(payload)431 if not self.type_validator.is_eth_hash(response["result"]):432 lcc.log_error("Wrong format of 'count', got: '{}'".format(response["result"]))433 else:434 lcc.log_info("'count' has correct format: eth_hash")435 @lcc.test("Check method 'eth_getBlockTransactionCountByHash'")436 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")437 def eth_get_block_transaction_count_by_trx_hash(self):438 self.transfer()439 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))440 block_hash = self.get_response(self.rpc_call("eth_getBlockByNumber",441 [block_id["result"], True]))["result"]["hash"]442 payload = self.rpc_call("eth_getBlockTransactionCountByHash", [block_hash])443 response = self.get_response(payload)444 require_that("'result'", response["result"], equal_to("0x01"))445 @lcc.test("Check method 'eth_getCode'")446 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")447 def eth_get_code(self):448 self.create_contract()449 self.create_contract()450 payload = self.rpc_call("eth_getCode", [self.contract_address, "0x02"])451 response = self.get_response(payload)452 require_that("'result'", response["result"][2:], equal_to(self.contract[58:]))453 @lcc.disabled()454 @lcc.test("Check method 'eth_sendRawTransaction'")455 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")456 def eth_send_raw_transaction(self):457 trx_hash = self.create_contract()458 payload = self.rpc_call("eth_sendRawTransaction", [trx_hash])459 response = self.get_response(payload)460 require_that("'result'", response["result"], equal_to("0x01"))461 @lcc.test("Check method 'eth_call'")462 @lcc.depends_on("TestRPC.TestRPC.TestRPC.personal_new_account")463 def eth_call(self):464 self.create_contract()465 payload = self.rpc_call(466 "eth_call", [{467 "from": self.new_account_address,468 "to": "0x0100000000000000000000000000000000000000"469 }, "latest"]470 )471 response = self.get_response(payload)472 require_that("'result'", response["result"], equal_to("0x"))473 @lcc.test("Check method 'eth_estimateGas'")474 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")475 def eth_estimate_gas(self):476 payload = self.rpc_call("eth_estimateGas", [{477 "from": self.account_address,478 "data": self.contract,479 }])480 response = self.get_response(payload)481 if not self.type_validator.is_eth_balance(response["result"]):482 lcc.log_error("Wrong format of 'gas', got: '{}'".format(response["result"]))483 else:484 lcc.log_info("'result' has correct format: gas")485 @lcc.test("Check method 'eth_getBlockByHash'")486 @lcc.depends_on("TestRPC.TestRPC.TestRPC.eth_block_number")487 def eth_get_block_by_trx_hash(self):488 self.transfer()489 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))490 block_hash = self.get_response(self.rpc_call("eth_getBlockByNumber",491 [block_id["result"], True]))["result"]["hash"]492 payload = self.rpc_call("eth_getBlockByHash", [block_hash, True])493 result = self.get_response(payload)["result"]494 self.validate_block(result)495 @lcc.test("Check method 'eth_getBlockByNumber'")496 @lcc.depends_on("TestRPC.TestRPC.TestRPC.eth_block_number")497 def eth_get_block_by_number(self):498 self.transfer()499 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))500 payload = self.rpc_call("eth_getBlockByNumber", [block_id["result"], True])501 result = self.get_response(payload)["result"]502 self.validate_block(result)503 @lcc.test("Check method 'eth_getTransactionByHash'")504 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")505 def eth_get_transaction_by_hash(self):506 trx_hash = self.transfer()507 payload = self.rpc_call("eth_getTransactionByHash", [trx_hash])508 result = self.get_response(payload)["result"]509 self.validate_transaction(result)510 @lcc.test("Check method 'eth_getTransactionByBlockHashAndIndex'")511 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")512 def eth_get_transaction_by_hash_and_index(self):513 self.transfer()514 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))515 block_hash = self.get_response(self.rpc_call("eth_getBlockByNumber",516 [block_id["result"], True]))["result"]["hash"]517 payload = self.rpc_call("eth_getTransactionByBlockHashAndIndex", [block_hash, "0x00"])518 result = self.get_response(payload)["result"]519 self.validate_transaction(result)520 @lcc.test("Check method 'eth_getTransactionReceipt'")521 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")522 def eth_get_transaction_receipt(self):523 self.create_contract()524 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))525 trx_hash = self.get_response(self.rpc_call("eth_getBlockByNumber",526 [block_id["result"], True]))["result"]["transactions"][0]["hash"]527 payload = self.rpc_call("eth_getTransactionReceipt", [trx_hash])528 result = self.get_response(payload)["result"]529 if require_that("'result'", result, has_length(12)):530 if not self.type_validator.check_hash_by_bytes(result["transactionHash"], 32):531 lcc.log_error("Wrong format of 'transactionHash', got: '{}'".format(result["transactionHash"]))532 else:533 lcc.log_info("'transactionHash' has correct format: trx_hash")534 if not self.type_validator.is_eth_hash(result["transactionIndex"]):535 lcc.log_error("Wrong format of 'transactionIndex', got: '{}'".format(result["transactionIndex"]))536 else:537 lcc.log_info("'transactionIndex' has correct format: trx_hash")538 if not self.type_validator.is_eth_hash(result["transactionIndex"]):539 lcc.log_error("Wrong format of 'transactionIndex', got: '{}'".format(result["transactionIndex"]))540 else:541 lcc.log_info("'transactionIndex' has correct format: trx_hash")542 check_that('from', result["from"], equal_to(self.account_address))543 check_that('to', result["to"], is_none())544 if not self.type_validator.is_eth_hash(result["cumulativeGasUsed"]):545 lcc.log_error("Wrong format of 'cumulativeGasUsed', got: '{}'".format(result["cumulativeGasUsed"]))546 else:547 lcc.log_info("'cumulativeGasUsed' has correct format: trx_hash")548 if not self.type_validator.is_eth_hash(result["gasUsed"]):549 lcc.log_error("Wrong format of 'gasUsed', got: '{}'".format(result["gasUsed"]))550 else:551 lcc.log_info("'gasUsed' has correct format: trx_hash")552 check_that('logs', result["logs"], is_list())553 if not self.type_validator.is_digit(result["logsBloom"]):554 lcc.log_error("Wrong format of 'logsBloom', got: '{}'".format(result["logsBloom"]))555 else:556 lcc.log_info("'logsBloom' has correct format: trx_hash")557 check_that('status', result["status"], equal_to("0x01"))558 @lcc.test("Check method 'eth_pendingTransactions'")559 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")560 def eth_pending_transactions(self):561 self.create_contract()562 payload = self.rpc_call("eth_pendingTransactions", [])563 response = self.get_response(payload)564 require_that("'result'", response["result"], is_list())565 @lcc.test("Check method 'echo_requestRegistrationTask'")566 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")567 def echo_request_registration_task(self):568 payload = self.rpc_call("echo_requestRegistrationTask", [])569 response = self.get_response(payload)["result"]570 if not self.type_validator.is_eth_hash(response["blockId"]):571 lcc.log_error("Wrong format of 'blockId', got: '{}'".format(response["blockId"]))572 else:573 lcc.log_info("'blockId' has correct format: eth_hash")574 if not self.type_validator.is_eth_hash(response["randNum"]):575 lcc.log_error("Wrong format of 'randNum', got: '{}'".format(response["randNum"]))576 else:577 lcc.log_info("'randNum' has correct format: eth_hash")578 if not self.type_validator.is_eth_hash(response["difficulty"]):579 lcc.log_error("Wrong format of 'difficulty', got: '{}'".format(response["difficulty"]))580 else:581 lcc.log_info("'difficulty' has correct format: eth_hash")582 @lcc.test("Check method 'echo_submitRegistrationSolution'")583 @lcc.depends_on("TestRPC.TestRPC.TestRPC.echo_request_registration_task")584 def echo_submit_registration_solution(self, get_random_valid_account_name):585 payload = self.rpc_call("echo_requestRegistrationTask", [])586 response = self.get_response(payload)["result"]587 block_id_right160 = response["blockId"][26:]588 rand_num_decimal = int(response["randNum"].lstrip("0x"), 16)589 difficulty = int(response["difficulty"].lstrip("0x"), 16)590 nonce = self.echo.solve_registration_task(block_id_right160, rand_num_decimal, difficulty)591 nonce_hex = hex(nonce)592 account_name = get_random_valid_account_name593 evm_address = None594 active_key = echorand_key = "ECHOHCcqrvESxeg4Kmmpr73FdQSQR6TbusCMsHeuXvx2rM1G"595 rand_num = response["randNum"]596 payload = self.rpc_call(597 "echo_submitRegistrationSolution",598 [account_name, active_key, echorand_key, evm_address, nonce_hex, rand_num]599 )600 response = self.get_response(payload)601 if not self.type_validator.is_eth_hash(response["result"]):602 lcc.log_error("Wrong format of 'difficulty', got: '{}'".format(response["difficulty"]))603 else:604 lcc.log_info("'difficulty' has correct format: eth_hash")605 @lcc.test("Check method 'evm_increaseTime'")606 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")607 def evm_increase_time(self):608 payload = self.rpc_call("evm_increaseTime", [60])609 response = self.get_response(payload)["result"]610 if not self.type_validator.is_eth_hash(response):611 lcc.log_error("Wrong format of 'increaseTime', got: '{}'".format(response))612 else:613 lcc.log_info("'increaseTime' has correct format: eth_hash")614 @lcc.test("Check method 'evm_mine'")615 @lcc.depends_on("TestRPC.TestRPC.TestRPC.main_check")616 def evm_mine(self):617 lcc.log_info("Get block number before method ''evm_mine")618 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))619 block_number_before = self.get_response(self.rpc_call("eth_getBlockByNumber",620 [block_id["result"], True]))["result"]["number"]621 lcc.log_info("Call method 'evm_mine'")622 payload = self.rpc_call("evm_mine", [])623 result = self.get_response(payload)["result"]624 require_that('result', result, is_none())625 lcc.log_info("Get block number after method ''evm_mine")626 block_id = self.get_response(self.rpc_call("eth_blockNumber", []))627 block_number_after = self.get_response(self.rpc_call("eth_getBlockByNumber",628 [block_id["result"], True]))["result"]["number"]629 lcc.log_info("Block number {}".format(block_number_after))...

Full Screen

Full Screen

ERC20.py

Source:ERC20.py Github

copy

Full Screen

...84 lcc.log_info("ERC20 contract created in Ethereum network, address: '{}'".format(self.erc20_contract.address))85 lcc.set_step("Get ethereum account ERC20 tokens balance in the Ethereum network")86 self.in_ethereum_erc20_balance = self.eth_trx.get_balance_of(self.erc20_contract, self.eth_account.address)87 self.in_ethereum_start_erc20_balance = self.in_ethereum_erc20_balance88 require_that("'in ethereum owner's erc20 balance'", self.in_ethereum_erc20_balance, greater_than(0))89 lcc.set_step("Perform register erc20 token operation")90 bd_result = \91 self.utils.perform_sidechain_erc20_register_token_operation(self, account=self.new_account,92 eth_addr=self.erc20_contract.address,93 name=name, symbol=symbol,94 database_api_id=self.__database_api_identifier)95 self.erc20_token_id = self.get_contract_result(bd_result, self.__database_api_identifier)96 lcc.log_info(97 "Registration of ERC20 token completed successfully, ERC20 token object is '{}'".format(98 self.erc20_token_id99 )100 )101 lcc.set_step("Get created ERC20 token and store contract id in the ECHO network")102 response_id = self.send_request(103 self.get_request("get_erc20_token", [self.erc20_contract.address[2:]]), self.__database_api_identifier104 )105 self.erc20_contract_id = self.get_response(response_id)["result"]["contract"]106 lcc.log_info("ERC20 token has id '{}' and contract_id '{}'".format(self.erc20_token_id, self.erc20_contract_id))107 @lcc.test("The scenario entering erc20 tokens to the echo account")108 @lcc.depends_on("API.SideChain.ERC20.ERC20.erc20_sidechain_pre_run_scenario")109 def erc20_in_scenario(self):110 erc20_deposit_amounts = []111 lcc.set_step("First transfer erc20 to ethereum address of created account")112 erc20_deposit_amounts.append(self.get_random_amount(_to=self.in_ethereum_erc20_balance))113 self.eth_trx.transfer(self.web3, self.erc20_contract, self.eth_account_address, erc20_deposit_amounts[0])114 lcc.log_info(115 "Transfer '{}' erc20 tokens to '{}' account completed successfully".format(116 erc20_deposit_amounts[0], self.eth_account_address117 )118 )119 lcc.set_step("First: Get ERC20 account deposits")120 deposits = \121 self.utils.get_erc20_account_deposits(self, self.new_account, self.__database_api_identifier)["result"]122 require_that("'account deposits'", deposits, has_length(len(erc20_deposit_amounts)))123 for i, deposit in enumerate(deposits):124 deposit_value = deposit["value"]125 require_that(126 "'account deposit value #'{}''".format(i), deposit_value, equal_to(str(erc20_deposit_amounts[i]))127 )128 lcc.set_step("Get ERC20 token balance of account in the ECHO network and check result")129 in_echo_erc20_balance = \130 self.utils.get_erc20_token_balance_in_echo(self, account_id=self.new_account,131 balance_of_method=self.erc20_balanceOf,132 contract_id=self.erc20_contract_id,133 database_api_id=self.__database_api_identifier)134 require_that("'in echo account's erc20 balance'", in_echo_erc20_balance, equal_to(erc20_deposit_amounts[0]))135 lcc.set_step("Get updated ethereum account ERC20 tokens balance in the Ethereum network")136 updated_in_ethereum_erc20_balance = self.eth_trx.get_balance_of(self.erc20_contract, self.eth_account.address)137 require_that(138 "'in ethereum owner's erc20 balance'", updated_in_ethereum_erc20_balance,139 equal_to(self.in_ethereum_erc20_balance - erc20_deposit_amounts[0])140 )141 lcc.set_step("Second transfer erc20 to ethereum address of created account")142 erc20_deposit_amounts.append(self.get_random_amount(_to=updated_in_ethereum_erc20_balance))143 self.eth_trx.transfer(self.web3, self.erc20_contract, self.eth_account_address, erc20_deposit_amounts[1])144 lcc.log_info(145 "Transfer '{}' erc20 tokens to '{}' account completed successfully".format(146 erc20_deposit_amounts[1], self.eth_account_address147 )148 )149 lcc.set_step("Second: Get ERC20 account deposits")150 import time151 time.sleep(3)152 deposits = self.utils.get_erc20_account_deposits(153 self, self.new_account, self.__database_api_identifier, previous_account_deposits=deposits154 )["result"]155 require_that("'account deposits'", deposits, has_length(len(erc20_deposit_amounts)))156 for i, deposit in enumerate(deposits):157 deposit_value = deposit["value"]158 require_that(159 "'account deposit value #'{}''".format(i), deposit_value, equal_to(str(erc20_deposit_amounts[i]))160 )161 lcc.set_step("Get ERC20 token balance of account in the ECHO network and check result")162 in_echo_erc20_balance = \163 self.utils.get_erc20_token_balance_in_echo(self, account_id=self.new_account,164 balance_of_method=self.erc20_balanceOf,165 contract_id=self.erc20_contract_id,166 database_api_id=self.__database_api_identifier)167 require_that(168 "'in echo account's erc20 balance'", in_echo_erc20_balance,169 equal_to(erc20_deposit_amounts[0] + erc20_deposit_amounts[1])170 )171 lcc.set_step("Get final ethereum account ERC20 tokens balance in the Ethereum network")172 final_in_ethereum_erc20_balance = self.eth_trx.get_balance_of(self.erc20_contract, self.eth_account.address)173 require_that(174 "'in ethereum owner'serc20 balance'", final_in_ethereum_erc20_balance,175 equal_to(updated_in_ethereum_erc20_balance - erc20_deposit_amounts[1])176 )177 self.in_echo_erc20_balance = in_echo_erc20_balance178 self.in_ethereum_erc20_balance = final_in_ethereum_erc20_balance179 lcc.set_step("Get ERC20 tokens of 'sidechain_erc20_issue_operation'")180 operation_id = self.echo.config.operation_ids.SIDECHAIN_ERC20_ISSUE181 operation_history_obj = "{}0".format(self.get_object_type(self.echo.config.object_types.OPERATION_HISTORY))182 stop, start = operation_history_obj, operation_history_obj183 limit = 100184 params = [self.new_account, operation_id, start, stop, limit]185 response_id = self.send_request(186 self.get_request("get_account_history_operations", params), self.__history_api_identifier187 )188 history_operations = self.get_response(response_id)["result"]189 lcc.log_info(190 "Call method 'get_account_history' with: account='{}', operation_id='{}', stop='{}', limit='{}', "191 "start='{}' parameters".format(self.new_account, operation_id, stop, limit, start)192 )193 lcc.set_step("Check ERC20 tokens of 'sidechain_erc20_issue_operation'")194 deposits.reverse()195 for i, history_operation in enumerate(history_operations):196 sidechain_erc20_issue_operation = history_operation["op"]197 if check_that("'sidechain_erc20_issue_operation'", sidechain_erc20_issue_operation[1], has_length(5)):198 check_that_in(199 sidechain_erc20_issue_operation[1],200 "deposit",201 is_(deposits[i]["id"]),202 "account",203 is_(deposits[i]["account"]),204 "amount",205 is_(deposits[i]["value"]),206 "extensions",207 is_list(),208 quite=True209 )210 if not self.type_validator.is_erc20_object_id(sidechain_erc20_issue_operation[1]["token"]):211 lcc.log_error(212 "Wrong format of 'token', got: {}".format(sidechain_erc20_issue_operation[1]["token"])213 )214 else:215 lcc.log_info("'operation_id' has correct format: erc20_token_object_type")216 @lcc.test("The scenario withdrawing erc20 tokens from the echo account")217 @lcc.depends_on("API.SideChain.ERC20.ERC20.erc20_in_scenario")218 def erc20_out_scenario(self):219 erc20_withdraw_amounts = []220 withdraw_erc20_token_ids = []221 lcc.set_step("Get ERC20 balance in the ECHO network")222 if self.in_echo_erc20_balance <= 0:223 raise Exception("No ERC20 balance to withdraw")224 lcc.log_info("ERC20 balance in ECHO network: '{}'".format(self.in_echo_erc20_balance))225 lcc.log_info("ERC20 balance in Ethereum network: '{}'".format(self.in_ethereum_erc20_balance))226 lcc.set_step("Perform first withdraw ERC20 token operation")227 erc20_withdraw_amounts.append(str(self.get_random_amount(_to=self.in_echo_erc20_balance)))228 bd_result = \229 self.utils.perform_sidechain_erc20_withdraw_token_operation(self, account=self.new_account,230 to=self.eth_account.address,231 erc20_token=self.erc20_token_id,232 value=erc20_withdraw_amounts[0],233 database_api_id=self.__database_api_identifier)234 withdraw_erc20_token_ids.append(self.get_operation_results_ids(bd_result))235 lcc.log_info(236 "Withdraw ERC20 token completed successfully, Withdraw ERC20 token object is '{}'".format(237 withdraw_erc20_token_ids[0]238 )239 )240 lcc.set_step("Get ERC20 account withdrawals")241 withdrawals = \242 self.utils.get_erc20_account_withdrawals(self, self.new_account, self.__database_api_identifier)["result"]243 require_that("'account withdrawals'", withdrawals, has_length(len(erc20_withdraw_amounts)))244 for i, withdraw in enumerate(withdrawals):245 lcc.log_info("Check account withdraw #'{}'".format(i))246 check_that_in(247 withdraw, "id", equal_to(withdraw_erc20_token_ids[i]), "value",248 equal_to(str(erc20_withdraw_amounts[i]))249 )250 lcc.set_step("Get ERC20 token balance of account in the ECHO network and check result")251 in_echo_erc20_balance = \252 self.utils.get_erc20_token_balance_in_echo(self, account_id=self.new_account,253 balance_of_method=self.erc20_balanceOf,254 contract_id=self.erc20_contract_id,255 database_api_id=self.__database_api_identifier)256 require_that(257 "'in echo account's erc20 balance'", in_echo_erc20_balance,258 equal_to(self.in_echo_erc20_balance - int(erc20_withdraw_amounts[0]))259 )260 lcc.set_step("Get updated ethereum account ERC20 tokens balance in the Ethereum network")261 updated_in_ethereum_erc20_balance = \262 self.utils.get_updated_account_erc20_balance_in_eth_network(self, self.erc20_contract,263 self.eth_account.address,264 self.in_ethereum_erc20_balance,265 self.__database_api_identifier)266 require_that(267 "'in ethereum owner'serc20 balance'", updated_in_ethereum_erc20_balance,268 equal_to(self.in_ethereum_erc20_balance + int(erc20_withdraw_amounts[0]))269 )270 lcc.set_step("Perform second withdraw ERC20 token operation to withdraw all ERC20 balance")271 erc20_withdraw_amounts.append(str(in_echo_erc20_balance))272 bd_result = \273 self.utils.perform_sidechain_erc20_withdraw_token_operation(self, account=self.new_account,274 to=self.eth_account.address,275 erc20_token=self.erc20_token_id,276 value=erc20_withdraw_amounts[1],277 database_api_id=self.__database_api_identifier)278 withdraw_erc20_token_ids.append(self.get_operation_results_ids(bd_result))279 lcc.log_info(280 "Withdraw ERC20 token completed successfully, Withdraw ERC20 token object is '{}'".format(281 withdraw_erc20_token_ids[1]282 )283 )284 lcc.set_step("Get ERC20 account withdrawals")285 withdrawals = \286 self.utils.get_erc20_account_withdrawals(self, self.new_account, self.__database_api_identifier)["result"]287 require_that("'account withdrawals'", withdrawals, has_length(len(erc20_withdraw_amounts)))288 for i, withdraw in enumerate(withdrawals):289 lcc.log_info("Check account withdraw #'{}'".format(i))290 check_that_in(291 withdraw, "id", equal_to(withdraw_erc20_token_ids[i]), "value",292 equal_to(str(erc20_withdraw_amounts[i]))293 )294 lcc.set_step("Get ERC20 token balance of account in the ECHO network and check result")295 updated_in_echo_erc20_balance = \296 self.utils.get_erc20_token_balance_in_echo(self, account_id=self.new_account,297 balance_of_method=self.erc20_balanceOf,298 contract_id=self.erc20_contract_id,299 database_api_id=self.__database_api_identifier)300 require_that(301 "'in echo account's erc20 balance'", updated_in_echo_erc20_balance,302 equal_to(in_echo_erc20_balance - int(erc20_withdraw_amounts[1]))303 )304 lcc.set_step("Get final ethereum account ERC20 tokens balance in the Ethereum network")305 final_in_ethereum_erc20_balance = \306 self.utils.get_updated_account_erc20_balance_in_eth_network(self, self.erc20_contract,307 self.eth_account.address,308 self.in_ethereum_erc20_balance,309 self.__database_api_identifier)310 require_that(311 "'in ethereum owner'serc20 balance'", final_in_ethereum_erc20_balance,312 equal_to(updated_in_ethereum_erc20_balance + int(erc20_withdraw_amounts[1]))313 )314 require_that(315 "'final balance equal to start balance'",316 final_in_ethereum_erc20_balance == self.in_ethereum_start_erc20_balance, is_true()317 )318 lcc.set_step("Get ERC20 burn token")319 operation_id = self.echo.config.operation_ids.SIDECHAIN_ERC20_BURN320 operation_history_obj = "{}0".format(self.get_object_type(self.echo.config.object_types.OPERATION_HISTORY))321 stop, start = operation_history_obj, operation_history_obj322 limit = 100323 params = [self.new_account, operation_id, start, stop, limit]324 response_id = self.send_request(325 self.get_request("get_account_history_operations", params), self.__history_api_identifier326 )327 history_operations = self.get_response(response_id)["result"]328 lcc.log_info(...

Full Screen

Full Screen

selection.py

Source:selection.py Github

copy

Full Screen

...161 the :py:func:`lemoncheesecake.matching.require_that` function.162 :param expected: a ``Matcher`` instance whose ``matches`` method will be called with163 the ``WebElement`` that has been found164 """165 require_that(str(self), self, HasElement(expected))166 def require_no_element(self):167 """168 Check that the element is not present using169 the :py:func:`lemoncheesecake.matching.require_that` function.170 """171 require_that(str(self), self, not_(HasElement(is_in_page())))172 def assert_element(self, expected: Matcher):173 """174 Check that the element matches ``expected`` using175 the :py:func:`lemoncheesecake.matching.assert_that` function.176 :param expected: a ``Matcher`` instance whose ``matches`` method will be called with177 the ``WebElement`` that has been found178 """179 assert_that(str(self), self, HasElement(expected))180 def assert_no_element(self):181 """182 Check that the element is not present using183 the :py:func:`lemoncheesecake.matching.assert_that` function.184 """185 assert_that(str(self), self, not_(HasElement(is_in_page())))...

Full Screen

Full Screen

Config.py

Source:Config.py Github

copy

Full Screen

...35 }36 return payload37 def get_response(self, payload):38 response = requests.post(ETHRPC_URL, json=payload).json()39 if require_that("eth-rpc response", response, has_length(3)):40 require_that_in(response, "id", is_integer(), "jsonrpc", equal_to("2.0"))41 return response42 def create_contract(self):43 payload = self.rpc_call(44 "personal_sendTransaction", [{45 "from": self.account_address,46 "data": self.contract,47 }, ""]48 )49 trx_hash = self.get_response(payload)["result"]50 return trx_hash51 def setup_suite(self):52 self.passphrase = "Account"53 self.null_trx_hash = "0x0000000000000000000000000000000000000000000000000000000000000000"54 self.account_address = "0x0000000000000000000000000000000000000006"55 self.new_account_address = "0x0000000000000000000000000000000000000007"56 self.contract_address = "0x0100000000000000000000000000000000000001"57 self.time = "0xffff"58 self.SHA3_trx_hash = "0x68656c6c6f20776f726c64"59 self.value = "0xffff"60 self.contract = self.get_byte_code("piggy", "code")61 def teardown_suite(self):62 pass63 @lcc.test("Check connection to EthPRC interface")64 def main_check(self):65 message = {66 'code': -32600,67 'message': 'Missing or invalid method'68 }69 payload = self.rpc_call("", "")70 response = requests.post(ETHRPC_URL, json=payload).json()71 if require_that("json-rpc response", response, has_length(3)):72 require_that_in(response, "id", is_none(), "jsonrpc", equal_to("2.0"), "error", equal_to(message))73 @lcc.test("Check method 'web3_clientVersion'")74 @lcc.depends_on("EthRPC.Config.Config.main_check")75 def web3_client_version(self):76 payload = self.rpc_call("web3_clientVersion", [])77 response = self.get_response(payload)78 client_version_parts = response["result"].split("/")79 require_that("'first part of web3 client version", client_version_parts[0], equal_to("ECHO"))80 echo_version_parts = client_version_parts[1].split(".")81 require_that("'version of echo splitted by dot have length", len(echo_version_parts), greater_than(2))82 require_that("'third part of web3 client version", client_version_parts[2], equal_to("Linux.64-bit"))83 @lcc.test("Check method 'eth_chain_id'")84 @lcc.depends_on("EthRPC.Config.Config.main_check")85 def eth_chain_id(self):86 chain_id = "0xff"87 payload = self.rpc_call("eth_chainId", [])88 response = self.get_response(payload)89 require_that("'result'", response["result"], equal_to(chain_id))90 @lcc.test("Check method 'web3_sha3'")91 @lcc.depends_on("EthRPC.Config.Config.main_check")92 def web3_sha3(self):93 payload = self.rpc_call("web3_sha3", [self.SHA3_trx_hash])94 response = self.get_response(payload)95 if not self.type_validator.is_SHA3_256(response["result"]):96 lcc.log_error("Wrong format of 'result', got: '{}'".format(response["result"]))97 else:98 lcc.log_info("'result' has correct format: hex")99 @lcc.test("Check method 'net_version'")100 @lcc.depends_on("EthRPC.Config.Config.main_check")101 def net_version(self):102 payload = self.rpc_call("net_version", [])103 response = self.get_response(payload)104 require_that("'result'", response["result"], equal_to("255"))105 @lcc.test("Check method 'net_listening'")106 @lcc.depends_on("EthRPC.Config.Config.main_check")107 def net_listening(self):108 payload = self.rpc_call("net_listening", [])109 response = self.get_response(payload)110 require_that("'result'", response["result"], is_true())111 @lcc.test("Check method 'net_peerCount'")112 @lcc.depends_on("EthRPC.Config.Config.main_check")113 def net_peer_count(self):114 payload = self.rpc_call("net_peerCount", [])115 response = self.get_response(payload)116 require_that("'result'", response["result"], equal_to("0x00"))117 @lcc.test("Check method 'eth_protocolVersion'")118 @lcc.depends_on("EthRPC.Config.Config.main_check")119 def eth_protocol_version(self):120 payload = self.rpc_call("eth_protocolVersion", [])121 response = self.get_response(payload)122 require_that("'result'", response["result"], equal_to("0x3f"))123 @lcc.test("Check method 'eth_syncing'")124 @lcc.depends_on("EthRPC.Config.Config.main_check")125 def eth_syncing(self):126 payload = self.rpc_call("eth_syncing", [])127 response = self.get_response(payload)128 require_that("'result'", response["result"], is_false())129 @lcc.test("Check method 'eth_coinbase'")130 @lcc.depends_on("EthRPC.Config.Config.main_check")131 def eth_coinbase(self):132 payload = self.rpc_call("eth_coinbase", [])133 response = self.get_response(payload)134 require_that("'result'", response["result"], equal_to(self.account_address))135 @lcc.test("Check method 'eth_gasPrice'")136 @lcc.depends_on("EthRPC.Config.Config.main_check")137 def eth_gas_price(self):138 payload = self.rpc_call("eth_gasPrice", [])139 response = self.get_response(payload)140 require_that("'result'", response["result"], equal_to("0x01"))141 @lcc.test("Check method 'eth_block_number'")142 @lcc.depends_on("EthRPC.Config.Config.main_check")143 def eth_block_number(self):144 payload = self.rpc_call("eth_blockNumber", [])145 response = self.get_response(payload)146 echo = Echo()147 echo.connect(BASE_URL)148 head_block_number = echo.api.database.get_dynamic_global_properties()["head_block_number"]149 check_that('block_number', int(response["result"], 16), equal_to(head_block_number))150 @lcc.disabled()151 @lcc.test("Check method 'eth_getStorageAt'")152 @lcc.depends_on("EthRPC.Config.Config.main_check")153 def eth_get_storage_at(self):154 self.create_contract()155 payload = self.rpc_call(156 "eth_getStorageAt",157 [self.contract_address, "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "latest"]158 )159 response = self.get_response(payload)160 require_that("'result'", response["result"], not_equal_to(self.null_trx_hash))161 @lcc.test("Check method 'eth_estimateGas'")162 @lcc.depends_on("EthRPC.Config.Config.main_check")163 def eth_estimate_gas(self):164 payload = self.rpc_call("eth_estimateGas", [{165 "from": self.account_address,166 "data": self.contract,167 }])168 response = self.get_response(payload)169 if not self.type_validator.is_eth_balance(response["result"]):170 lcc.log_error("Wrong format of 'gas', got: '{}'".format(response["result"]))171 else:172 lcc.log_info("'result' has correct format: gas")173 @lcc.test("Check method 'eth_pendingTransactions'")174 @lcc.depends_on("EthRPC.Config.Config.main_check")175 def eth_pending_transactions(self):176 payload = self.rpc_call("eth_pendingTransactions", [])177 response = self.get_response(payload)178 require_that("'result'", response["result"], is_list())179 @lcc.test("Check method 'echo_requestRegistrationTask'")180 @lcc.depends_on("EthRPC.Config.Config.main_check")181 def echo_request_registration_task(self):182 payload = self.rpc_call("echo_requestRegistrationTask", [])183 response = self.get_response(payload)["result"]184 if not self.type_validator.is_eth_hash(response["blockId"]):185 lcc.log_error("Wrong format of 'blockId', got: '{}'".format(response["blockId"]))186 else:187 lcc.log_info("'blockId' has correct format: eth_hash")188 if not self.type_validator.is_eth_hash(response["randNum"]):189 lcc.log_error("Wrong format of 'randNum', got: '{}'".format(response["randNum"]))190 else:191 lcc.log_info("'randNum' has correct format: eth_hash")192 if not self.type_validator.is_eth_hash(response["difficulty"]):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful