mirror of
git://holbrook.no/eth-faucet
synced 2025-01-07 09:37:32 +01:00
Improve testing
This commit is contained in:
parent
621077aa0f
commit
2ed3f46660
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user