-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avm): initial external calls (#4194)
- Loading branch information
Showing
26 changed files
with
621 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
yarn-project/acir-simulator/src/avm/avm_execution_environment.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Fr } from '@aztec/foundation/fields'; | ||
|
||
import { initExecutionEnvironment } from './fixtures/index.js'; | ||
|
||
describe('Execution Environment', () => { | ||
const newAddress = new Fr(123456n); | ||
const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; | ||
|
||
it('New call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
storageAddress: newAddress, | ||
calldata, | ||
}); | ||
}); | ||
|
||
it('New delegate call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newDelegateCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
isDelegateCall: true, | ||
calldata, | ||
}); | ||
}); | ||
|
||
it('New static call call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newStaticCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
storageAddress: newAddress, | ||
isStaticCall: true, | ||
calldata, | ||
}); | ||
}); | ||
}); | ||
|
||
/** | ||
* Check all properties of one object are the same, except for the specified differentProperties | ||
*/ | ||
function allTheSameExcept(referenceObject: any, comparingObject: any, differentProperties: Record<string, any>): void { | ||
for (const key in referenceObject) { | ||
if (Object.keys(differentProperties).includes(key)) { | ||
expect(comparingObject[key]).toEqual(differentProperties[key]); | ||
} else { | ||
expect(comparingObject[key]).toEqual(referenceObject[key]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.