commit 2ed3f466606fbd1460362d456a694eaf78968a4a
parent 621077aa0f966f662ca570247c0535e8fe44c500
Author: lash <dev@holbrook.no>
Date: Sat, 4 Feb 2023 10:33:00 +0000
Improve testing
Diffstat:
3 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py
@@ -13,8 +13,8 @@ from chainlib.eth.gas import balance
from chainlib.eth.gas import Gas
from chainlib.eth.gas import OverrideGasOracle
-# local imports
-from eth_faucet.faucet import EthFaucet
+# local import
+from eth_faucet import EthFaucet
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -44,6 +44,24 @@ class TestFaucet(EthTesterCase):
o = receipt(tx_hash_hex)
r = self.conn.do(o)
self.assertEqual(r['status'], 1)
+
+ nonce_oracle = RPCNonceOracle(self.accounts[2], self.conn)
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.gimme(self.address, self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+
+ def test_basic_funding(self):
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
o = balance(self.accounts[9])
r = self.conn.do(o)
@@ -92,7 +110,7 @@ class TestFaucet(EthTesterCase):
self.assertEqual(int(r, 16), prebalance + 1000)
- def test_basic_fund(self):
+ def test_basic_result(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
@@ -121,7 +139,6 @@ class TestFaucet(EthTesterCase):
o = receipt(tx_hash_hex)
r = self.conn.do(o)
- logg.debug('rrrr {}'.format(r))
cost = r['gas_used'] * gas_price
self.assertEqual(r['status'], 1)
@@ -130,15 +147,5 @@ class TestFaucet(EthTesterCase):
self.assertEqual(int(r, 16), prebalance - cost + 1000)
- def test_basic_self(self):
- nonce_oracle = RPCNonceOracle(self.accounts[2], self.conn)
- c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
- (tx_hash_hex, o) = c.gimme(self.address, self.accounts[2])
- self.conn.do(o)
- o = receipt(tx_hash_hex)
- r = self.conn.do(o)
- self.assertEqual(r['status'], 1)
-
-
if __name__ == '__main__':
unittest.main()
diff --git a/python/tests/test_period.py b/python/tests/test_period.py
@@ -18,7 +18,8 @@ from chainlib.eth.contract import ABIContractType
from chainlib.eth.block import block_by_number
# local imports
-from eth_faucet.faucet import EthFaucet
+from eth_faucet import EthFaucet
+from eth_faucet.period import PeriodSimple
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -34,6 +35,10 @@ class TestFaucetPeriod(EthTesterCase):
def setUp(self):
super(TestFaucetPeriod, self).setUp()
# DRY
+ c = PeriodSimple(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.constructor(self.accounts[0])
+ r = self.conn.do(o)
+
self.conn = RPCConnection.connect(self.chain_spec, 'default')
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
diff --git a/python/tests/test_registry.py b/python/tests/test_registry.py
@@ -19,7 +19,7 @@ from chainlib.eth.block import block_by_number
from eth_accounts_index.registry import AccountRegistry
# local imports
-from eth_faucet.faucet import EthFaucet
+from eth_faucet import EthFaucet
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -70,6 +70,24 @@ class TestFaucetRegistry(EthTesterCase):
self.assertEqual(r['status'], 1)
+ def test_basic(self):
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 0)
+
+ nonce_oracle = RPCNonceOracle(self.accounts[2], self.conn)
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.gimme(self.address, self.accounts[1])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+
def test_registry(self):
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)