Skip to content

Commit

Permalink
VRF-1102: disable tests and checks depending on network type (Simulat… (
Browse files Browse the repository at this point in the history
#13290)

* VRF-1102: disable tests and checks depending on network type (Simulated or live testnet)

* VRF-1102: fixing tests
  • Loading branch information
iljapavlovs committed May 22, 2024
1 parent eb6b50d commit 087e2a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
27 changes: 16 additions & 11 deletions integration-tests/smoke/vrfv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,11 @@ func TestVRFV2NodeReorg(t *testing.T) {
config, err := tc.GetConfig("Smoke", tc.VRFv2)
require.NoError(t, err, "Error getting config")
vrfv2Config := config.VRFv2
chainID := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0].ChainID

network := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0]
if !network.Simulated {
t.Skip("Skipped since Reorg test could only be run on Simulated chain.")
}
chainID := network.ChainID
cleanupFn := func() {
sethClient, err := env.GetSethClient(chainID)
require.NoError(t, err, "Getting Seth client shouldn't fail")
Expand Down Expand Up @@ -1236,8 +1239,8 @@ func TestVRFv2BatchFulfillmentEnabledDisabled(t *testing.T) {
config, err := tc.GetConfig("Smoke", tc.VRFv2)
require.NoError(t, err, "Error getting config")
vrfv2Config := config.VRFv2
chainID := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0].ChainID

network := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0]
chainID := network.ChainID
cleanupFn := func() {
sethClient, err := env.GetSethClient(chainID)
require.NoError(t, err, "Getting Seth client shouldn't fail")
Expand Down Expand Up @@ -1395,14 +1398,16 @@ func TestVRFv2BatchFulfillmentEnabledDisabled(t *testing.T) {
// verify that VRF node sends fulfillments via BatchCoordinator contract
require.Equal(t, vrfContracts.BatchCoordinatorV2.Address(), fulfillmentTXToAddress, "Fulfillment Tx To Address should be the BatchCoordinatorV2 Address when batch fulfillment is enabled")

fulfillmentTxReceipt, err := sethClient.Client.TransactionReceipt(testcontext.Get(t), fulfillmentTx.Hash())
require.NoError(t, err)

randomWordsFulfilledLogs, err := contracts.ParseRandomWordsFulfilledLogs(vrfContracts.CoordinatorV2, fulfillmentTxReceipt.Logs)
require.NoError(t, err)

// verify that all fulfillments should be inside one tx
require.Equal(t, int(randRequestCount), len(randomWordsFulfilledLogs))
// This check is disabled for live testnets since each testnet has different gas usage for similar tx
if network.Simulated {
fulfillmentTxReceipt, err := sethClient.Client.TransactionReceipt(testcontext.Get(t), fulfillmentTx.Hash())
require.NoError(t, err)
randomWordsFulfilledLogs, err := contracts.ParseRandomWordsFulfilledLogs(vrfContracts.CoordinatorV2, fulfillmentTxReceipt.Logs)
require.NoError(t, err)
require.Equal(t, 1, len(batchFulfillmentTxs))
require.Equal(t, int(randRequestCount), len(randomWordsFulfilledLogs))
}
})
t.Run("Batch Fulfillment Disabled", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
Expand Down
30 changes: 16 additions & 14 deletions integration-tests/smoke/vrfv2plus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1956,8 +1956,11 @@ func TestVRFv2PlusNodeReorg(t *testing.T) {
config, err := tc.GetConfig("Smoke", tc.VRFv2Plus)
require.NoError(t, err, "Error getting config")
vrfv2PlusConfig := config.VRFv2Plus
chainID := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0].ChainID

network := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0]
if !network.Simulated {
t.Skip("Skipped since Reorg test could only be run on Simulated chain.")
}
chainID := network.ChainID
cleanupFn := func() {
sethClient, err := env.GetSethClient(chainID)
require.NoError(t, err, "Getting Seth client shouldn't fail")
Expand Down Expand Up @@ -2136,8 +2139,8 @@ func TestVRFv2PlusBatchFulfillmentEnabledDisabled(t *testing.T) {
config, err := tc.GetConfig("Smoke", tc.VRFv2Plus)
require.NoError(t, err, "Error getting config")
vrfv2PlusConfig := config.VRFv2Plus
chainID := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0].ChainID

network := networks.MustGetSelectedNetworkConfig(config.GetNetworkConfig())[0]
chainID := network.ChainID
cleanupFn := func() {
sethClient, err := env.GetSethClient(chainID)
require.NoError(t, err, "Getting Seth client shouldn't fail")
Expand Down Expand Up @@ -2277,9 +2280,6 @@ func TestVRFv2PlusBatchFulfillmentEnabledDisabled(t *testing.T) {
batchFulfillmentTxs = append(batchFulfillmentTxs, tx)
}
}
// verify that all fulfillments should be inside one tx
require.Equal(t, 1, len(batchFulfillmentTxs))

fulfillmentTx, _, err := sethClient.Client.TransactionByHash(testcontext.Get(t), randomWordsFulfilledEvent.Raw.TxHash)
require.NoError(t, err, "error getting tx from hash")

Expand All @@ -2292,14 +2292,16 @@ func TestVRFv2PlusBatchFulfillmentEnabledDisabled(t *testing.T) {
// verify that VRF node sends fulfillments via BatchCoordinator contract
require.Equal(t, vrfContracts.BatchCoordinatorV2Plus.Address(), fulfillmentTXToAddress, "Fulfillment Tx To Address should be the BatchCoordinatorV2Plus Address when batch fulfillment is enabled")

fulfillmentTxReceipt, err := sethClient.Client.TransactionReceipt(testcontext.Get(t), fulfillmentTx.Hash())
require.NoError(t, err)

randomWordsFulfilledLogs, err := contracts.ParseRandomWordsFulfilledLogs(vrfContracts.CoordinatorV2Plus, fulfillmentTxReceipt.Logs)
require.NoError(t, err)

// verify that all fulfillments should be inside one tx
require.Equal(t, int(randRequestCount), len(randomWordsFulfilledLogs))
// This check is disabled for live testnets since each testnet has different gas usage for similar tx
if network.Simulated {
fulfillmentTxReceipt, err := sethClient.Client.TransactionReceipt(testcontext.Get(t), fulfillmentTx.Hash())
require.NoError(t, err)
randomWordsFulfilledLogs, err := contracts.ParseRandomWordsFulfilledLogs(vrfContracts.CoordinatorV2Plus, fulfillmentTxReceipt.Logs)
require.NoError(t, err)
require.Equal(t, 1, len(batchFulfillmentTxs))
require.Equal(t, int(randRequestCount), len(randomWordsFulfilledLogs))
}
})
t.Run("Batch Fulfillment Disabled", func(t *testing.T) {
configCopy := config.MustCopy().(tc.TestConfig)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/testconfig/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ gas_fee_cap = 30_000_000_000
gas_tip_cap = 1_000_000_000

# how many last blocks to use, when estimating gas for a transaction
gas_price_estimation_blocks = 50
gas_price_estimation_blocks = 30
# priority of the transaction, can be "fast", "standard" or "slow" (the higher the priority, the higher adjustment factor will be used for gas estimation) [default: "standard"]
gas_price_estimation_tx_priority = "standard"

Expand Down

0 comments on commit 087e2a7

Please sign in to comment.