From 2dcb8276831da96dd187bf1d0ced9c29493832ca Mon Sep 17 00:00:00 2001 From: Chris Cushman <104409744+vreff@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:33:26 -0400 Subject: [PATCH] [VRF-618] Fix VRFV2Plus tests with blockhash update (#10705) * [VRF-618] Fix VRFV2Plus tests with blockhash update * prettier --- .../test/v0.8/foundry/vrf/VRFV2Plus.t.sol | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol b/contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol index 2bfedcc8c1f..80a94730ffe 100644 --- a/contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol +++ b/contracts/test/v0.8/foundry/vrf/VRFV2Plus.t.sol @@ -99,8 +99,7 @@ contract VRFV2Plus is BaseTest { ); } - // TODO: Fix this test after make foundry-refresh (JIRA ticket VRF-618) - function skipped_testSetConfig() public { + function testSetConfig() public { // Should setConfig successfully. setConfig(basicFeeConfig); (uint16 minConfs, uint32 gasLimit, ) = s_testCoordinator.getRequestConfig(); @@ -116,8 +115,7 @@ contract VRFV2Plus is BaseTest { s_testCoordinator.setConfig(0, 2_500_000, 1, 50_000, 0, basicFeeConfig); } - // TODO: Fix this test after make foundry-refresh - function skipped_testRegisterProvingKey() public { + function testRegisterProvingKey() public { // Should set the proving key successfully. registerProvingKey(); (, , bytes32[] memory keyHashes) = s_testCoordinator.getRequestConfig(); @@ -241,8 +239,7 @@ contract VRFV2Plus is BaseTest { bool success ); - // TODO: Fix this test after make foundry-refresh (JIRA ticket VRF-618) - function skipped_testRequestAndFulfillRandomWordsNative() public { + function testRequestAndFulfillRandomWordsNative() public { uint32 requestBlock = 10; vm.roll(requestBlock); s_testConsumer.createSubscriptionAndFund(0); @@ -285,15 +282,15 @@ contract VRFV2Plus is BaseTest { // Store the previous block's blockhash, and assert that it is as expected. vm.roll(requestBlock + 1); s_bhs.store(requestBlock); - assertEq(hex"c65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8", s_bhs.getBlockhash(requestBlock)); + assertEq(bytes32(uint256(requestBlock)), s_bhs.getBlockhash(requestBlock)); // Fulfill the request. // Proof generated via the generate-proof-v2-plus script command. Example usage: /* go run . generate-proof-v2-plus \ -key-hash 0x9f2353bde94264dbc3d554a94cceba2d7d2b4fdce4304d3e09a1fea9fbeb1528 \ - -pre-seed 53391429126065232382402681707515137895470547057819816488254124798726362946635 \ - -block-hash 0xc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8 \ + -pre-seed 93724884573574303181157854277074121673523280784530506403108144933983063023487 \ + -block-hash 0x000000000000000000000000000000000000000000000000000000000000000a \ -block-num 10 \ -sender 0x90A8820424CC8a819d14cBdE54D12fD3fbFa9bb2 \ -native-payment true @@ -304,22 +301,22 @@ contract VRFV2Plus is BaseTest { 62070622898698443831883535403436258712770888294397026493185421712108624767191 ], gamma: [ - 2973102176083872659982988645522968133664529102555885971868619302367987919116, - 43610558806647181042154132372309425100765955827430056035281841579494767100593 + 51111463251706978184511913295560024261167135799300172382907308330135472647507, + 41885656274025752055847945432737871864088659248922821023734315208027501951872 ], - c: 75194344641067036522826220229162084868390366816380211563792760218107272249498, - s: 108927968992343929608833704938910483045052376946991907425266794689988418576748, - seed: 53391429126065232382402681707515137895470547057819816488254124798726362946635, - uWitness: 0x2fF1135666317726951c76126c8723d85CFD9F32, + c: 16524568342669389118511849307228542933779732546262509461687493305210182275018, + s: 41994650358817457338836417117109954917585544148583960677058620868924739846555, + seed: 93724884573574303181157854277074121673523280784530506403108144933983063023487, + uWitness: 0x239F36bb6F40B875feDB78A35668ED503714229D, cGammaWitness: [ - 46085870527299320975519920659984209079990358705974909475473962711525316439739, - 95523996389945915706780830430209540746261656800207800796591631955877527338163 + 39509254444382483930263995092200486700241035538419529811079167788988152938775, + 45386456067856204990374891906500133027941582609057652148999284389995660222714 ], sHashWitness: [ - 33452562099427047562641801544992972552164940262753954784240667763204805691450, - 60260251393131215964980682331539706583150315372000173687277509360968942328689 + 111625720767470372476405191521859549066251564741183518661578940869038469627728, + 102482035245447833089088394562631090129269030797203395897444301192092668485625 ], - zInv: 90963680785087352218671937531239943963498221959522740883795298137227163523089 + zInv: 46854489406365983023053639507653417780777725139199393583659574012051139260916 }); VRFCoordinatorV2Plus.RequestCommitment memory rc = VRFCoordinatorV2Plus.RequestCommitment({ blockNum: requestBlock, @@ -359,8 +356,7 @@ contract VRFV2Plus is BaseTest { assertApproxEqAbs(ethBalanceAfter, ethBalanceBefore - 120_000, 10_000); } - // TODO: Fix this test after make foundry-refresh (JIRA ticket VRF-618) - function skipped_testRequestAndFulfillRandomWordsLINK() public { + function testRequestAndFulfillRandomWordsLINK() public { uint32 requestBlock = 20; vm.roll(requestBlock); s_linkToken.transfer(address(s_testConsumer), 10 ether); @@ -403,15 +399,15 @@ contract VRFV2Plus is BaseTest { // Store the previous block's blockhash, and assert that it is as expected. vm.roll(requestBlock + 1); s_bhs.store(requestBlock); - assertEq(hex"ce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec", s_bhs.getBlockhash(requestBlock)); + assertEq(bytes32(uint256(requestBlock)), s_bhs.getBlockhash(requestBlock)); // Fulfill the request. // Proof generated via the generate-proof-v2-plus script command. Example usage: /* go run . generate-proof-v2-plus \ -key-hash 0x9f2353bde94264dbc3d554a94cceba2d7d2b4fdce4304d3e09a1fea9fbeb1528 \ - -pre-seed 14817911724325909152780695848148728017190840227899344848185245004944693487904 \ - -block-hash 0xce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec \ + -pre-seed 108233140904510496268355288815996296196427471042093167619305836589216327096601 \ + -block-hash 0x0000000000000000000000000000000000000000000000000000000000000014 \ -block-num 20 \ -sender 0x90A8820424CC8a819d14cBdE54D12fD3fbFa9bb2 */ @@ -421,22 +417,22 @@ contract VRFV2Plus is BaseTest { 62070622898698443831883535403436258712770888294397026493185421712108624767191 ], gamma: [ - 33866404953216897461413961842321788789902210776565180957857448351149268461878, - 115311460432520855364215812517921508651759645277579047898967111537639679255245 + 49785247270467418393187938018746488660500261614113251546613288843777654841004, + 8320717868018488740308781441198484312662094766876176838868269181386589318272 ], - c: 98175725525459014587207855195868784126328401309203602128167819356654355538256, - s: 78212468144318845248263931834872020573314019987337100119712622816610913379348, - seed: 14817911724325909152780695848148728017190840227899344848185245004944693487904, - uWitness: 0xA98F604595c018ca3A897a89A93335C4D9736200, + c: 76453805415479914665188560136648688491255275134351022531196270897692316685243, + s: 22475315809542512110111038532919582593833813393763591614796010376988981373422, + seed: 108233140904510496268355288815996296196427471042093167619305836589216327096601, + uWitness: 0x5FEaCA3fb4754440E6a2A9954FC9239C598575D6, cGammaWitness: [ - 89663557576172659880527012694290366148297911460143038889658956042430644586923, - 29419553942575420255373719124720052624389851192491471135797878382964991183413 + 55445396003779478156538753672495726993840482493921680192868130506843942678541, + 106319974075683500018668841039963899149060186085112051787355016812064025102025 ], sHashWitness: [ - 108049980454753981965039838334334363963059423646097861676439703242702207924520, - 30630879728902862732102533191211056668896962900771600171010644651087695869520 + 34533061775486739812426491689767238316751877347882380297143821485918957938090, + 2922713080913931101723342979079557154957284247074698150345640807351459691338 ], - zInv: 20922890987701239032692501385659950984080522095093996771712575172616647361477 + zInv: 5351690486803355464662962731889988792533544566214255216629618109252893229562 }); VRFCoordinatorV2Plus.RequestCommitment memory rc = VRFCoordinatorV2Plus.RequestCommitment({ blockNum: requestBlock,