Rehabilitate tests

This commit is contained in:
nolash 2021-10-18 13:57:42 +02:00
parent c66f5fdff9
commit 2204c512c3
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 21 additions and 13 deletions

View File

@ -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))

View File

@ -7,16 +7,19 @@ import logging
import json
# external imports
from crypto_dev_signer.eth.transaction import EIP155Transaction
from crypto_dev_signer.eth.signer.defaultsigner import ReferenceSigner
from crypto_dev_signer.keystore.dict import DictKeystore
from funga.eth.transaction import EIP155Transaction
from funga.eth.signer.defaultsigner import EIP155Signer
from funga.eth.keystore.dict import DictKeystore
# local imports
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'])
@ -92,7 +97,7 @@ class TestSign(TestBase):
logg.debug('alice {}'.format(alice))
logg.debug('bob {}'.format(bob))
self.signer = ReferenceSigner(keystore)
self.signer = EIP155Signer(keystore)
Mocket.signer = self.signer

View File

@ -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):