test

package
v0.0.0-...-f2e8c00 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package containing objects and functions which aid in the contruction and execution of our Geth-based spec suite

Index

Constants

View Source
const MIN_VOTE_BY = 86400

MIN_VOTE_BY is one day, in seconds

View Source
const ONE_ETH = 1000000000000000000
View Source
const ONE_FINNEY = 1000000000000000
View Source
const ONE_GWEI = 1000000000
View Source
const ONE_KWEI = 1000
View Source
const ONE_MWEI = 1000000
View Source
const ONE_SZABO = 1000000000000

Variables

View Source
var APPLICATION = big.NewInt(1)
View Source
var BACKEND_PAYMENT = big.NewInt(8)
View Source
var CHALLENGE = big.NewInt(2)
View Source
var COST_PER_BYTE = big.NewInt(11)
View Source
var LIST_REWARD = big.NewInt(5)
View Source
var MAKER_PAYMENT = big.NewInt(9)
View Source
var PLURALITY = big.NewInt(6)
View Source
var PRICE_FLOOR = big.NewInt(2)
View Source
var REGISTRATION = big.NewInt(4)
View Source
var REPARAM = big.NewInt(3)
View Source
var SPREAD = big.NewInt(4)
View Source
var STAKE = big.NewInt(1)
View Source
var UNDEFINED = big.NewInt(0)
View Source
var VOTE_BY = big.NewInt(7)

Functions

func Commafy

func Commafy(n *big.Int) string

Commafy will take a big integer and return a string with commas so that logging big integers is human readable

func GenBytes32

func GenBytes32(str string) [32]byte

GenBytes32 is a convenience function for some tests where a "GetHash" method is not available. Returns a type compatible with bytes32, given a string 32 chars or less.

func GetAuthObject

func GetAuthObject() *bind.TransactOpts

used to generate auth objects

func GetCallOpts

func GetCallOpts(auth *bind.TransactOpts) *bind.CallOpts

GetCallOpts is a function which allows us to more succinctly place Call options

func GetTxOpts

func GetTxOpts(auth *bind.TransactOpts, val *big.Int, price *big.Int, limit uint64) *bind.TransactOpts

GetTxOpts is a function which allows us to more succintly place the transaction options into a "send" type transaction. We do this in place of wrapping our TX in a global session variable, as, we tend to use different values in various places. Returns the assembled Geth TransactOpts

func IfNotNil

func IfNotNil(l logish, err error, msg string)

IfNotNil is a convenience method to throw fatal errors

func MaybeIncreaseMarketTokenAllowance

func MaybeIncreaseMarketTokenAllowance(c *Ctx, d *Dep, owner *bind.TransactOpts, spender common.Address, thresh *big.Int) error

MaybeApprove is a convenience method that inspects the Market Token Allowance of one address to another. If it is below the given threshold, increase the allowance until it meets said threshold Returns any error incurred.

func MaybeTransferMarketToken

func MaybeTransferMarketToken(c *Ctx, d *Dep, from *bind.TransactOpts, to common.Address, thresh *big.Int) error

MaybeTransferMarketToken is a convenience method that inspects the Market Token balance of a given address. If it is below the given threshold, increase the balance via transfer until it meets said threshold Returns any error incurred.

Types

type Ctx

type Ctx struct {
	Alloc       core.GenesisAlloc
	AuthOwner   *bind.TransactOpts
	AuthBackend *bind.TransactOpts
	AuthUser1   *bind.TransactOpts
	AuthUser2   *bind.TransactOpts
	AuthUser3   *bind.TransactOpts
	Blockchain  *backends.SimulatedBackend
}

Ctx, holds Auth objects capable of signing transactions. Not every spec will use every Auth object but they all should be available here, rather than scattered about many specs. Also holds the Geth simulated backend.

func GetContext

func GetContext(bal *big.Int) *Ctx

GetContext returns a hydrated Ctx struct, ready for use. Given a bal argument, it assigns this as the wallet balance for each authorization object in the Ctx

type Dep

type Dep struct {
	EtherTokenAddress        common.Address
	EtherTokenContract       *ethertoken.EtherToken
	EtherTokenTransaction    *types.Transaction
	MarketTokenAddress       common.Address
	MarketTokenContract      *markettoken.MarketToken
	MarketTokenTransaction   *types.Transaction
	VotingAddress            common.Address
	VotingContract           *voting.Voting
	VotingTransaction        *types.Transaction
	ParameterizerAddress     common.Address
	ParameterizerContract    *parameterizer.Parameterizer
	ParameterizerTransaction *types.Transaction
	DatatrustAddress         common.Address
	DatatrustContract        *datatrust.Datatrust
	DatatrustTransaction     *types.Transaction
	ListingAddress           common.Address
	ListingContract          *listing.Listing
	ListingTransaction       *types.Transaction
	ReserveAddress           common.Address
	ReserveContract          *reserve.Reserve
	ReserveTransaction       *types.Transaction
}

The deployed struct holds references to the instantiated contracts on the simulated backend. Also, refernces to each contract's adress and the deployment transaction itself, in case we want to inspect it.

func Deploy

func Deploy(mtBal *big.Int, c *Ctx, p *Params) (*Dep, error)

Deploy function which, well, deploys our contracts - returning a hydrated Dep object ready for use. The mtBal argument is an amount of market token(in wei) credited to the AuthOwner Also passed a hydrated Ctx object, used to aid the deploying. Params arg is hydrated with values for the parameterizer. Returns a hydrated Dep object or any error incurred.

type Params

type Params struct {
	PriceFloor  *big.Int
	Spread      *big.Int
	ListReward  *big.Int
	Stake       *big.Int
	VoteBy      *big.Int
	Plurality   *big.Int
	BackendPct  *big.Int
	MakerPct    *big.Int
	CostPerByte *big.Int
}

the params struct holds values that will be set in the P11r at init during deploy

Jump to

Keyboard shortcuts

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