prottest

package
v0.0.0-...-ff6bfbe Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package prottest provides utilities for Chain Protocol testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockKeyPairs

func BlockKeyPairs(c *protocol.Chain) ([]ed25519.PublicKey, []ed25519.PrivateKey)

BlockKeyPairs returns the configured block-signing key-pairs for the provided Chain.

func Initial

func Initial(tb testing.TB, c *protocol.Chain) *bc.Block

Initial returns the provided Chain's initial block.

func MakeBlock

func MakeBlock(tb testing.TB, c *protocol.Chain, txs []*bc.Tx) *bc.Block

MakeBlock makes a new block from txs, commits it, and returns it. It assumes c's consensus program requires 0 signatures. (This is true for chains returned by NewChain.) If c requires more than 0 signatures, MakeBlock will fail. MakeBlock always makes a block; if there are no transactions in txs, it makes an empty block.

func NewChain

func NewChain(tb testing.TB, opts ...Option) *protocol.Chain

NewChain makes a new Chain. By default it uses a memstore for storage and creates an initial block using a 0/0 multisig program. It commits the initial block before returning the Chain.

Its defaults may be overridden by providing Options.

Types

type Option

type Option func(testing.TB, *config)

Option is a configuration option for NewChain.

func WithBlockSigners

func WithBlockSigners(quorum, n int) Option

WithBlockSigners is an option for NewChain that configures the NextPredicate for blocks in the new chain. It generates a suitable number of random new keypairs and stores them in the global maps blockPubkeys and blockPrivkeys.

func WithOutputIDs

func WithOutputIDs(outputIDs ...bc.Hash) Option

WithOutputIDs is an option for NewChain that prepopulates the blockchain's utxo set with the given hashes.

func WithStore

func WithStore(store protocol.Store) Option

WithStore is an option for NewChain that sets the Chain object's protocol.Store.

Directories

Path Synopsis
Package memstore is a protocol.Store implementation that keeps all blockchain state in memory.
Package memstore is a protocol.Store implementation that keeps all blockchain state in memory.

Jump to

Keyboard shortcuts

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