Skip to content

Commit

Permalink
test: Use chain_id and version in nested test
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Jun 27, 2023
1 parent 8a9d3f6 commit 6be0410
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
12 changes: 7 additions & 5 deletions yarn-project/acir-simulator/src/client/private_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Private Execution test suite', () => {

const historicRoots = PrivateHistoricTreeRoots.empty();
const contractDeploymentData = ContractDeploymentData.empty();
const txContext = new TxContext(false, false, false, contractDeploymentData, Fr.ZERO, Fr.ZERO);
const txContext = new TxContext(false, false, false, contractDeploymentData, new Fr(69), new Fr(420));

const buildTxExecutionRequest = (args: {
abi: FunctionAbi;
Expand Down Expand Up @@ -303,9 +303,11 @@ describe('Private Execution test suite', () => {
});

describe('nested calls', () => {
const privateIncrement = txContext.chainId.value + txContext.version.value;
it('child function should be callable', async () => {
const initialValue = 100n;
const abi = ChildAbi.functions.find(f => f.name === 'value')!;
const txRequest = buildTxExecutionRequest({ args: [100n], abi });
const txRequest = buildTxExecutionRequest({ args: [initialValue], abi });
const result = await acirSimulator.run(
txRequest,
abi,
Expand All @@ -315,7 +317,7 @@ describe('Private Execution test suite', () => {
await Grumpkin.new(),
);

expect(result.callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(142n));
expect(result.callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(initialValue + privateIncrement));
});

it('parent should call child', async () => {
Expand All @@ -342,11 +344,11 @@ describe('Private Execution test suite', () => {
await Grumpkin.new(),
);

expect(result.callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(42n));
expect(result.callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(privateIncrement));
expect(oracle.getFunctionABI.mock.calls[0]).toEqual([childAddress, childSelector]);
expect(oracle.getPortalContractAddress.mock.calls[0]).toEqual([childAddress]);
expect(result.nestedExecutions).toHaveLength(1);
expect(result.nestedExecutions[0].callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(42n));
expect(result.nestedExecutions[0].callStackItem.publicInputs.returnValues[0]).toEqual(new Fr(privateIncrement));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Child {
let mut context = PrivateFunctionContext::new();
context.args = context.args.push(input);

context.return_values = context.return_values.push(input + 42);
context.return_values = context.return_values.push(input + inputs.private_global_variables.chain_id + inputs.private_global_variables.version);

context.finish(inputs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
}
],
"returnTypes": [],
"bytecode": "cdd7494edb6000c5f1a4053ab7ccf35866c2e031b1193390843184308519db710035a512a552b7b901985ea152d5550fc205907216d44feaaa426293b77896deeadbfc7fb617f68fb3922f5bfc132d58cea7e897ef896f174ecc2a148a3f339154327ee355f89f38ac7ceab0ca5ffc1db93cbf3afbec5e9d3bb7d737de7d5895829ae686145756654b524cdbd0254db783866cc8baa1e71443555d433342a66d862453d65457ceeba69a97fe5db5f761a9cc0b1f55c71855cf18d5c018d5c818d5c418d5cc18d5c218d5ca18d5c618d5ce18d5c118d5c918d5c518d50d887afc5df32bede6dccbafeec56dc957edd5dc3d78b5627562f5620d628d624d62cd622d62ad626d62ed621d629d625d62dd770f3eafe7e3ff70cf2bbb5aae01dcbcde7233140bff44fb185fb37ec6a801c6a841c6a821c6a861c6a811c6a80063d42863d41863d43863d4046394c418253346298c512a6394c618a533460519a3428c51066394c91835c91835c518358d8e42fc65fb01b01946d833006c9611f61c009b638455006061465825001661845501605146580f00166384f50260f38cb03e002cce08eb07c0128cb001002cc9081b04c01618614300d822236c18005b62848d0060cb8cb00000b6c2081b05c05619616300588a11360e80ad31c22600b034234c02c0d6196132009661842900d806234c05c03619611a00b6c508d301b06d46581000db61848500b02c23cc00c07619612600b6c7089b04c0f619615300d801236c1a003b6484bd00c08e18612f01b06346d82b00ec8411f61a00b318616f00309b11f61600731861ef00b01c23ec3d00e632c23e00607946583500765a3eecbae40bccccce8523d1d87c3c915c585c5a5e594dada5d7331b9b5bdb3bd9ddbdfd83c3a3e313cb76726efef42f",
"bytecode": "cdd8d94e1a6100c57168d5ee15f77d6bdd7199616660c69545c0151157dc9961b0b4d426d626bde50d74e82b34697ad507f1054c7816d32ff1ca9878c3b938939cab49befc7f6448607e7d2ebbd2c57fe142c6fa12fef633f6e3dc8a640a85e2ef5428118f5e3b55ee276e563f75b3c65dfc1bbac85f7efa6a5fe6add2d5b5731b5424bfaada019f2d2b7246f219a6ae49aa66fa755997355dcbfa7445b175550f18a611900c59556c39a7194a4ebabfea6f835285173eaa8131aa9131aa8931aa9931aa8531aa9531aa8d31aa9d31aa8331aa9331aa8b31aa9b31aa8731aa1710f5f877cd9fa49db52fbedbe7a5b2cbe3d4dddc39f5620d628d624d62cd622d62ad626d62ed621d629d625d62dd623d62bd37772ea7efc34378c9a9b85aae059ce1019c91473f15880fa70ef0647d049c9167fccaf433460d30460d32460d31460d33468d30468d32467919a3c618a3c619a32618a32619a324c6289931cac718a53046a98c511a63949f312ac018a53346198c51538c51d38c5133e82807f04fdd0d80cd32c29e0160738cb0e700d83c23ac0a000b32c2aa01b01023ac06000b33c2fa00b008230cf152758111d60f804519610300588c11360880c519614300d822236c18005b62848d0060cb8cb051006c8511e605c05619616300d81a236c1c004b30c22600b07546d824009664844900d806234c06c0528c301f00b6c9085300b02d46980a806d33c234006c8711e607c076196101006c8f11a603606946980180ed33c2a600b00346d8340076c8089b01c08e18612f00b06346d84b00ec8411f60a003b6584bd06c0328cb0370098c9087b0b80598cb07700589611f61e00b31961b500588e11e601c0ce2a875d955dded9b9f960281c5988c6e28b4bcb2bab6b89f5e4466a736b7b67772fbd7f7078747c729a31adac9d3bfb0f",
"verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@
"visibility": "private"
}
],
"returnTypes": [
null
],
"returnTypes": [null],
"bytecode": "cd9d795793d716c60953cfaded37687bb5751e3392c4910022283880f31cc81b8c86242601c1398e9d9b6cb493761451f4ba6a6be7d1ced3e907e8ba7e83cef36c6f52e4220a9b24ef133dacc51fac67adc7b37fd939ef3e278f2b873e33345cc8fb6fec6c99dfddb8a92cd856d912682c77fbfdb1e375aef9736627a8d0c088459c586c889d72857dd10dcd5ad4d7d8114fd0e7a5166389d5aad9cd9ac962721bcdce0687cd68b53594384c0e93cd61f3981d168be6b03aecce06a7dde834592d9ac96b735abcc69e9f5b3e2f35eafbb1e21775abee459907c07872a1e6d1c2112dd0d141b7c88b746bf2d7202fe6d16dff8e9d280bfbfc7e5fd3e144acabde1768f26b3d95e85c86e936dd16c67f56d41cf26bc3e34762c76a83ad64c88b1d2f0f062251ca4be8f78f9dae0c86355f532005a9e374241a0cbb9bb43acded49c4baab3477c8150ebbdb29df90889da9d39a7c91a816ae0e78b43643ef2a0a11ab3853e60bb8c3ed953ecdef59103a5474cce5f1e417c63a6b826e0f1514f5545e5470894051ac736e4b7328f1af9ebff30c9df5d160e87cacbbc217d61aa3be562d7672514b30ead302d1c3989772b8fe223be2f1344c4cbc7cfb88f3cc1e31a28d116f9707fabf593b006fd6e100b62308c005d084396c9f618ab4cfc83bb8f6b9836b9f91b9689f6100b67700da6724a07de070465c2b384378c833fa016741c7ced2318d02101e0df0488b4e965b0fa9d245fa1b00b27d8d1acd6d5fa3b9ed6b94a16fcc23e5c6bcbe059122bbea70e0ec3a267eb46752cb37e47e86fdcfa519765972bfd1fa0db10506ba6a88edff777eefb28a7230d416a786dae42cdb33d41616f7a0282ebc84a4f8d2507b63bfa11673a41aa5bf1f98b7d658c188e338713c274ee0c4899c3889132773e2144e3472a28913cd9c68e1442b27da38b18413ed9ce8e04427274ee5c4699c389d136770e24c4e9cc589a59ce8e2c4324e2ce7c40a4e9ccd89959c38470c386059746c1aa6caa487d9ab6be331cd410c58cfe4703837655b5945af87277b3ab31174cee6f8e862cca6b2b2cb3d8cd9d12947d079f61a1cec1c9956567a8587d39b391d1782ce73d7e6d86bf56652d9cc813cec99d19985a073ee1a5e0ad8d2ad6cfa601ed6f4e9cc40d079fe1a5f9918d3a96c2ae7614c8fce34049d17aec38552e350953986f2b00f4dc789a0f3e275ba6e33739595002ea5ec083a2f5dc7cb48fb609559d3f5b00f4ec786a0f3f275beaa750c549939130fc7c0742c083aaf2870916dbcb23263861e25deabe99810745e55e49adf78796593b3f130f7a7330541e735853e0431f75636315b0f6b1f9d49083aafabf41191e6f5a616661aafcba387ce04049d37724147a7a149be8e307903c1e74d25f9bc8a30790dc1e72d25f9bc8c307905c1e7bc927c5e4498bc84e0f3b6927c9e4798bc80e0f38e927c9e43989c43f07957493e671126cf22f8bca7daf4939c7f4ce310789e41e0795fc9f6790f61f23e82cf074af2790761f22e82cf874af2398f30791bc1e72325f9bc8930790bc1e76325f97c8430f918c1e71325f97c8030f910c1e75315f90c0354361681582ad93d9f204c3e45748fc42660bb17076bb43ab7c7d7d6a14cfafe42def0b1e3c64f983869f294e46dbfc56a2bb13b9c53a74d9f317356a9abacbc6276e59ccf0c794c42a78a8bef5473e25c4e9cc789359c58cb89f3397101272ee4c4459c58c789f59cb898139770e2524e5cc689cb39710527aee4c4559cb89a13d770e25a4e5cc789eb39d1cd890d9cd8c8891e4ed438d1cb894d3908c9790121b926c41efc858a21390f2024a721e87ca96248ae0110926b44d0f94ac590dc7a4048ce8da0f3b58a21b9b58090dc3a049d6f540cc9ad0684e4d620e87cab62486e252024b70a41e73b154372cb0121b915083adfab18925b0a08c92d43d0f941c590dc6240486e0982ce8f2a86e4ea0021b97a049d9f540cc92d0484e41621e8fcac62486e3e2024b70041e7171543723580905c2d82ceaf2a86e4e6024272f310747e53f21ef95784c96f083ebf2bc9e76784c92f083e7f28c9e74784c94f083e7f2ac9e77b84c90f083e7f29c9e75b84c977083e1795e4f335c2e41b049fbf95e4f325c2e42b009fe407802aa6e4aa117cbe80f031a8d840c9970de2628020ca57f23d761161f2370450819280fe4498fc050154a824a0df11267f400015a9b90b15425c8a20888ad544940f71298020ba41454437014aab8240166a765031c4e506480709c563733741627355d573e7d5d4ce5fb070515dfde2254b972d5fb172d5ea356bd7ad7737347a346f131f9bdbc0057a7c9cb891133771a29f139b3931c089414e0c71e2664e0c73628413a39cd8c289ad9cb88513db38b19d13b772e2364edcce893b38712727eee244b99b5563acba8755f7b2ea3e56ddcfaa0758f5600ee273f200203f270f42b6e3312a26e8e43e40844eee87001aab62884eee01a4e8e45e08a0712ae6e8e46e40904ec62080c6ab18a5db0988d2ed82e099a062966e3b204bb7038267a28a61baad8030dd36089e492aa6e9da0069ba76089ec92ac6e95a0171ba2d103c5354ccd3450179ba16081ea38a81ba3020501781e031a998a80b0112759b2178cc2a46ea0280485d1082c7a262a6ce0fc8d43543f058550cd56d0484ea3641f0d8d4bc69b6425c6c1044256a2232435c2c104476351119212e260822879a8826435ca6401039d5443411e232098268aa9a88c6435c2640104d5313d15888cb3808a2e92a26ed7c104063208066a8d943d3212e33208866aa89682ac4651a04d12c351139202e4e08a252351195405cec10442e351195425c5c1044656a229a097199054154ae22a29b01a56d8040ae50b383ca202ee5900eaa503c7077332470b7c1b77193bf39100c6d0e47a22dad5bdadab76edbbe63e72eb95bc6e41eb957ee93fbe501793015bcebf78223be6956dea9b786066b0e567597de55951873b0aabbf5aecaedcdc1aaeed1bb2aa775801859577d95cb6c2ba10b791e92770a9277257fef4efede23688ea04a41b30555082a175426c825a854d02c413305cd10345dd03441530539053904d9059508b209b20ab208320b3209320a9a2268b2a04982260a9a2068bca07182c60a6a12e415a409f2086a14d420c82d68bda07582d60a5a2368b5a05582560a5a2168b9a06582960a5a2268b1a07a41758216095a286881a0f9826a05d5089a2768aea06a415522158d4b85e752f1ba54002f15d14b85f85231bf5410907609da296887a0ed82b609da2aa85d509ba02d825a05b5088a0a8a080a0bda2c282428282820a859905fd026411b05f9046d10c9f7b6bc57de27ef970fc8b84c48921df2903c2c1f940fc987e523f25179441e958fc9c7e513f249f9947c5a1e939df2b8ec9227e449d92d4fc9d37ddf819ee8fbcaf1a46f6af332e97bd5e5bd3d3ba02e1b795fef36aac346dedfb717676d231fb87c43cfd246c6fb3f15b2b291573d5ab2b09174f5f329631b39e04890a18d3c34f09332231b7978b0c76d0636f2c1c19fd969dbc887b8077f9a36f2617e7a48cb463e32d40892868d7c74e83966481b79249d6168081b7934bd898ab5918fa53b963136f2f1f467bb416de413990c8883d8c827339b3207b4914f653aaa0e60239fce7cdebdca461ecb6668bec24676663779f7b391c7b31ddf2fb3915dd99f01fe6f234fe839485cb29127f59d46feb191dd7a8f34491b790af1ff3e4feb3f18c5e34763c76a83ad943cf51c2f0f062251ca4b00ce83a72b8361cdd714480db91de71ac39a3baad59893274353ad1689b89bb444acbb4a73875ce1b0bb9df20d89d8993aadc917896ae1ea80476b33f4aea610b19a3365be803bdc5ee9d3fc9e05a14345c75c1e4f7e61acb326e8f65041514effadaed99b5bdcfe484161ac6b6e4b73a8da4b4537762e0ebb43b1ced4df89619df5d160a8231ed7df10f1f8ff00",
"verificationKey": "0000000200000800000000740000000f00000003515f3109623eb3c25aa5b16a1a79fd558bac7a7ce62c4560a8c537c77ce80dd339128d1d37b6582ee9e6df9567efb64313471dfa18f520f9ce53161b50dbf7731bc5f900000003515f322bc4cce83a486a92c92fd59bd84e0f92595baa639fc2ed86b00ffa0dfded2a092a669a3bdb7a273a015eda494457cc7ed5236f26cee330c290d45a33b9daa94800000003515f332729426c008c085a81bd34d8ef12dd31e80130339ef99d50013a89e4558eee6d0fa4ffe2ee7b7b62eb92608b2251ac31396a718f9b34978888789042b790a30100000003515f342be6b6824a913eb7a57b03cb1ee7bfb4de02f2f65fe8a4e97baa7766ddb353a82a8a25c49dc63778cd9fe96173f12a2bc77f3682f4c4448f98f1df82c75234a100000003515f351f85760d6ab567465aadc2f180af9eae3800e6958fec96aef53fd8a7b195d7c000c6267a0dd5cfc22b3fe804f53e266069c0e36f51885baec1e7e67650c62e170000000c515f41524954484d455449430d9d0f8ece2aa12012fa21e6e5c859e97bd5704e5c122064a66051294bc5e04213f61f54a0ebdf6fee4d4a6ecf693478191de0c2899bcd8e86a636c8d3eff43400000003515f43224a99d02c86336737c8dd5b746c40d2be6aead8393889a76a18d664029096e90f7fe81adcc92a74350eada9622ac453f49ebac24a066a1f83b394df54dfa0130000000c515f46495845445f42415345060e8a013ed289c2f9fd7473b04f6594b138ddb4b4cf6b901622a14088f04b8d2c83ff74fce56e3d5573b99c7b26d85d5046ce0c6559506acb7a675e7713eb3a00000007515f4c4f4749430721a91cb8da4b917e054f72147e1760cfe0ef3d45090ac0f4961d84ec1996961a25e787b26bd8b50b1a99450f77a424a83513c2b33af268cd253b0587ff50c700000003515f4d05dbd8623b8652511e1eb38d38887a69eceb082f807514f09e127237c5213b401b9325b48c6c225968002318095f89d0ef9cf629b2b7f0172e03bc39aacf6ed800000007515f52414e474504b57a3805e41df328f5ca9aefa40fad5917391543b7b65c6476e60b8f72e9ad07c92f3b3e11c8feae96dedc4b14a6226ef3201244f37cfc1ee5b96781f48d2b000000075349474d415f3125001d1954a18571eaa007144c5a567bb0d2be4def08a8be918b8c05e3b27d312c59ed41e09e144eab5de77ca89a2fd783be702a47c951d3112e3de02ce6e47c000000075349474d415f3223994e6a23618e60fa01c449a7ab88378709197e186d48d604bfb6931ffb15ad11c5ec7a0700570f80088fd5198ab5d5c227f2ad2a455a6edeec024156bb7beb000000075349474d415f3300cda5845f23468a13275d18bddae27c6bb189cf9aa95b6a03a0cb6688c7e8d829639b45cf8607c525cc400b55ebf90205f2f378626dc3406cc59b2d1b474fba000000075349474d415f342d299e7928496ea2d37f10b43afd6a80c90a33b483090d18069ffa275eedb2fc2f82121e8de43dc036d99b478b6227ceef34248939987a19011f065d8b5cef5c0000000010000000000000000100000002000000030000000400000005000000060000000700000008000000090000000a0000000b0000000c0000000d0000000e0000000f"
}
Expand Down
Loading

0 comments on commit 6be0410

Please sign in to comment.