test

package
v4.8.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBlocks

func AppendBlocks(chain *protocol.Chain, num uint64) error

AppendBlocks append empty blocks to chain, mainly used to mature the coinbase tx

func CreateCoinbaseTx

func CreateCoinbaseTx(controlProgram []byte, height, txsFee uint64) (*types.Tx, error)

CreateCoinbaseTx create coinbase tx at block height

func CreateSpendInput

func CreateSpendInput(tx *types.Tx, outputIndex uint64) (*types.SpendInput, error)

CreateSpendInput create SpendInput which spent the output from tx

func CreateTxFromTx

func CreateTxFromTx(baseTx *types.Tx, outputIndex uint64, outputAmount uint64, ctrlProgram []byte) (*types.Tx, error)

CreateTxFromTx create a tx spent the output in outputIndex at baseTx

func MockBlock

func MockBlock() *bc.Block

MockBlock mock a block

func MockChain

func MockChain(testDB dbm.DB) (*protocol.Chain, *database.Store, *protocol.TxPool, error)

MockChain mock chain with genesis block

func MockSign

func MockSign(tpl *txbuilder.Template, hsm *pseudohsm.HSM, password string) (bool, error)

MockSign sign a tx

func MockTx

func MockTx(utxo *account.UTXO, testAccount *account.Account) (*txbuilder.Template, *types.TxData, error)

MockTx mock a tx

func MockUTXO

func MockUTXO(controlProg *account.CtrlProgram) *account.UTXO

MockUTXO mock a utxo

func NewBlock

func NewBlock(chain *protocol.Chain, txs []*types.Tx, controlProgram []byte) (*types.Block, error)

NewBlock create block according to the current status of chain

func ReplaceCoinbase

func ReplaceCoinbase(block *types.Block, coinbaseTx *types.Tx) (err error)

ReplaceCoinbase replace the coinbase tx of block with coinbaseTx

func SignInstructionFor

func SignInstructionFor(input *types.SpendInput, db dbm.DB, signer *signers.Signer) (*txbuilder.SigningInstruction, error)

SignInstructionFor read CtrlProgram from db, construct SignInstruction for SpendInput

Types

type TxGenerator

type TxGenerator struct {
	Builder        *txbuilder.TemplateBuilder
	AccountManager *account.Manager
	Assets         *asset.Registry
	Hsm            *pseudohsm.HSM
}

TxGenerator used to generate new tx

func NewTxGenerator

func NewTxGenerator(accountManager *account.Manager, assets *asset.Registry, hsm *pseudohsm.HSM) *TxGenerator

NewTxGenerator create a TxGenerator

func (*TxGenerator) AddRetirement

func (g *TxGenerator) AddRetirement(assetAlias string, amount uint64) error

AddRetirement add a retirement output

func (*TxGenerator) AddSpendInput

func (g *TxGenerator) AddSpendInput(accountAlias, assetAlias string, amount uint64) error

AddSpendInput add a spend input

func (*TxGenerator) AddTxInput

func (g *TxGenerator) AddTxInput(txInput *types.TxInput, signInstruction *txbuilder.SigningInstruction) error

AddTxInput add a tx input and signing instruction

func (*TxGenerator) AddTxInputFromUtxo

func (g *TxGenerator) AddTxInputFromUtxo(utxo *account.UTXO, accountAlias string) error

AddTxInputFromUtxo add a tx input which spent the utxo

func (*TxGenerator) AddTxOutput

func (g *TxGenerator) AddTxOutput(accountAlias, assetAlias string, amount uint64) error

AddTxOutput add a tx output

func (*TxGenerator) Reset

func (g *TxGenerator) Reset()

Reset reset transaction builder, used to create a new tx

func (*TxGenerator) Sign

func (g *TxGenerator) Sign(passwords []string) (*types.Tx, error)

Sign used to sign tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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