chainlib-eth

Ethereum implementation of the chainlib interface
Log | Files | Refs | README | LICENSE

commit 5cfb6a7dda1cbcf9fa92268674afd7d9ec1dcc35
parent 700c52089ee669cf17348dc32c4163ad270fd650
Author: nolash <dev@holbrook.no>
Date:   Mon, 18 Oct 2021 14:04:49 +0200

Rehabilitate tests

Diffstat:
Mrequirements.txt | 2+-
Mtests/test_address.py | 2+-
Mtests/test_sign.py | 15++++++++++-----
Mtests/test_tx.py | 9++++++---
4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/requirements.txt b/requirements.txt @@ -3,5 +3,5 @@ pysha3==1.0.2 hexathon~=0.0.1a8 websocket-client==0.57.0 potaahto~=0.0.1a1 -chainlib==0.0.9rc1 +chainlib==0.0.10a2 confini>=0.4.1a1,<0.5.0 diff --git a/tests/test_address.py b/tests/test_address.py @@ -12,7 +12,7 @@ from tests.base import TestBase class TestChain(TestBase): def test_chain_spec(self): - checksum_address = '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C' + checksum_address = 'Eb3907eCad74a0013c259D5874AE7f22DcBcC95C' plain_address = checksum_address.lower() self.assertEqual(checksum_address, to_checksum(checksum_address)) diff --git a/tests/test_sign.py b/tests/test_sign.py @@ -16,7 +16,10 @@ import chainlib from chainlib.eth.connection import EthUnixSignerConnection from chainlib.eth.sign import sign_transaction from chainlib.eth.tx import TxFactory -from chainlib.eth.address import to_checksum_address +from chainlib.eth.address import ( + to_checksum_address, + is_same_address, + ) from chainlib.jsonrpc import ( jsonrpc_response, jsonrpc_error, @@ -52,11 +55,13 @@ class Mocket(socket.socket): logg.debug('mocket received {}'.format(v)) Mocket.req_id = o['id'] params = o['params'][0] - if to_checksum_address(params.get('from')) != alice: - logg.error('from does not match alice {}'.format(params)) + from_address = to_checksum_address(params.get('from')) + if not is_same_address(alice, from_address): + logg.error('from {} does not match alice {}'.format(from_address, alice)) #params)) Mocket.error = True - if to_checksum_address(params.get('to')) != bob: - logg.error('to does not match bob {}'.format(params)) + to_address = to_checksum_address(params.get('to')) + if not is_same_address(bob, to_address): + logg.error('to {} does not match bob {}'.format(to_address, bob)) #params)) Mocket.error = True if not Mocket.error: Mocket.tx = EIP155Transaction(params, params['nonce'], params['chainId']) diff --git a/tests/test_tx.py b/tests/test_tx.py @@ -23,7 +23,10 @@ from chainlib.eth.contract import ( ABIContractEncoder, ABIContractType, ) -from chainlib.eth.address import to_checksum_address +from chainlib.eth.address import ( + to_checksum_address, + is_same_address, + ) from hexathon import ( strip_0x, add_0x, @@ -43,8 +46,8 @@ class TxTestCase(EthTesterCase): c = Gas(signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle, chain_spec=self.chain_spec) (tx_hash_hex, o) = c.create(self.accounts[0], self.accounts[1], 1024, tx_format=TxFormat.RLP_SIGNED) tx = unpack(bytes.fromhex(strip_0x(o)), self.chain_spec) - self.assertEqual(tx['from'], self.accounts[0]) - self.assertEqual(tx['to'], self.accounts[1]) + self.assertTrue(is_same_address(tx['from'], self.accounts[0])) + self.assertTrue(is_same_address(tx['to'], self.accounts[1])) def test_tx_pack(self):