vrftesthelpers

package
v2.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WeiPerUnitLink = decimal.RequireFromString("10000000000000000")
)

Functions

func CreateAndStartBHSJob

func CreateAndStartBHSJob(
	t *testing.T,
	fromAddresses []string,
	app *cltest.TestApplication,
	bhsAddress, coordinatorV1Address, coordinatorV2Address, coordinatorV2PlusAddress string,
	trustedBlockhashStoreAddress string, trustedBlockhashStoreBatchSize int32, lookback int,
	heartbeatPeriod time.Duration, waitBlocks int,
) job.Job

func CreateAndStartBlockHeaderFeederJob

func CreateAndStartBlockHeaderFeederJob(
	t *testing.T,
	fromAddresses []string,
	app *cltest.TestApplication,
	bhsAddress, batchBHSAddress, coordinatorV1Address, coordinatorV2Address, coordinatorV2PlusAddress string,
) job.Job

func NewMaliciousConsumer

func NewMaliciousConsumer(consumer *vrf_malicious_consumer_v2.VRFMaliciousConsumerV2) *vrfConsumerContract

func NewMaliciousConsumerPlus

func NewMaliciousConsumerPlus(consumer *vrf_malicious_consumer_v2_plus.VRFMaliciousConsumerV2Plus) *vrfConsumerContract

func NewRevertingConsumer

func NewRevertingConsumer(consumer *vrfv2_reverting_example.VRFV2RevertingExample) *vrfConsumerContract

func NewRevertingConsumerPlus

func NewRevertingConsumerPlus(consumer *vrfv2plus_reverting_example.VRFV2PlusRevertingExample) *vrfConsumerContract

func NewUpgradeableConsumer

func NewUpgradeableConsumer(consumer *vrf_consumer_v2_upgradeable_example.VRFConsumerV2UpgradeableExample) *vrfConsumerContract

func NewUpgradeableConsumerPlus

func NewUpgradeableConsumerPlus(consumer *vrf_consumer_v2_plus_upgradeable_example.VRFConsumerV2PlusUpgradeableExample) *vrfConsumerContract

func NewVRFConsumerV2

func NewVRFConsumerV2(consumer *vrf_consumer_v2.VRFConsumerV2) *vrfConsumerContract

func NewVRFV2PlusConsumer

func NewVRFV2PlusConsumer(consumer *vrfv2plus_consumer_example.VRFV2PlusConsumerExample) *vrfConsumerContract

Types

type ConsumerType

type ConsumerType string
const (
	VRFConsumerV2           ConsumerType = "VRFConsumerV2"
	VRFV2PlusConsumer       ConsumerType = "VRFV2PlusConsumer"
	MaliciousConsumer       ConsumerType = "MaliciousConsumer"
	MaliciousConsumerPlus   ConsumerType = "MaliciousConsumerPlus"
	RevertingConsumer       ConsumerType = "RevertingConsumer"
	RevertingConsumerPlus   ConsumerType = "RevertingConsumerPlus"
	UpgradeableConsumer     ConsumerType = "UpgradeableConsumer"
	UpgradeableConsumerPlus ConsumerType = "UpgradeableConsumerPlus"
)

type CoordinatorUniverse

type CoordinatorUniverse struct {
	// Golang wrappers ofr solidity contracts
	RootContract               *solidity_vrf_coordinator_interface.VRFCoordinator
	LinkContract               *link_token_interface.LinkToken
	BHSContract                *blockhash_store.BlockhashStore
	ConsumerContract           *solidity_vrf_consumer_interface.VRFConsumer
	RequestIDBase              *solidity_vrf_request_id.VRFRequestIDBaseTestHelper
	ConsumerContractV08        *solidity_vrf_consumer_interface_v08.VRFConsumer
	RequestIDBaseV08           *solidity_vrf_request_id_v08.VRFRequestIDBaseTestHelper
	RootContractAddress        common.Address
	ConsumerContractAddress    common.Address
	ConsumerContractAddressV08 common.Address
	LinkContractAddress        common.Address
	BHSContractAddress         common.Address

	// Abstraction representation of the ethereum blockchain
	Backend        *backends.SimulatedBackend
	CoordinatorABI *abi.ABI
	ConsumerABI    *abi.ABI
	// Cast of participants
	Sergey *bind.TransactOpts // Owns all the LINK initially
	Neil   *bind.TransactOpts // Node operator running VRF service
	Ned    *bind.TransactOpts // Secondary node operator
	Carol  *bind.TransactOpts // Author of consuming contract which requests randomness
}

CoordinatorUniverse represents the universe in which a randomness request occurs and is fulfilled.

func NewVRFCoordinatorUniverse

func NewVRFCoordinatorUniverse(t *testing.T, keys ...ethkey.KeyV2) CoordinatorUniverse

newVRFCoordinatorUniverse sets up all identities and contracts associated with testing the solidity VRF contracts involved in randomness request workflow

func NewVRFCoordinatorUniverseWithV08Consumer

func NewVRFCoordinatorUniverseWithV08Consumer(t *testing.T, key ethkey.KeyV2) CoordinatorUniverse

type VRFConsumerContract

type VRFConsumerContract interface {
	CreateSubscriptionAndFund(opts *bind.TransactOpts, fundingJuels *big.Int) (*gethtypes.Transaction, error)
	CreateSubscriptionAndFundNative(opts *bind.TransactOpts, fundingAmount *big.Int) (*gethtypes.Transaction, error)
	SSubId(opts *bind.CallOpts) (*big.Int, error)
	SRequestId(opts *bind.CallOpts) (*big.Int, error)
	RequestRandomness(opts *bind.TransactOpts, keyHash [32]byte, subID *big.Int, minReqConfs uint16, callbackGasLimit uint32, numWords uint32, payInEth bool) (*gethtypes.Transaction, error)
	SRandomWords(opts *bind.CallOpts, randomwordIdx *big.Int) (*big.Int, error)
	TopUpSubscription(opts *bind.TransactOpts, amount *big.Int) (*gethtypes.Transaction, error)
	TopUpSubscriptionNative(opts *bind.TransactOpts, amount *big.Int) (*gethtypes.Transaction, error)
	SGasAvailable(opts *bind.CallOpts) (*big.Int, error)
	UpdateSubscription(opts *bind.TransactOpts, consumers []common.Address) (*gethtypes.Transaction, error)
	SetSubID(opts *bind.TransactOpts, subID *big.Int) (*gethtypes.Transaction, error)
}

VRFConsumerContract is the common interface implemented by the example contracts used for the integration tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL