testHelper

package
v6.4.2-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBlockHeadPrimaryIndex   = "e8e28ca4dfd65075cc113c522bf9476ffdf78235d553e8a192f477ee8c659cd0"
	DBlockHeadSecondaryIndex = "5a0654af6690ff20f2a50970e2859daec94390a623e39598ffe79c76cbe45a4b"

	ABlockHeadPrimaryIndex   = "073bd46185217fddbd6d422cc23f28fe8ea58bf63c2e7521b7de3623b52e3b41"
	ABlockHeadSecondaryIndex = "4d4d40eff3c48e054226d7308ac6a8e2230dc489be7ca39631abac258f33902b"

	ECBlockHeadPrimaryIndex   = "6b1aa04211ffd258c19f3ae4d0299f2b71ccabb8105489ed35dd881fc40a1e68"
	ECBlockHeadSecondaryIndex = "25a030e3a0eb491f7b5c0be7ee31575e8c274effc80854eafb1bf6c4ec4ea1e2"

	FBlockHeadPrimaryIndex   = "84c8ac94c639117ef1b80d00c48f03c4a14bd74f17d86d56a8d8a4a73e6f91a8"
	FBlockHeadSecondaryIndex = "5f4d14e8b4bf5d8545d7ccaccccc99d2757b6ef5eaf5ffac03705457bb9d65ac"

	EBlockHeadPrimaryIndex   = "6e7e64ac45ff57edbf8537a0c99fba2e9ee351ef3d3f4abd93af9f01107e592c"
	EBlockHeadSecondaryIndex = "e79fb46ad81f0b4fac7f1e66728b40b390f8fcc3806e93f94550eec041eecff2"

	AnchorBlockHeadPrimaryIndex   = "df3ade9eec4b08d5379cc64270c30ea7315d8a8a1a69efe2b98a60ecdd69e604"
	AnchorBlockHeadSecondaryIndex = "c4e4c26a0f280425cc4acafa66205cf2643e8d9c2c13cf6905edcfa1e5f90983"
)

Variables

View Source
var BlockCount int = 10
View Source
var DefaultCoinbaseAmount uint64 = 100000000
View Source
var ExpectedHeight, Leaders, Audits, Followers int
View Source
var RanSimTest = false // only run 1 sim test at a time

Functions

func AccountFromFctSecret

func AccountFromFctSecret(s string) *testAccount

func AddFNode

func AddFNode()

func AdjustAuthoritySet

func AdjustAuthoritySet(adjustingNodes string)

func AssertAuthoritySet

func AssertAuthoritySet(t *testing.T, givenNodes string)

func CheckAuthoritySet

func CheckAuthoritySet(t *testing.T)

func CloneFnodeData

func CloneFnodeData(fnode int, copyToNode int, t *testing.T)

func ComposeChainCommit

func ComposeChainCommit(pkey *primitives.PrivateKey, c *factom.Chain) (*messages.CommitChainMsg, error)

func ComposeCommitEntryMsg

func ComposeCommitEntryMsg(pkey *primitives.PrivateKey, e factom.Entry) (*messages.CommitEntryMsg, error)

func ComposeRevealEntryMsg

func ComposeRevealEntryMsg(pkey *primitives.PrivateKey, e *factom.Entry) (*messages.RevealEntryMsg, error)

func CopyDir

func CopyDir(src, dst string) error

REVIEW: is there a build-in way better than this?

func CountAuthoritySet

func CountAuthoritySet() (int, int, int)

func CreateAndPopulateStaleHolding

func CreateAndPopulateStaleHolding() *state.State

func CreateAndPopulateTestDatabaseOverlay

func CreateAndPopulateTestDatabaseOverlay() *databaseOverlay.Overlay

func CreateAndPopulateTestDatabaseOverlayForFER

func CreateAndPopulateTestDatabaseOverlayForFER(testEntries []FEREntryWithHeight, desiredHeight int) *databaseOverlay.Overlay

func CreateAndPopulateTestState

func CreateAndPopulateTestState() *state.State

func CreateAndPopulateTestStateAndStartValidator

func CreateAndPopulateTestStateAndStartValidator() *state.State

func CreateAndPopulateTestStateForFER

func CreateAndPopulateTestStateForFER(testEntries []FEREntryWithHeight, desiredHeight int) *state.State

func CreateEmptyTestDatabaseOverlay

func CreateEmptyTestDatabaseOverlay() *databaseOverlay.Overlay

func CreateEmptyTestState

func CreateEmptyTestState() *state.State

func CreateFirstAnchorEntry

func CreateFirstAnchorEntry() *entryBlock.Entry

func CreateFirstTestEntry

func CreateFirstTestEntry() *entryBlock.Entry

func CreatePopulateAndExecuteTestState

func CreatePopulateAndExecuteTestState() *state.State

func CreateTestAdminBlock

func CreateTestAdminBlock(prev *adminBlock.AdminBlock) *adminBlock.AdminBlock

func CreateTestAdminHeader

func CreateTestAdminHeader(prev *adminBlock.AdminBlock) *adminBlock.ABlockHeader

func CreateTestAnchorEnry

func CreateTestAnchorEnry(dBlock *directoryBlock.DirectoryBlock) *entryBlock.Entry

func CreateTestDBStateList

func CreateTestDBStateList() []interfaces.IMsg

func CreateTestDirBlockInfo

func CreateTestDirBlockInfo(prev *dbInfo.DirBlockInfo) *dbInfo.DirBlockInfo

func CreateTestDirectoryBlock

func CreateTestDirectoryBlock(prevBlock *directoryBlock.DirectoryBlock) *directoryBlock.DirectoryBlock

func CreateTestDirectoryBlockHeader

func CreateTestDirectoryBlockHeader(prevBlock *directoryBlock.DirectoryBlock) *directoryBlock.DBlockHeader

func CreateTestDirectoryBlockHeaderWithNetworkID

func CreateTestDirectoryBlockHeaderWithNetworkID(prevBlock *directoryBlock.DirectoryBlock, networkID uint32) *directoryBlock.DBlockHeader

func CreateTestDirectoryBlockWithNetworkID

func CreateTestDirectoryBlockWithNetworkID(prevBlock *directoryBlock.DirectoryBlock, networkID uint32) *directoryBlock.DirectoryBlock

func CreateTestEntry

func CreateTestEntry(n uint32) *entryBlock.Entry

func CreateTestEntryBlock

func CreateTestEntryBlock(p interfaces.IEntryBlock) (*entryBlock.EBlock, []*entryBlock.Entry)

func CreateTestEntryBlockForFER

func CreateTestEntryBlockForFER(p interfaces.IEntryBlock, height uint32) (*entryBlock.EBlock, []*entryBlock.Entry)

func CreateTestEntryBlockWithContentN

func CreateTestEntryBlockWithContentN(p interfaces.IEntryBlock, content uint32) (*entryBlock.EBlock, []*entryBlock.Entry)

func CreateTestFEREntry

func CreateTestFEREntry(n uint32) *entryBlock.Entry

func CreateTestFactoidBlock

func CreateTestFactoidBlock(prev interfaces.IFBlock) interfaces.IFBlock

func CreateTestFactoidBlockWithCoinbase

func CreateTestFactoidBlockWithCoinbase(prev interfaces.IFBlock, address interfaces.IAddress, amount uint64) interfaces.IFBlock

func CreateTestFactoidBlockWithTransaction

func CreateTestFactoidBlockWithTransaction(prev interfaces.IFBlock, sentSecret string, receivePublic []byte, amt uint64) interfaces.IFBlock

func ExecuteAllBlocksFromDatabases

func ExecuteAllBlocksFromDatabases(s *state.State)

func GetAllDBStateMsgsFromDatabase

func GetAllDBStateMsgsFromDatabase(s *state.State) []interfaces.IMsg

func GetAnchorChainID

func GetAnchorChainID() interfaces.IHash

func GetBankAccount

func GetBankAccount() *testAccount

This account has a balance from initial coinbase

func GetChainID

func GetChainID() interfaces.IHash

func GetLongTestHome

func GetLongTestHome(t *testing.T) string

re-use a common dir for longTest

func GetRandomAccount

func GetRandomAccount() *testAccount

build addresses from random key

func GetSimTestHome

func GetSimTestHome(t *testing.T) string

use a test specific dir for simTest

func GetTestName

func GetTestName() (name string)

find Test Function name in stack

func Halt

func Halt(t *testing.T)

func InitTestState

func InitTestState()

func IntToByteSlice

func IntToByteSlice(n int) []byte

func NewCommitChain

func NewCommitChain(eBlock *entryBlock.EBlock) *entryCreditBlock.CommitChain

func NewCommitEntry

func NewCommitEntry(eBlock *entryBlock.EBlock) *entryCreditBlock.CommitEntry

func NewECAddress

func NewECAddress(n uint64) interfaces.IAddress

func NewECAddressPublicKeyString

func NewECAddressPublicKeyString(n uint64) string

func NewECAddressString

func NewECAddressString(n uint64) string

func NewFactoidAddress

func NewFactoidAddress(n uint64) interfaces.IAddress

func NewFactoidAddressStrings

func NewFactoidAddressStrings(n uint64) (string, string, string)

func NewFactoidRCDAddress

func NewFactoidRCDAddress(n uint64) interfaces.IRCD

func NewFactoidRCDAddressString

func NewFactoidRCDAddressString(n uint64) string

func NewFullPrivKey

func NewFullPrivKey(n uint64) []byte

Create a full 64 bit key holding both private and public key

func NewPrimitivesPrivateKey

func NewPrimitivesPrivateKey(n uint64) *primitives.PrivateKey

func NewPrivKey

func NewPrivKey(n uint64) []byte

Create 32 bit private key (without the public key part)

func NewPrivKeyString

func NewPrivKeyString(n uint64) string

func NewRepeatingHash

func NewRepeatingHash(b byte) interfaces.IHash

func PopulateTestDatabaseOverlay

func PopulateTestDatabaseOverlay(dbo *databaseOverlay.Overlay)

func PrintList

func PrintList(title string, list map[string]uint64)

func PrivateKeyToECAddress

func PrivateKeyToECAddress(key *primitives.PrivateKey) *factom.ECAddress

func PrivateKeyToEDPub

func PrivateKeyToEDPub(priv []byte) []byte

func ResetSimHome

func ResetSimHome(t *testing.T) string

func ResetTestHome

func ResetTestHome(homeDir string, t *testing.T)

remove files from a home dir and remake .factom config dir

func RunCmd

func RunCmd(cmd string)

func SetInputFilter

func SetInputFilter(apiRegex string) (*http.Response, error)

func SetOutputFilter

func SetOutputFilter(apiRegex string) (*http.Response, error)

func SetupSim

func SetupSim(givenNodes string, userAddedOptions map[string]string, height int, electionsCnt int, roundsCnt int, t *testing.T) *state.State

EX. state0 := SetupSim("LLLLLLLLLLLLLLLAAAAAAAAAA", map[string]string {"--controlpanelsetting" : "readwrite"}, t)

func ShutDownEverything

func ShutDownEverything(t *testing.T)

func SignCommit

func SignCommit(n uint64, tx interfaces.ISignable)

func SignFactoidTransaction

func SignFactoidTransaction(n uint64, tx interfaces.ITransaction)

func StartSim

func StartSim(nodeCount int, UserAddedOptions map[string]string) *state.State

start simulation without promoting nodes to the authority set this is useful for creating scripts that will start/stop a simulation outside of the context of a unit test this allows for consistent tweaking of a simulation to induce load add message loss or adjust timing

func StatusEveryMinute

func StatusEveryMinute(s *state.State)

print the status for every minute for a state

func SystemCall

func SystemCall(cmd string) []byte

func TestABlockEntryFunctions

func TestABlockEntryFunctions(a interfaces.IABEntry, b interfaces.IABEntry, t *testing.T)

func TestMarshaling

func TestMarshaling(a interfaces.BinaryMarshallable, b interfaces.BinaryMarshallable, extraBytes int, t *testing.T)

TestMarshaling will test a marshing and unmarshal operation. Do the comparison of equality yourself. Extrabytes adds a random number of bytes up to extrabytes in length

func TimeNow

func TimeNow(s *state.State)

func WaitBlocks

func WaitBlocks(s *state.State, blks int)

Wait so many blocks

func WaitForAllNodes

func WaitForAllNodes(state *state.State)

func WaitForAnyEcBalance

func WaitForAnyEcBalance(s *state.State, ecPub string) int64

wait for non-zero EC balance

func WaitForAnyFctBalance

func WaitForAnyFctBalance(s *state.State, fctPub string) int64

wait for non-zero FCT balance

func WaitForBlock

func WaitForBlock(s *state.State, newBlock int)

Wait for a specific blocks

func WaitForEcBalanceOver

func WaitForEcBalanceOver(s *state.State, ecPub string, target int64) int64

loop until balance is >= target

func WaitForEcBalanceUnder

func WaitForEcBalanceUnder(s *state.State, ecPub string, target int64) int64

loop until balance is < target

func WaitForEntry

func WaitForEntry(s *state.State, hash interfaces.IHash) bool

func WaitForFctBalanceOver

func WaitForFctBalanceOver(s *state.State, fctPub string, target int64) int64

loop until balance is <= target

func WaitForFctBalanceUnder

func WaitForFctBalanceUnder(s *state.State, fctPub string, target int64) int64

loop until balance is >= target

func WaitForMinute

func WaitForMinute(s *state.State, newMinute int)

Wait to a given minute.

func WaitForQuiet

func WaitForQuiet(s *state.State, newBlock int, newMinute int)

Wait till block = newBlock and minute = newMinute

func WaitForZeroEC

func WaitForZeroEC(s *state.State, ecPub string) int64

wait for exactly Zero EC balance REVIEW: should we ditch this?

func WaitMinutes

func WaitMinutes(s *state.State, min int)

func WriteConfigFile

func WriteConfigFile(identityNumber int, fnode int, extra string, t *testing.T)

Write an identity to a config file for an Fnode, optionally appending extra config data NOTE: works only for simulation

Types

type BlockSet

type BlockSet struct {
	DBlock       *directoryBlock.DirectoryBlock
	ABlock       *adminBlock.AdminBlock
	ECBlock      interfaces.IEntryCreditBlock
	FBlock       interfaces.IFBlock
	EBlock       *entryBlock.EBlock
	AnchorEBlock *entryBlock.EBlock
	Entries      []*entryBlock.Entry
	Height       int
}

func CreateFullTestBlockSet

func CreateFullTestBlockSet() []*BlockSet

func CreateTestBlockSet

func CreateTestBlockSet(prev *BlockSet) *BlockSet

func CreateTestBlockSetForFER

func CreateTestBlockSetForFER(prev *BlockSet, db *databaseOverlay.Overlay, testEntries []FEREntryWithHeight) *BlockSet

func CreateTestBlockSetWithNetworkID

func CreateTestBlockSetWithNetworkID(prev *BlockSet, networkID uint32, transactions bool) *BlockSet

Transactions says whether or not to add a transaction

type FEREntryWithHeight

type FEREntryWithHeight struct {
	AnFEREntry interfaces.IEBEntry
	Height     uint32
}

func MakeFEREntryWithHeightFromContent

func MakeFEREntryWithHeightFromContent(passedResidentHeight uint32, passedTargetActivationHeight uint32,
	passedTargetPrice uint64, passedExpirationHeight uint32, passedPriority uint32) *FEREntryWithHeight

Jump to

Keyboard shortcuts

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