mirror of
git://holbrook.no/eth-faucet
synced 2026-04-27 10:21:04 +02:00
Add nextTime method
This commit is contained in:
@@ -35,13 +35,13 @@ class TestFaucetPeriod(EthTesterCase):
|
||||
def setUp(self):
|
||||
super(TestFaucetPeriod, self).setUp()
|
||||
# DRY
|
||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
|
||||
|
||||
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)
|
||||
|
||||
f = open(os.path.join(datadir, 'PeriodSimple.bin'))
|
||||
period_store_bytecode = f.read()
|
||||
f.close()
|
||||
@@ -207,5 +207,35 @@ class TestFaucetPeriod(EthTesterCase):
|
||||
self.assertEqual(r['status'], 1)
|
||||
|
||||
|
||||
def test_period_front(self):
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
|
||||
c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('setPeriod')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.uint256(100)
|
||||
data = enc.get()
|
||||
tx = c.template(self.accounts[0], self.period_store_address, use_nonce=True)
|
||||
tx = c.set_code(tx, data)
|
||||
(tx_hash_hex, o) = c.finalize(tx)
|
||||
self.conn.do(o)
|
||||
|
||||
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.gimme(self.address, self.accounts[0])
|
||||
self.conn.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.conn.do(o)
|
||||
o = block_by_number(r['block_number'])
|
||||
r = self.conn.do(o)
|
||||
thistime = r['timestamp']
|
||||
|
||||
o = c.next_time(self.address, self.accounts[0], sender_address=self.accounts[0])
|
||||
r = self.conn.do(o)
|
||||
nexttime = int(r, 16)
|
||||
|
||||
self.assertEqual(nexttime, thistime+100)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user