@@ -8,7 +8,7 @@ import { AztecLMDBStoreV2, openTmpStore } from '@aztec/kv-store/lmdb-v2';
88import { TestContractArtifact } from '@aztec/noir-test-contracts.js/Test' ;
99import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle' ;
1010import { WASMSimulator } from '@aztec/simulator/client' ;
11- import { EventSelector } from '@aztec/stdlib/abi' ;
11+ import { EventSelector , FunctionType } from '@aztec/stdlib/abi' ;
1212import { AztecAddress } from '@aztec/stdlib/aztec-address' ;
1313import { BlockHash , GENESIS_CHECKPOINT_HEADER_HASH } from '@aztec/stdlib/block' ;
1414import { getContractClassFromArtifact } from '@aztec/stdlib/contract' ;
@@ -163,6 +163,40 @@ describe('PXE', () => {
163163 await expect ( pxe . registerContract ( { instance, artifact } ) ) . rejects . toThrow ( / A r t i f a c t d o e s n o t m a t c h / i) ;
164164 } ) ;
165165
166+ it ( 'does not call registerContractFunctionSignatures for contracts without public functions' , async ( ) => {
167+ const { artifact, instance } = await randomDeployedContract ( ) ;
168+ node . registerContractFunctionSignatures . mockClear ( ) ;
169+
170+ await pxe . registerContract ( { artifact, instance } ) ;
171+
172+ expect ( node . registerContractFunctionSignatures ) . not . toHaveBeenCalled ( ) ;
173+ } ) ;
174+
175+ it ( 'calls registerContractFunctionSignatures for contracts with public functions' , async ( ) => {
176+ const artifact = randomContractArtifact ( ) ;
177+ artifact . functions = [
178+ {
179+ name : 'my_public_fn' ,
180+ functionType : FunctionType . PUBLIC ,
181+ isOnlySelf : false ,
182+ isStatic : false ,
183+ isInitializer : false ,
184+ parameters : [ ] ,
185+ returnTypes : [ ] ,
186+ errorTypes : { } ,
187+ bytecode : Buffer . from ( '' ) ,
188+ debugSymbols : '' ,
189+ } ,
190+ ] ;
191+ const contractClass = await getContractClassFromArtifact ( artifact ) ;
192+ const instance = await randomContractInstanceWithAddress ( { contractClassId : contractClass . id } ) ;
193+ node . registerContractFunctionSignatures . mockClear ( ) ;
194+
195+ await pxe . registerContract ( { artifact, instance } ) ;
196+
197+ expect ( node . registerContractFunctionSignatures ) . toHaveBeenCalledWith ( [ 'my_public_fn()' ] ) ;
198+ } ) ;
199+
166200 // These tests are meant to quickly exercise PXE as a
167201 // frontier API so we don't need to rely on slower E2E
168202 // tests (which in turn are more meaningful for acceptance).
0 commit comments