commit 057980e21355f90734da2f469fcd3ebd59da636d
parent b895ebbef9bebe2de8833ecc87894b806c312d80
Author: lash <dev@holbrook.no>
Date: Tue, 6 Jun 2023 13:59:57 +0100
Add erc165 self-check in test
Diffstat:
6 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/python/eth_interface/unittest/base.py b/python/eth_interface/unittest/base.py
@@ -24,7 +24,8 @@ class TestERC165:
def test_erc165_interfaces(self):
c = ERC165(self.chain_spec)
- for ifc in self.erc165_ifcs:
+ logg.info('will check interfaces: {}'.format(self.erc165_ifcs))
+ for ifc in self.erc165_ifcs + ['01ffc9a7']:
logg.debug('checking ifc {}'.format(ifc))
o = c.supports_interface(self.address, ifc, sender_address=self.accounts[0])
r = self.rpc.do(o)
diff --git a/python/setup.cfg b/python/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = eth-interface
-version = 0.1.1
+version = 0.1.2
description = EIP165 interface
author = Louis Holbrook
author_email = dev@holbrook.no
diff --git a/python/tests/test_eip165.py b/python/tests/test_eip165.py
@@ -15,6 +15,7 @@ from chainlib.eth.tx import (
# local imports
from eth_interface import ERC165
+from eth_interface.unittest import TestERC165
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
@@ -22,7 +23,7 @@ logg = logging.getLogger()
script_dir = os.path.realpath(os.path.dirname(__file__))
-class TestSupports(EthTesterCase):
+class TestSupports(EthTesterCase, TestERC165):
def setUp(self):
super(TestSupports, self).setUp()
@@ -46,18 +47,18 @@ class TestSupports(EthTesterCase):
self.address = r['contract_address']
- def test_supports(self):
- gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
- 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)
- self.assertEqual(v, 1)
-
- o = c.supports_interface(self.address, '0xbeeffeed', sender_address=self.accounts[0])
- r = self.conn.do(o)
- v = c.parse_supports_interface(r)
- self.assertEqual(v, 0)
+# def test_supports(self):
+# gas_oracle = OverrideGasOracle(limit=100000, conn=self.conn)
+# 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)
+# self.assertEqual(v, 1)
+#
+# o = c.supports_interface(self.address, '0xbeeffeed', sender_address=self.accounts[0])
+# r = self.conn.do(o)
+# v = c.parse_supports_interface(r)
+# self.assertEqual(v, 0)
if __name__ == '__main__':
unittest.main()
diff --git a/python/tests/testdata/Supports.bin b/python/tests/testdata/Supports.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b506101c9806100206000396000f3fe608060405234801561001057600080fd5b5060043610610048576000357c01000000000000000000000000000000000000000000000000000000009004806301ffc9a71461004d575b600080fd5b610067600480360381019061006291906100f1565b61007d565b6040516100749190610129565b60405180910390f35b600063deadbeef7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156100d257600190506100d7565b600090505b919050565b6000813590506100eb8161017c565b92915050565b60006020828403121561010357600080fd5b6000610111848285016100dc565b91505092915050565b61012381610144565b82525050565b600060208201905061013e600083018461011a565b92915050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61018581610150565b811461019057600080fd5b5056fea264697066735822122073144ec34d71a86680325f1aee9a3b9041e22c422e7b1b82d409b303d52192de64736f6c63430008030033
-\ No newline at end of file
+608060405234801561001057600080fd5b50610223806100206000396000f3fe608060405234801561001057600080fd5b5060043610610048576000357c01000000000000000000000000000000000000000000000000000000009004806301ffc9a71461004d575b600080fd5b6100676004803603810190610062919061018a565b61007d565b60405161007491906101d2565b60405180910390f35b60006301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036100d15760019050610128565b63deadbeef7c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036101235760019050610128565b600090505b919050565b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61016781610132565b811461017257600080fd5b50565b6000813590506101848161015e565b92915050565b6000602082840312156101a05761019f61012d565b5b60006101ae84828501610175565b91505092915050565b60008115159050919050565b6101cc816101b7565b82525050565b60006020820190506101e760008301846101c3565b9291505056fea2646970667358221220802ddeb5e1ebf18b9b6352883513405c7dad64e00e6fe3584691af2ab637ed8c64736f6c63430008130033
+\ No newline at end of file
diff --git a/python/tests/testdata/Supports.sol b/python/tests/testdata/Supports.sol
@@ -2,6 +2,9 @@ pragma solidity ^0.8.0;
contract Supports {
function supportsInterface(bytes4 _sum) public pure returns (bool) {
+ if (_sum == 0x01ffc9a7) {
+ return true;
+ }
if (_sum == 0xdeadbeef) {
return true;
}
diff --git a/solidity/Interface.sol b/solidity/Interface.sol
@@ -17,7 +17,7 @@ contract InterfaceCheckSample {
interfaceN = uint32(interfaceID);
// EIP165 interface id
- if (uint32(interfaceID) == 0x01ffc9a7) {
+ if (uint32(interfaceID) == 0x01ffc9a7) {
return true;
}