@@ -520,6 +520,40 @@ describe('Private Execution test suite', () => {
520520 } ) ;
521521 } ) ;
522522
523+ it ( 'throws when request origin does not match contract address' , async ( ) => {
524+ const contractAddress = await mockContractInstance ( TestContractArtifact ) ;
525+ const differentAddress = await AztecAddress . random ( ) ;
526+ contracts [ differentAddress . toString ( ) ] = TestContractArtifact ;
527+
528+ const functionArtifact = getFunctionArtifactByName ( TestContractArtifact , 'emit_array_as_encrypted_log' ) ;
529+ const selector = await FunctionSelector . fromNameAndParameters ( functionArtifact . name , functionArtifact . parameters ) ;
530+ const hashedArguments = await HashedValues . fromArgs (
531+ encodeArguments ( functionArtifact , [ Fr . ZERO , times ( 5 , ( ) => Fr . random ( ) ) , owner , false ] ) ,
532+ ) ;
533+
534+ const txRequest = TxExecutionRequest . from ( {
535+ origin : differentAddress ,
536+ firstCallArgsHash : hashedArguments . hash ,
537+ functionSelector : selector ,
538+ txContext : TxContext . from ( txContextFields ) ,
539+ argsOfCalls : [ hashedArguments ] ,
540+ authWitnesses : [ ] ,
541+ capsules : [ ] ,
542+ salt : Fr . random ( ) ,
543+ } ) ;
544+
545+ await expect (
546+ acirSimulator . run ( txRequest , {
547+ contractAddress,
548+ selector,
549+ anchorBlockHeader,
550+ senderForTags,
551+ jobId : TEST_JOB_ID ,
552+ scopes : [ owner ] ,
553+ } ) ,
554+ ) . rejects . toThrow ( 'Request origin does not match contract address' ) ;
555+ } ) ;
556+
523557 describe ( 'stateful test contract' , ( ) => {
524558 let contractAddress : AztecAddress ;
525559 const mockFirstNullifier = new Fr ( 1111 ) ;
0 commit comments