go-chainscript: github.com/stratumn/go-chainscript/chainscripttest Index | Files

package chainscripttest

import "github.com/stratumn/go-chainscript/chainscripttest"

Index

Package Files

builder.go compare.go random.go

func EvidencesEqual Uses

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 Uses

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 Uses

func RandomBytes(n int) []byte

RandomBytes returns a random byte array of the specified length.

func RandomEvidence Uses

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

RandomEvidence creates a random evidence.

func RandomHash Uses

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 Uses

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

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

func RandomSegment Uses

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

RandomSegment creates a segment with random data.

func RandomString Uses

func RandomString(n int) string

RandomString generates a random string.

func SegmentsEqual Uses

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.

type LinkBuilder Uses

type LinkBuilder struct {
    Link *chainscript.Link
}

LinkBuilder allows building links easily in tests.

func NewLinkBuilder Uses

func NewLinkBuilder(t *testing.T) *LinkBuilder

NewLinkBuilder creates a new LinkBuilder.

func (*LinkBuilder) Branch Uses

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 Uses

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

Build returns the underlying link.

func (*LinkBuilder) From Uses

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

From clones the given link.

func (*LinkBuilder) Segmentify Uses

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

Segmentify builds the link and then segmentifies it.

func (*LinkBuilder) WithAction Uses

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

WithAction fills the link's action.

func (*LinkBuilder) WithClientID Uses

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

WithClientID sets the link's clientID.

func (*LinkBuilder) WithData Uses

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

WithData fills the link's data.

func (*LinkBuilder) WithDegree Uses

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

WithDegree sets the link's out degree.

func (*LinkBuilder) WithInvalidFields Uses

func (lb *LinkBuilder) WithInvalidFields() *LinkBuilder

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

func (*LinkBuilder) WithInvalidSignature Uses

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

WithInvalidSignature adds an invalid signature to the link.

func (*LinkBuilder) WithMapID Uses

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

WithMapID fills the link's mapID.

func (*LinkBuilder) WithMetadata Uses

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

WithMetadata sets the link meta.Data field.

func (*LinkBuilder) WithParent Uses

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 Uses

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

WithParentHash fills the link's prevLinkHash.

func (*LinkBuilder) WithPriority Uses

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

WithPriority fills the link's priority.

func (*LinkBuilder) WithProcess Uses

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

WithProcess fills the link's process.

func (*LinkBuilder) WithProcessState Uses

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

WithProcessState fills the link's process state.

func (*LinkBuilder) WithRandomData Uses

func (lb *LinkBuilder) WithRandomData() *LinkBuilder

WithRandomData sets random data in most fields of the link.

func (*LinkBuilder) WithRef Uses

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

WithRef adds a reference to the link.

func (*LinkBuilder) WithSignature Uses

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 Uses

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 Uses

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

WithStep fills the link's step.

func (*LinkBuilder) WithTag Uses

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

WithTag adds a tag to the link.

func (*LinkBuilder) WithTags Uses

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

WithTags replaces the link's tags.

func (*LinkBuilder) WithVersion Uses

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

WithVersion sets the link's version.

func (*LinkBuilder) WithoutParent Uses

func (lb *LinkBuilder) WithoutParent() *LinkBuilder

WithoutParent removes the link's parent (prevLinkHash).

Package chainscripttest imports 5 packages (graph) and is imported by 9 packages. Updated 2018-11-01. Refresh now. Tools for package owners.