@@ -92,8 +92,10 @@ const SIGNATURES = {
92
92
93
93
const INTERFACE_IDS = mapValues ( SIGNATURES , interfaceId ) ;
94
94
95
- function shouldSupportInterfaces ( interfaces = [ ] ) {
95
+ function shouldSupportInterfaces ( interfaces = [ ] , signatures = SIGNATURES ) {
96
96
interfaces . unshift ( 'ERC165' ) ;
97
+ signatures . ERC165 = SIGNATURES . ERC165 ;
98
+ const interfaceIds = mapValues ( signatures , interfaceId , ( [ name ] ) => interfaces . includes ( name ) ) ;
97
99
98
100
describe ( 'ERC165' , function ( ) {
99
101
beforeEach ( function ( ) {
@@ -103,14 +105,14 @@ function shouldSupportInterfaces(interfaces = []) {
103
105
describe ( 'when the interfaceId is supported' , function ( ) {
104
106
it ( 'uses less than 30k gas' , async function ( ) {
105
107
for ( const k of interfaces ) {
106
- const interfaceId = INTERFACE_IDS [ k ] ?? k ;
108
+ const interfaceId = interfaceIds [ k ] ?? k ;
107
109
expect ( await this . contractUnderTest . supportsInterface . estimateGas ( interfaceId ) ) . to . lte ( 30_000n ) ;
108
110
}
109
111
} ) ;
110
112
111
113
it ( 'returns true' , async function ( ) {
112
114
for ( const k of interfaces ) {
113
- const interfaceId = INTERFACE_IDS [ k ] ?? k ;
115
+ const interfaceId = interfaceIds [ k ] ?? k ;
114
116
expect ( await this . contractUnderTest . supportsInterface ( interfaceId ) , `does not support ${ k } ` ) . to . be . true ;
115
117
}
116
118
} ) ;
@@ -129,10 +131,10 @@ function shouldSupportInterfaces(interfaces = []) {
129
131
it ( 'all interface functions are in ABI' , async function ( ) {
130
132
for ( const k of interfaces ) {
131
133
// skip interfaces for which we don't have a function list
132
- if ( SIGNATURES [ k ] === undefined ) continue ;
134
+ if ( signatures [ k ] === undefined ) continue ;
133
135
134
136
// Check the presence of each function in the contract's interface
135
- for ( const fnSig of SIGNATURES [ k ] ) {
137
+ for ( const fnSig of signatures [ k ] ) {
136
138
expect ( this . contractUnderTest . interface . hasFunction ( fnSig ) , `did not find ${ fnSig } ` ) . to . be . true ;
137
139
}
138
140
}
@@ -141,5 +143,7 @@ function shouldSupportInterfaces(interfaces = []) {
141
143
}
142
144
143
145
module . exports = {
146
+ SIGNATURES ,
147
+ INTERFACE_IDS ,
144
148
shouldSupportInterfaces,
145
149
} ;
0 commit comments