chainscripttest

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvidencesEqual

func EvidencesEqual(t *testing.T, e1, e2 *chainscript.Evidence)

EvidencesEqual compares two evidences. We can't directly compare the structs because protobuf sets some internal state data in the XXX_* fields of each underlying struct when serializing.

func LinksEqual

func LinksEqual(t *testing.T, l1, l2 *chainscript.Link)

LinksEqual compares two links. We can't directly compare the structs because protobuf sets some internal state data in the XXX_* fields of each underlying struct when serializing.

func RandomBytes

func RandomBytes(n int) []byte

RandomBytes returns a random byte array of the specified length.

func RandomEvidence

func RandomEvidence(t *testing.T) *chainscript.Evidence

RandomEvidence creates a random evidence.

func RandomHash

func RandomHash() chainscript.LinkHash

RandomHash creates a random hash.

func RandomLink(t *testing.T) *chainscript.Link

RandomLink creates a link with random data.

func RandomPrivateKey

func RandomPrivateKey(t *testing.T) []byte

RandomPrivateKey generates a private key that can be used to sign links.

func RandomSegment

func RandomSegment(t *testing.T) *chainscript.Segment

RandomSegment creates a segment with random data.

func RandomString

func RandomString(n int) string

RandomString generates a random string.

func SegmentsEqual

func SegmentsEqual(t *testing.T, s1, s2 *chainscript.Segment)

SegmentsEqual compares two segments. We can't directly compare the structs because protobuf sets some internal state data in the XXX_* fields of each underlying struct when serializing.

Types

type LinkBuilder

type LinkBuilder struct {
	Link *chainscript.Link
}

LinkBuilder allows building links easily in tests.

func NewLinkBuilder

func NewLinkBuilder(t *testing.T) *LinkBuilder

NewLinkBuilder creates a new LinkBuilder.

func (*LinkBuilder) Branch

func (lb *LinkBuilder) Branch(t *testing.T, parent *chainscript.Link) *LinkBuilder

Branch uses the provided link as its parent and copies its mapID and process.

func (*LinkBuilder) Build

func (lb *LinkBuilder) Build() *chainscript.Link

Build returns the underlying link.

func (*LinkBuilder) From

func (lb *LinkBuilder) From(t *testing.T, l *chainscript.Link) *LinkBuilder

From clones the given link.

func (*LinkBuilder) Segmentify

func (lb *LinkBuilder) Segmentify(t *testing.T) *chainscript.Segment

Segmentify builds the link and then segmentifies it.

func (*LinkBuilder) WithAction

func (lb *LinkBuilder) WithAction(action string) *LinkBuilder

WithAction fills the link's action.

func (*LinkBuilder) WithClientID

func (lb *LinkBuilder) WithClientID(clientID string) *LinkBuilder

WithClientID sets the link's clientID.

func (*LinkBuilder) WithData

func (lb *LinkBuilder) WithData(t *testing.T, data interface{}) *LinkBuilder

WithData fills the link's data.

func (*LinkBuilder) WithDegree

func (lb *LinkBuilder) WithDegree(d int) *LinkBuilder

WithDegree sets the link's out degree.

func (*LinkBuilder) WithInvalidFields

func (lb *LinkBuilder) WithInvalidFields() *LinkBuilder

WithInvalidFields makes the link invalid by setting some fields to invalid values.

func (*LinkBuilder) WithInvalidSignature

func (lb *LinkBuilder) WithInvalidSignature(t *testing.T) *LinkBuilder

WithInvalidSignature adds an invalid signature to the link.

func (*LinkBuilder) WithMapID

func (lb *LinkBuilder) WithMapID(mapID string) *LinkBuilder

WithMapID fills the link's mapID.

func (*LinkBuilder) WithMetadata

func (lb *LinkBuilder) WithMetadata(t *testing.T, metadata interface{}) *LinkBuilder

WithMetadata sets the link meta.Data field.

func (*LinkBuilder) WithParent

func (lb *LinkBuilder) WithParent(t *testing.T, link *chainscript.Link) *LinkBuilder

WithParent fills the link's prevLinkHash with the given parent's hash.

func (*LinkBuilder) WithParentHash

func (lb *LinkBuilder) WithParentHash(linkHash []byte) *LinkBuilder

WithParentHash fills the link's prevLinkHash.

func (*LinkBuilder) WithPriority

func (lb *LinkBuilder) WithPriority(priority float64) *LinkBuilder

WithPriority fills the link's priority.

func (*LinkBuilder) WithProcess

func (lb *LinkBuilder) WithProcess(process string) *LinkBuilder

WithProcess fills the link's process.

func (*LinkBuilder) WithProcessState

func (lb *LinkBuilder) WithProcessState(state string) *LinkBuilder

WithProcessState fills the link's process state.

func (*LinkBuilder) WithRandomData

func (lb *LinkBuilder) WithRandomData() *LinkBuilder

WithRandomData sets random data in most fields of the link.

func (*LinkBuilder) WithRef

func (lb *LinkBuilder) WithRef(t *testing.T, link *chainscript.Link) *LinkBuilder

WithRef adds a reference to the link.

func (*LinkBuilder) WithSignature

func (lb *LinkBuilder) WithSignature(t *testing.T, payloadPath string) *LinkBuilder

WithSignature signs the link with a random key. Provide an empty payload to sign the whole link.

func (*LinkBuilder) WithSignatureFromKey

func (lb *LinkBuilder) WithSignatureFromKey(t *testing.T, key []byte, payloadPath string) *LinkBuilder

WithSignatureFromKey signs the link with the given key. Provide an empty payload to sign the whole link.

func (*LinkBuilder) WithStep

func (lb *LinkBuilder) WithStep(step string) *LinkBuilder

WithStep fills the link's step.

func (*LinkBuilder) WithTag

func (lb *LinkBuilder) WithTag(tag string) *LinkBuilder

WithTag adds a tag to the link.

func (*LinkBuilder) WithTags

func (lb *LinkBuilder) WithTags(tags ...string) *LinkBuilder

WithTags replaces the link's tags.

func (*LinkBuilder) WithVersion

func (lb *LinkBuilder) WithVersion(version string) *LinkBuilder

WithVersion sets the link's version.

func (*LinkBuilder) WithoutParent

func (lb *LinkBuilder) WithoutParent() *LinkBuilder

WithoutParent removes the link's parent (prevLinkHash).

Jump to

Keyboard shortcuts

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