add missing files, make adapter test rely on chaintool alembic
This commit is contained in:
22
tests/chaind_eth_base.py
Normal file
22
tests/chaind_eth_base.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# standard imports
|
||||
import unittest
|
||||
|
||||
# external imports
|
||||
from chainsyncer.unittest.db import ChainSyncerDb
|
||||
from chainqueue.unittest.db import ChainQueueDb
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.db_chainsyncer = ChainSyncerDb()
|
||||
self.session_chainsyncer = self.db_chainsyncer.bind_session()
|
||||
|
||||
self.db_chainqueue = ChainQueueDb()
|
||||
self.session_chainqueue = self.db_chainqueue.bind_session()
|
||||
|
||||
def tearDown(self):
|
||||
self.session_chainsyncer.commit()
|
||||
self.db_chainsyncer.release_session(self.session_chainsyncer)
|
||||
self.session_chainqueue.commit()
|
||||
self.db_chainqueue.release_session(self.session_chainqueue)
|
||||
45
tests/test_adapter.py
Normal file
45
tests/test_adapter.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# stanndard imports
|
||||
import logging
|
||||
import unittest
|
||||
import os
|
||||
|
||||
# external imports
|
||||
from chainqueue.sql.backend import SQLBackend
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainqueue.unittest.db import (
|
||||
db_config,
|
||||
dsn_from_config,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from chainqueue.adapters.eth import EthAdapter
|
||||
|
||||
# test imports
|
||||
from tests.chaind_eth_base import TestBase
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
|
||||
class TestAdapter(TestBase):
|
||||
|
||||
example_tx = bytes.fromhex('f8640183989680825208948311ad69b3429400ab795d45af85d204f73329ae8204d38026a097a7fd66548e4c116270b547ac7ed8cb531b0b97f80d49b45986144e47dbe44da07cc4345741dc0fabf65a473c0d3a1536cd501961f7e01b07dd8e107ff87d1556')
|
||||
dsn = dsn_from_config(db_config)
|
||||
|
||||
def setUp(self):
|
||||
super(TestAdapter, self).setUp()
|
||||
self.chain_spec = ChainSpec.from_chain_str('foo:bar:1:baz')
|
||||
self.backend = SQLBackend(self.dsn, debug=bool(os.environ.get('DATABASE_DEBUG')))
|
||||
self.adapter = EthAdapter(self.backend)
|
||||
|
||||
|
||||
def test_eth_adapter_translate(self):
|
||||
self.adapter.translate(self.chain_spec, self.example_tx)
|
||||
# succesful decode means translate is working, no further checks needed
|
||||
|
||||
|
||||
def test_eth_adapter_add(self):
|
||||
self.adapter.add(self.chain_spec, self.example_tx, session=self.session_chainqueue)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
15
tests/test_helo.py
Normal file
15
tests/test_helo.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# standard imports
|
||||
import unittest
|
||||
|
||||
# test imports
|
||||
from tests.chaind_eth_base import TestBase
|
||||
|
||||
|
||||
class TestHelo(TestBase):
|
||||
|
||||
def test_helo(self):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user