Add limiter token registry

This commit is contained in:
lash
2023-07-28 13:46:15 +01:00
parent 5219ca0385
commit 89b92ef7de
9 changed files with 136 additions and 30 deletions

View File

@@ -14,6 +14,7 @@ from chainlib.eth.block import block_latest
from eth_accounts_index.unittest import TestAccountsIndex
from eth_accounts_index.registry import AccountRegistry
from giftable_erc20_token import GiftableToken
from erc20_limiter.unittest import TestLimiter
# local imports
from erc20_pool import Pool
@@ -21,18 +22,21 @@ from erc20_pool import Pool
logg = logging.getLogger(__name__)
hash_of_foo = '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'
hash_of_bar = 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'
hash_of_baz = 'baa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096'
#hash_of_bar = 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9'
#hash_of_baz = 'baa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096'
class TestERC20Pool(TestGiftableToken):
class TestERC20PoolBase(TestGiftableToken):
expire = 0
def setUp(self):
super(TestERC20Pool, self).setUp()
super(TestERC20PoolBase, self).setUp()
self.foo_address = self.address
self.publish_tokens()
def publish_tokens(self):
self.bar_address = self.publish_giftable_token('Bar Token', 'BAR', 16)
self.baz_address = self.publish_giftable_token('Baz Token', 'BAZ', 16)
self.initial_supply_bar = 1 << 20
@@ -52,8 +56,11 @@ class TestERC20Pool(TestGiftableToken):
r = self.conn.do(o)
self.assertEqual(r['status'], 1)
def publish_pool(self, declaration=hash_of_foo, token_registry=None, token_limiter=None):
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
c = Pool(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash, o) = c.constructor(self.accounts[0], "Big Pool", "BIG", 16)
(tx_hash, o) = c.constructor(self.accounts[0], "Big Pool", "BIG", 16, declaration=declaration, token_registry=token_registry, token_limiter=token_limiter)
self.rpc.do(o)
o = receipt(tx_hash)
r = self.rpc.do(o)
@@ -62,3 +69,19 @@ class TestERC20Pool(TestGiftableToken):
self.address = self.pool_address
logg.debug('published bar token {}, baz token {}'.format(self.bar_address, self.baz_address))
logg.debug('published pool on address {} with hash {}'.format(self.pool_address, tx_hash))
class TestERC20Pool(TestERC20PoolBase):
def setUp(self):
super(TestERC20Pool, self).setUp()
self.publish_pool()
class TestERC20PoolLimiter(TestERC20PoolBase, TestLimiter):
def setUp(self):
super(TestERC20PoolLimiter, self).setUp()
self.limiter_address = self.publish_limiter()
self.publish_pool(token_limiter=self.limiter_address)