eth-erc20

ERC20 interface and example giftable token contract
Log | Files | Refs | LICENSE

commit 637080c4641fc2cf0242e8f1f44d717c7bfd3336
parent 2fb7143956b8889fdc124a11e610911da4bc68d0
Author: lash <dev@holbrook.no>
Date:   Thu, 27 Jul 2023 07:36:33 +0100

Factor out token publish in giftable token unittest fixture

Diffstat:
Mpython/CHANGELOG | 2++
Mpython/giftable_erc20_token/unittest/base.py | 30+++++++++++++++++++-----------
Mpython/setup.cfg | 2+-
3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,3 +1,5 @@ +* 0.7.5 + - Factor out token publish method in unittest fixture * 0.7.4 - Add missing unittest module to python package * 0.7.3 diff --git a/python/giftable_erc20_token/unittest/base.py b/python/giftable_erc20_token/unittest/base.py @@ -22,19 +22,11 @@ class TestGiftableToken(EthTesterCase): def setUp(self): super(TestGiftableToken, self).setUp() self.conn = RPCConnection.connect(self.chain_spec, 'default') + + address = self.publish_giftable_token('Foo Token', 'FOO', 16, expire=self.expire) + self.address = to_checksum_address(address) nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - self.symbol = 'FOO' - self.name = 'Foo Token' - self.decimals = 16 - (tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals, expire=self.expire) - self.rpc.do(o) - o = receipt(tx_hash) - r = self.rpc.do(o) - self.assertEqual(r['status'], 1) - self.address = to_checksum_address(r['contract_address']) - logg.debug('published on address {} with hash {}'.format(self.address, tx_hash)) - self.initial_supply = 1 << 40 (tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[0], self.initial_supply) r = self.conn.do(o) @@ -43,6 +35,22 @@ class TestGiftableToken(EthTesterCase): self.assertEqual(r['status'], 1) + def publish_giftable_token(self, name, symbol, decimals=16, expire=None): + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) + c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + self.symbol = name + self.name = symbol + self.decimals = decimals + (tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals, expire=expire) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + address = r['contract_address'] + logg.debug('published on address {} with hash {}'.format(address, tx_hash)) + return address + + class TestGiftableExpireToken(TestGiftableToken): expire = int(time.time()) + 100000 diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-erc20 -version = 0.7.4 +version = 0.7.5 description = ERC20 interface and simple contract with deployment script that lets any address mint and gift itself tokens. author = Louis Holbrook author_email = dev@holbrook.no