Habilitate expire unittest module for external use
This commit is contained in:
parent
80589e574a
commit
fe4f1c2c41
@ -1,7 +1,7 @@
|
||||
INPUTS = $(wildcard solidity/*.sol)
|
||||
INPUTS = $(wildcard cic_contracts/unittest/solidity/*.sol)
|
||||
OUTPUTS = $(patsubst %.sol, %.bin, $(INPUTS))
|
||||
|
||||
all: outs readme package
|
||||
all: outs package
|
||||
|
||||
.SUFFIXES: .sol .bin
|
||||
|
||||
|
@ -34,9 +34,9 @@ class TestEthExpire(EthTesterCase):
|
||||
tx = txf.template(self.accounts[0], None, use_nonce=True)
|
||||
|
||||
date_expire = datetime.datetime.utcnow() + datetime.timedelta(seconds=10000)
|
||||
self.expire = int(date_expire.timestamp())
|
||||
self.expire_value = int(date_expire.timestamp())
|
||||
enc = ABIContractEncoder()
|
||||
enc.uint256(self.expire)
|
||||
enc.uint256(self.expire_value)
|
||||
args = enc.get()
|
||||
|
||||
tx = txf.set_code(tx, code + args)
|
||||
@ -49,11 +49,11 @@ class TestEthExpire(EthTesterCase):
|
||||
logg.debug('published expire test contract with hash {}'.format(r))
|
||||
|
||||
|
||||
def set_expiry(self, contract_address, sender_address, v, tx_format=TxFormat.JSONRPC):
|
||||
def set_expire(self, contract_address, sender_address, v, tx_format=TxFormat.JSONRPC):
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
|
||||
txf = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('setExpiry')
|
||||
enc.method('setExpire')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.uint256(v)
|
||||
data = enc.get()
|
||||
|
@ -12,20 +12,20 @@ class TestEthExpireInterface:
|
||||
|
||||
|
||||
def test_expire(self):
|
||||
if self.expire == 0:
|
||||
if self.expire_value == 0:
|
||||
return
|
||||
c = EthExpire(self.chain_spec)
|
||||
o = c.expires(self.address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(self.expire, int(r, 16))
|
||||
self.assertEqual(self.expire_value, int(r, 16))
|
||||
|
||||
|
||||
def test_expire_change(self):
|
||||
if self.set_method == None:
|
||||
return
|
||||
|
||||
self.expire += 43200
|
||||
(tx_hash_hex, o) = self.set_method(self.address, self.accounts[0], self.expire)
|
||||
self.expire_value += 43200
|
||||
(tx_hash_hex, o) = self.set_method(self.address, self.accounts[0], self.expire_value)
|
||||
self.rpc.do(o)
|
||||
o = receipt(tx_hash_hex)
|
||||
r = self.conn.do(o)
|
||||
@ -34,4 +34,4 @@ class TestEthExpireInterface:
|
||||
c = EthExpire(self.chain_spec)
|
||||
o = c.expires(self.address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(self.expire, int(r, 16))
|
||||
self.assertEqual(self.expire_value, int(r, 16))
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = cic-contracts
|
||||
version = 0.3.4
|
||||
version = 0.3.5
|
||||
description = CIC network smart contract interfaces
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
|
@ -23,7 +23,7 @@ class TestExpireBase(TestEthExpire, TestEthExpireInterface, TestERC165):
|
||||
def setUp(self):
|
||||
super(TestExpireBase, self).setUp()
|
||||
self.add_interface_check('841a0e94')
|
||||
self.set_method = self.set_expiry
|
||||
self.set_method = self.set_expire
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user