vrftesthelpers

package
v0.0.0-...-3674750 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func NewMaliciousConsumer

func NewMaliciousConsumer(consumer *vrf_malicious_consumer_v2.VRFMaliciousConsumerV2) *vrfConsumerContract

func NewRevertingConsumer

func NewRevertingConsumer(consumer *vrfv2_reverting_example.VRFV2RevertingExample) *vrfConsumerContract

func NewVRFConsumerV2

func NewVRFConsumerV2(consumer *vrf_consumer_v2.VRFConsumerV2) *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
	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