Documentation
¶
Index ¶
Constants ¶
const ( // DefaultMaxBytesSize is the MaxBytesSize value in the Generator returned by NewGenerator() DefaultMaxBytesSize = 1024 // DefaultMaxVecLen is the MaxVecLen value in the Generator returned by NewGenerator() DefaultMaxVecLen = 10 // DefaultSeed is the seed for the Source value in the Generator returned by NewGenerator() DefaultSeed = 99 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
// MaxBytesSize configures the upper bound limit for variable length
// opaque data and variable length strings
// https://tools.ietf.org/html/rfc4506#section-4.10
MaxBytesSize uint32
// MaxVecLen configures the upper bound limit for variable length arrays
// https://tools.ietf.org/html/rfc4506#section-4.13
MaxVecLen uint32
// Source is the rand.Source which is used by the Generator to create
// random values
Source rand.Source
}
Generator generates random XDR values.
func NewGenerator ¶
func NewGenerator() Generator
NewGenerator returns a new Generator instance configured with default settings. The returned Generator is deterministic but it is not thread-safe.
type Selector ¶
Selector is function used to match fields of a goxdr.XdrType
var IsNestedInnerSet Selector = func(name string, xdrType goxdr.XdrType) bool { if strings.HasSuffix(name, ".innerSets") && strings.Count(name, ".innerSets[") > 0 { _, ok := goxdr.XdrBaseType(xdrType).(goxdr.XdrVec) return ok } return false }
IsNestedInnerSet is a Selector which identifies nesting for the following xdr type:
struct SCPQuorumSet
{
uint32 threshold;
PublicKey validators<>;
SCPQuorumSet innerSets<>;
};
supports things like: A,B,C,(D,E,F),(G,H,(I,J,K,L)) only allows 2 levels of nesting
var IsPtr Selector = func(name string, xdrType goxdr.XdrType) bool { _, ok := goxdr.XdrBaseType(xdrType).(goxdr.XdrPtr) return ok }
IsPtr is a Selector which matches on all XDR pointer fields
func FieldEquals ¶
FieldEquals returns a Selector which matches on a field name by equality
func FieldMatches ¶
FieldMatches returns a Selector which matches on a field name by regexp
type Setter ¶
Setter is a function used to set field values for a goxdr.XdrType
var SetPtrToPresent Setter = func(m *randMarshaller, name string, xdrType goxdr.XdrType) { p := goxdr.XdrBaseType(xdrType).(goxdr.XdrPtr) p.SetPresent(true) p.XdrMarshalValue(m, name) }
SetPtrToPresent is a Setter which ensures that a given XDR pointer field is not nil
func SetPositiveNum32 ¶
func SetPositiveNum32() Setter
SetPositiveNum32 returns a Setter which sets a uint32 XDR field to a random positive value
func SetPositiveNum64 ¶
func SetPositiveNum64() Setter
SetPositiveNum64 returns a Setter which sets a uint64 XDR field to a random positive value
func SetVecLen ¶
SetVecLen returns a Setter which sets the length of a variable length array ( https://tools.ietf.org/html/rfc4506#section-4.13 ) to a fixed value