mirror of
git://holbrook.no/eth-accounts-index
synced 2026-05-17 10:45:21 +02:00
Add unittest module, factor out common test code
This commit is contained in:
@@ -26,6 +26,7 @@ from chainlib.eth.block import (
|
||||
# local imports
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
from eth_accounts_index import AccountsIndex
|
||||
from eth_accounts_index.unittest import TestAccountsIndex
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
@@ -33,39 +34,10 @@ logg = logging.getLogger()
|
||||
testdir = os.path.dirname(__file__)
|
||||
|
||||
|
||||
class TestNonceOracle:
|
||||
|
||||
def __init__(self, address, default_value=0):
|
||||
self.nonce = default_value
|
||||
|
||||
|
||||
def next_nonce(self):
|
||||
nonce = self.nonce
|
||||
self.nonce += 1
|
||||
return nonce
|
||||
|
||||
|
||||
class Test(EthTesterCase):
|
||||
class Test(TestAccountsIndex):
|
||||
|
||||
def setUp(self):
|
||||
super(Test, self).setUp()
|
||||
nonce_oracle = TestNonceOracle(self.accounts[0])
|
||||
c = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
(tx_hash, o) = c.constructor(self.accounts[0])
|
||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||
r = self.conn.do(o)
|
||||
logg.debug(f'published with hash {r}')
|
||||
|
||||
o = receipt(r)
|
||||
r = self.conn.do(o)
|
||||
self.address = to_checksum_address(r['contract_address'])
|
||||
|
||||
(tx_hash, o) = c.add_writer(self.address, self.accounts[0], self.accounts[0])
|
||||
r = self.conn.do(o)
|
||||
|
||||
o = receipt(r)
|
||||
r = self.conn.do(o)
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
|
||||
def test_1_count(self):
|
||||
|
||||
Reference in New Issue
Block a user