testapp

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

test.app: a test application blockchain

It's frustrating to make changes to the metanode code and then discover that they're buggy only later, when testing the affected chaosnode / ndaunode implementations of the update.

What we need is an example application, tightly integrated into the metanode repo, with which we can demonstrate basic functionality.

This is that.

Documentation

Index

Constants

View Source
const ValueEndpoint = "/value"

Variables

View Source
var TxIDs = metatx.TxIDMap{
	metatx.TxID(1): &Add{},
}

TxIDs is the testapp transactions

Functions

This section is empty.

Types

type Add

type Add struct {
	Qty int
}

Add transactions add an appropriate amount to the state

func (Add) Apply

func (a Add) Apply(appI interface{}) error

Apply implements Transactable

func (*Add) DecodeMsg

func (z *Add) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Add) EncodeMsg

func (z Add) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Add) MarshalMsg

func (z Add) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Add) Msgsize

func (z Add) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (Add) SignableBytes

func (a Add) SignableBytes() []byte

SignableBytes implements Transactable

func (*Add) UnmarshalMsg

func (z *Add) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (Add) Validate

func (a Add) Validate(interface{}) error

Validate implements Transactable

type TestApp

type TestApp struct {
	*meta.App
}

TestApp is an application built solely for testing the metanode stuff

func NewTestApp

func NewTestApp() (*TestApp, error)

NewTestApp constructs a new TestApp

func (*TestApp) GetCount

func (t *TestApp) GetCount() uint64

GetCount returns the count in this app

func (*TestApp) UpdateCount

func (t *TestApp) UpdateCount(ud func(*uint64) error) error

UpdateCount allows callers to modify the count

If the supplied function returns a non-nil error, the app count is unchanged and the error is propagated.

type TestState

type TestState struct {
	Number util.Int
}

TestState is a super simple test state

func (*TestState) Init

func (*TestState) Init(vrw nt.ValueReadWriter)

Init satisfies metast.State

func (TestState) MarshalNoms

func (t TestState) MarshalNoms(vrw nt.ValueReadWriter) (nt.Value, error)

MarshalNoms implements metast.State

func (*TestState) UnmarshalNoms

func (t *TestState) UnmarshalNoms(v nt.Value) (err error)

UnmarshalNoms implements metast.State

Jump to

Keyboard shortcuts

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