Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
35c6b26677 | ||
|
c7f88b71ce | ||
|
e73a258ce9 | ||
|
a2132e11c1 | ||
|
0b62874631 | ||
|
8d51154564 | ||
|
ab6d99005d | ||
|
682fa9ee5f |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -19,6 +19,10 @@ class TestCappedToken(EthTesterCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCappedToken, self).setUp()
|
super(TestCappedToken, self).setUp()
|
||||||
|
self.publish()
|
||||||
|
|
||||||
|
|
||||||
|
def publish(self):
|
||||||
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
||||||
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
||||||
c = CappedToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
c = CappedToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = ge-capped-token
|
name = ge-capped-token
|
||||||
version = 0.1.0
|
version = 0.1.1
|
||||||
description = ERC20 token that can be minted, capped and expired.
|
description = ERC20 token that can be minted, capped and expired.
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
eth_tester==0.5.0b3
|
eth_tester==0.5.0b3
|
||||||
py-evm==0.3.0a20
|
py-evm==0.3.0a20
|
||||||
pytest==6.0.1
|
pytest==6.0.1
|
||||||
|
cic-contracts~=0.3.8
|
||||||
|
eth-interface~=0.1.2
|
||||||
|
eth-owned~=0.1.2
|
||||||
|
25
python/tests/test_cic_burner.py
Normal file
25
python/tests/test_cic_burner.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
from chainlib.eth.block import block_latest
|
||||||
|
from chainlib.eth.block import block_by_number
|
||||||
|
from eth_burner.unittest import TestEthBurnerInterface
|
||||||
|
from eth_burner.unittest.base import TestEthBurner
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
from cic_contracts import erc165_for
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedBurner(TestEthBurner, TestCappedToken, TestEthBurnerInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedBurner, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
32
python/tests/test_cic_capped.py
Normal file
32
python/tests/test_cic_capped.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
from eth_capped.unittest import TestEthCappedInterface
|
||||||
|
from eth_capped.unittest.base import TestEthCapped
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedCapped(TestEthCapped, TestCappedToken, TestEthCappedInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedCapped, self).setUp()
|
||||||
|
self.set_method = self.set_max_supply
|
||||||
|
self.max_supply_value = self.initial_supply + 1
|
||||||
|
self.publish()
|
||||||
|
(tx_hash, o) = self.set_method(self.address, self.accounts[0], self.max_supply_value)
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
self.contracts['capped'] = self.address
|
||||||
|
self.roles['capped'] = self.accounts[0]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
39
python/tests/test_cic_expire.py
Normal file
39
python/tests/test_cic_expire.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
from chainlib.eth.block import block_latest
|
||||||
|
from chainlib.eth.block import block_by_number
|
||||||
|
from eth_expire.unittest import TestEthExpireInterface
|
||||||
|
from eth_expire.unittest.base import TestEthExpire
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedExpire(TestEthExpire, TestCappedToken, TestEthExpireInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedExpire, self).setUp()
|
||||||
|
self.set_method = self.set_expire
|
||||||
|
|
||||||
|
o = block_latest()
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
o = block_by_number(r)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
|
||||||
|
self.expire_value = r['timestamp'] + 10000
|
||||||
|
self.publish()
|
||||||
|
(tx_hash, o) = self.set_method(self.address, self.accounts[0], self.expire_value)
|
||||||
|
self.rpc.do(o)
|
||||||
|
o = receipt(tx_hash)
|
||||||
|
r = self.rpc.do(o)
|
||||||
|
self.assertEqual(r['status'], 1)
|
||||||
|
self.contracts['expire'] = self.address
|
||||||
|
self.roles['expire'] = self.accounts[0]
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
24
python/tests/test_cic_minter.py
Normal file
24
python/tests/test_cic_minter.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
from chainlib.eth.block import block_latest
|
||||||
|
from chainlib.eth.block import block_by_number
|
||||||
|
from eth_minter.unittest import TestEthMinterInterface
|
||||||
|
from eth_minter.unittest.base import TestEthMinter
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedMinter(TestEthMinter, TestCappedToken, TestEthMinterInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedMinter, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
30
python/tests/test_cic_seal.py
Normal file
30
python/tests/test_cic_seal.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from chainlib.eth.tx import receipt
|
||||||
|
from chainlib.eth.block import block_latest
|
||||||
|
from chainlib.eth.block import block_by_number
|
||||||
|
from eth_seal.unittest import TestEthSealInterface
|
||||||
|
from eth_seal.unittest.base import TestEthSeal
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedSeal(TestEthSeal, TestCappedToken, TestEthSealInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedSeal, self).setUp()
|
||||||
|
self.set_method = self.seal
|
||||||
|
self.max_seal_state = 15
|
||||||
|
|
||||||
|
self.publish()
|
||||||
|
self.contracts['seal'] = self.address
|
||||||
|
self.roles['seal'] = self.accounts[0]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
23
python/tests/test_cic_writer.py
Normal file
23
python/tests/test_cic_writer.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from eth_writer.unittest import TestEthWriterInterface
|
||||||
|
from eth_writer.unittest.base import TestEthWriter
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedWriter(TestCappedToken, TestEthWriterInterface):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedWriter, self).setUp()
|
||||||
|
self.contracts['writer'] = self.address
|
||||||
|
self.roles['writer'] = self.accounts[0]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
34
python/tests/test_erc165.py
Normal file
34
python/tests/test_erc165.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from cic_contracts import erc165_for
|
||||||
|
from eth_interface.unittest import TestERC165
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedBurner(TestCappedToken, TestERC165):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestEthCappedBurner, self).setUp()
|
||||||
|
for v in [
|
||||||
|
# 'Minter',
|
||||||
|
'Burner',
|
||||||
|
'Capped',
|
||||||
|
'Writer',
|
||||||
|
'Expire',
|
||||||
|
'ERC20',
|
||||||
|
]:
|
||||||
|
ifc = erc165_for(v)
|
||||||
|
logg.debug('add interface check {} -> {}'.format(v, ifc))
|
||||||
|
self.add_interface_check(ifc)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
21
python/tests/test_erc173.py
Normal file
21
python/tests/test_erc173.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# standard imports
|
||||||
|
import unittest
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# external imports
|
||||||
|
from cic_contracts import erc165_for
|
||||||
|
from eth_owned.unittest import TestERC173
|
||||||
|
|
||||||
|
# local imports
|
||||||
|
from ge_capped_token.unittest import TestCappedToken
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class TestEthCappedERC173(TestCappedToken, TestERC173):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -181,7 +181,6 @@ contract CappedToken {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements ERC20
|
// Implements ERC20
|
||||||
@ -272,6 +271,9 @@ contract CappedToken {
|
|||||||
if (_sum == 0x841a0e94) { // Expire
|
if (_sum == 0x841a0e94) { // Expire
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (_sum == 0x869f7594) { // Capped
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user