Skip to content

Commit 70a292c

Browse files
committed
VRF-330: fixing tests
1 parent 6c9bd20 commit 70a292c

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

integration-tests/actions/vrf/vrfv2plus/setup_steps.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ func CreateVRFV2PlusJob(
4343
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, vrfcommon.ErrParseJob, err)
4444
}
4545

46-
job, err := chainlinkNode.MustCreateJob(&client.VRFV2PlusJobSpec{
46+
jobSpec := client.VRFV2PlusJobSpec{
4747
Name: fmt.Sprintf("vrf-v2-plus-%s", jobUUID),
4848
CoordinatorAddress: vrfJobSpecConfig.CoordinatorAddress,
49-
BatchCoordinatorAddress: vrfJobSpecConfig.BatchCoordinatorAddress,
5049
FromAddresses: vrfJobSpecConfig.FromAddresses,
5150
EVMChainID: vrfJobSpecConfig.EVMChainID,
5251
MinIncomingConfirmations: vrfJobSpecConfig.MinIncomingConfirmations,
@@ -57,7 +56,13 @@ func CreateVRFV2PlusJob(
5756
BatchFulfillmentGasMultiplier: vrfJobSpecConfig.BatchFulfillmentGasMultiplier,
5857
PollPeriod: vrfJobSpecConfig.PollPeriod,
5958
RequestTimeout: vrfJobSpecConfig.RequestTimeout,
60-
})
59+
}
60+
61+
if vrfJobSpecConfig.BatchFulfillmentEnabled {
62+
jobSpec.BatchCoordinatorAddress = vrfJobSpecConfig.BatchCoordinatorAddress
63+
}
64+
65+
job, err := chainlinkNode.MustCreateJob(&jobSpec)
6166
if err != nil {
6267
return nil, fmt.Errorf(vrfcommon.ErrGenericFormat, ErrCreatingVRFv2PlusJob, err)
6368
}

integration-tests/smoke/vrfv2plus_test.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ func TestVRFv2Plus(t *testing.T) {
258258
vrfcommon.LogSubDetails(l, subscription, subID.String(), vrfContracts.CoordinatorV2Plus)
259259
subIDsForCancellingAfterTest = append(subIDsForCancellingAfterTest, subIDs...)
260260

261-
randRequestCount := 3
262-
263-
configCopy.VRFv2Plus.General.CallbackGasLimit = ptr.Ptr(uint32(1_000_000))
261+
//batchMaxGas := config.MaxGasLimit() (2.5 mill) + 400_000 = 2.9 mill
262+
//callback gas limit set by consumer = 500k
263+
// so 4 requests should be fulfilled inside 1 tx since 500k*4 < 2.9 mill
264+
randRequestCount := 4
265+
configCopy.VRFv2Plus.General.CallbackGasLimit = ptr.Ptr(uint32(500_000))
264266
configCopy.VRFv2Plus.General.RandomnessRequestCountPerRequest = ptr.Ptr(uint16(randRequestCount))
265267

266268
// test and assert
@@ -288,6 +290,7 @@ func TestVRFv2Plus(t *testing.T) {
288290
Str("BatchCoordinatorV2Plus Address", vrfContracts.BatchCoordinatorV2Plus.Address()).
289291
Msg("Fulfillment Tx To Address should be the BatchCoordinatorV2Plus Address when batch fulfillment is enabled")
290292

293+
// verify that VRF node sends fulfillments via BatchCoordinator contract
291294
require.Equal(t, vrfContracts.BatchCoordinatorV2Plus.Address(), fulfillmentTXToAddress, "Fulfillment Tx To Address should be the BatchCoordinatorV2Plus Address when batch fulfillment is enabled")
292295

293296
fulfillmentTxReceipt, err := evmClient.GetTxReceipt(fulfillmentTx.Hash())
@@ -296,7 +299,8 @@ func TestVRFv2Plus(t *testing.T) {
296299
randomWordsFulfilledLogs, err := contracts.ParseRandomWordsFulfilledLogs(vrfContracts.CoordinatorV2Plus, fulfillmentTxReceipt.Logs)
297300
require.NoError(t, err)
298301

299-
require.Equal(t, int(*configCopy.VRFv2Plus.General.RandomnessRequestCountPerRequest), len(randomWordsFulfilledLogs))
302+
// verify that all fulfillments should be inside one tx
303+
require.Equal(t, randRequestCount, len(randomWordsFulfilledLogs))
300304

301305
})
302306

0 commit comments

Comments
 (0)