eth-interface

EIP-165 interface and tools for chainlib-eth
git clone git://holbrook.no/eth-interface.git
Log | Files | Refs

commit 68a9c37dd011f0749eb3bbd400a9c4e54751be4a
parent c254ab08590885c4ec11a338c3a605a586729550
Author: lash <dev@holbrook.no>
Date:   Fri, 24 Mar 2023 17:05:17 +0000

Add unittest support

Diffstat:
Mpython/eth_interface/__init__.py | 2+-
Mpython/eth_interface/eip165.py | 2+-
Apython/eth_interface/unittest/__init__.py | 1+
Apython/eth_interface/unittest/base.py | 31+++++++++++++++++++++++++++++++
Mpython/setup.cfg | 16+++++++++-------
Mpython/tests/test_eip165.py | 4++--
6 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/python/eth_interface/__init__.py b/python/eth_interface/__init__.py @@ -1 +1 @@ -from .eip165 import EIP165 +from .eip165 import ERC165 diff --git a/python/eth_interface/eip165.py b/python/eth_interface/eip165.py @@ -13,7 +13,7 @@ from chainlib.eth.contract import ( from chainlib.eth.tx import TxFactory -class EIP165(TxFactory): +class ERC165(TxFactory): def supports_interface(self, contract_address, interface_sum, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) diff --git a/python/eth_interface/unittest/__init__.py b/python/eth_interface/unittest/__init__.py @@ -0,0 +1 @@ +from .base import * diff --git a/python/eth_interface/unittest/base.py b/python/eth_interface/unittest/base.py @@ -0,0 +1,31 @@ +# standard imports +import logging + +# local imports +from eth_interface import ERC165 + +logg = logging.getLogger(__name__) + + +class TestERC165: + + erc165_ifcs = [] + + @classmethod + def flush_interface_check(cls): + cls.erc165_ifcs = [] + + + @classmethod + def add_interface_check(cls, ifc): + assert len(bytes.fromhex(ifc)) == 4 + cls.erc165_ifcs.append(ifc) + + + def test_erc165_interfaces(self): + c = ERC165(self.chain_spec) + for ifc in self.erc165_ifcs: + logg.debug('checking ifc {}'.format(ifc)) + o = c.supports_interface(self.address, ifc, sender_address=self.accounts[0]) + r = self.rpc.do(o) + self.assertEqual(int(r, 16), 1) diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,30 +1,32 @@ [metadata] name = eth-interface -version = 0.0.1 +version = 0.1.0 description = EIP165 interface author = Louis Holbrook author_email = dev@holbrook.no -url = https://gitlab.com/cicnet/eth-interface +url = https://git.defalsify.org/eth-interface keywords = ethereum classifiers = Programming Language :: Python :: 3 Operating System :: OS Independent - Development Status :: 3 - Alpha - Environment :: No Input/Output (Daemon) + Development Status :: 4 - Beta + Environment :: Console Intended Audience :: Developers - License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) + License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+) + Topic :: Software Development :: Libraries Topic :: Internet #Topic :: Blockchain :: EVM -license = GPL3 +license = AGPL3 licence_files = LICENSE [options] include_package_data = True -python_requires = >= 3.6 +python_requires = >= 3.8 packages = eth_interface + eth_interface.unittest [options.package_data] * = diff --git a/python/tests/test_eip165.py b/python/tests/test_eip165.py @@ -14,7 +14,7 @@ from chainlib.eth.tx import ( ) # local imports -from eth_interface.eip165 import EIP165 +from eth_interface import ERC165 logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() @@ -48,7 +48,7 @@ class TestSupports(EthTesterCase): def test_supports(self): gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn) - c = EIP165(self.chain_spec, gas_oracle=gas_oracle) + c = ERC165(self.chain_spec, gas_oracle=gas_oracle) o = c.supports_interface(self.address, '0xdeadbeef', sender_address=self.accounts[0]) r = self.conn.do(o) v = c.parse_supports_interface(r)