Remove eth_keys, web3 dependencies
This commit is contained in:
@@ -3,14 +3,12 @@ import unittest
|
||||
import logging
|
||||
import os
|
||||
|
||||
# third-party imports
|
||||
import web3
|
||||
|
||||
# local imports
|
||||
from crypto_dev_signer.keystore import DictKeystore
|
||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner
|
||||
from crypto_dev_signer.helper import TxExecutor
|
||||
from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||
#from crypto_dev_signer.eth.helper import EthTxExecutor
|
||||
from crypto_dev_signer.encoding import to_checksum_address
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
@@ -42,7 +40,7 @@ class MockEthTxBackend:
|
||||
|
||||
def builder_two(self, tx):
|
||||
tx['value'] = 10243
|
||||
tx['to'] = web3.Web3.toChecksumAddress('0x' + os.urandom(20).hex())
|
||||
tx['to'] = to_checksum_address('0x' + os.urandom(20).hex())
|
||||
tx['data'] = ''
|
||||
if tx.get('feePrice') != None:
|
||||
tx['gasPrice'] = tx['feePrice']
|
||||
@@ -78,15 +76,15 @@ class TestHelper(unittest.TestCase):
|
||||
executor.sign_and_send([backend.builder_two])
|
||||
|
||||
|
||||
def test_eth_helper(self):
|
||||
backend = MockEthTxBackend()
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider('http://localhost:8545'))
|
||||
executor = EthTxExecutor(w3, self.address_hex, self.signer, 1337)
|
||||
|
||||
tx_ish = {'from': self.address_hex}
|
||||
#executor.sign_and_send([backend.builder, backend.builder_two])
|
||||
with self.assertRaises(ValueError):
|
||||
executor.sign_and_send([backend.builder_two])
|
||||
# def test_eth_helper(self):
|
||||
# backend = MockEthTxBackend()
|
||||
# w3 = web3.Web3(web3.Web3.HTTPProvider('http://localhost:8545'))
|
||||
# executor = EthTxExecutor(w3, self.address_hex, self.signer, 1337)
|
||||
#
|
||||
# tx_ish = {'from': self.address_hex}
|
||||
# #executor.sign_and_send([backend.builder, backend.builder_two])
|
||||
# with self.assertRaises(ValueError):
|
||||
# executor.sign_and_send([backend.builder_two])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -7,7 +7,7 @@ import base64
|
||||
import os
|
||||
|
||||
# local imports
|
||||
from crypto_dev_signer.keystore import DictKeystore
|
||||
from crypto_dev_signer.keystore.dict import DictKeystore
|
||||
from crypto_dev_signer.error import UnknownAccountError
|
||||
from crypto_dev_signer.eth.signer import ReferenceSigner
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from psycopg2 import sql
|
||||
from cryptography.fernet import Fernet, InvalidToken
|
||||
|
||||
# local imports
|
||||
from crypto_dev_signer.keystore import ReferenceKeystore
|
||||
from crypto_dev_signer.keystore.postgres import ReferenceKeystore
|
||||
from crypto_dev_signer.error import UnknownAccountError
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
@@ -68,14 +68,14 @@ class TestSign(unittest.TestCase):
|
||||
t = EIP155Transaction(tx_ints, 0)
|
||||
self.assertRegex(t.__class__.__name__, "Transaction")
|
||||
s = t.serialize()
|
||||
self.assertEqual('{}'.format(s), "{'nonce': '', 'gasPrice': '0x04a817c800', 'gas': '0x5208', 'to': '0x3535353535353535353535353535353535353535', 'value': '0x03e8', 'data': '0xdeadbeef', 'v': '0x01', 'r': '', 's': ''}")
|
||||
self.assertEqual('{}'.format(s), "{'nonce': '0x00', 'gasPrice': '0x04a817c800', 'gas': '0x5208', 'to': '0x3535353535353535353535353535353535353535', 'value': '0x03e8', 'data': '0xdeadbeef', 'v': '0x01', 'r': '', 's': ''}")
|
||||
r = t.rlp_serialize()
|
||||
self.assertEqual(r.hex(), 'ea808504a817c8008252089435353535353535353535353535353535353535358203e884deadbeef018080')
|
||||
|
||||
t = EIP155Transaction(tx_hexs, 0)
|
||||
self.assertRegex(t.__class__.__name__, "Transaction")
|
||||
s = t.serialize()
|
||||
self.assertEqual('{}'.format(s), "{'nonce': '', 'gasPrice': '0x04a817c800', 'gas': '0x5208', 'to': '0x3535353535353535353535353535353535353535', 'value': '0x03e8', 'data': '0xdeadbeef', 'v': '0x01', 'r': '', 's': ''}")
|
||||
self.assertEqual('{}'.format(s), "{'nonce': '0x00', 'gasPrice': '0x04a817c800', 'gas': '0x5208', 'to': '0x3535353535353535353535353535353535353535', 'value': '0x03e8', 'data': '0xdeadbeef', 'v': '0x01', 'r': '', 's': ''}")
|
||||
r = t.rlp_serialize()
|
||||
self.assertEqual(r.hex(), 'ea808504a817c8008252089435353535353535353535353535353535353535358203e884deadbeef018080')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user