Documentation ¶
Index ¶
- Variables
- func FloatToUint128(t *testing.T, med float64) *util.Uint128
- func NewTestGenesisBlock(t *testing.T, dynastySize int) (genesis *core.Block, dynasties keyutil.AddrKeyPairs, ...)
- func NewTestGenesisConf(t *testing.T, dynastySize int) (genesis *corepb.Genesis, dynasties keyutil.AddrKeyPairs, ...)
- func Points(t *testing.T, tx *core.Transaction, b *core.Block) *util.Uint128
- type BlockBuilder
- func (bb *BlockBuilder) AccountRoot(root []byte) *BlockBuilder
- func (bb *BlockBuilder) AddKeyPairs(keyPairs keyutil.AddrKeyPairs) *BlockBuilder
- func (bb *BlockBuilder) AddTx(tx *core.Transaction) *BlockBuilder
- func (bb *BlockBuilder) Block(b *core.Block) *BlockBuilder
- func (bb *BlockBuilder) Build() *core.Block
- func (bb *BlockBuilder) BuildBytes() []byte
- func (bb *BlockBuilder) BuildProto() *corepb.Block
- func (bb *BlockBuilder) CalcHash() *BlockBuilder
- func (bb *BlockBuilder) ChainID(chainID uint32) *BlockBuilder
- func (bb *BlockBuilder) Child() *BlockBuilder
- func (bb *BlockBuilder) ChildNextDynasty() *BlockBuilder
- func (bb *BlockBuilder) ChildWithTimestamp(ts int64) *BlockBuilder
- func (bb *BlockBuilder) Clone() *BlockBuilder
- func (bb *BlockBuilder) Coinbase(addr common.Address) *BlockBuilder
- func (bb *BlockBuilder) DposRoot(root []byte) *BlockBuilder
- func (bb *BlockBuilder) ExecuteTx(tx *core.Transaction) *BlockBuilder
- func (bb *BlockBuilder) ExecuteTxErr(tx *core.Transaction, expected error) *BlockBuilder
- func (bb *BlockBuilder) Expect() *Expect
- func (bb *BlockBuilder) FindProposer() *keyutil.AddrKeyPair
- func (bb *BlockBuilder) Flush() *BlockBuilder
- func (bb *BlockBuilder) Genesis() *BlockBuilder
- func (bb *BlockBuilder) GetProposer() common.Address
- func (bb *BlockBuilder) Hash(hash []byte) *BlockBuilder
- func (bb *BlockBuilder) Height(height uint64) *BlockBuilder
- func (bb *BlockBuilder) ParentHash(hash []byte) *BlockBuilder
- func (bb *BlockBuilder) PayReward() *BlockBuilder
- func (bb *BlockBuilder) Prepare() *BlockBuilder
- func (bb *BlockBuilder) Reward(reward uint64) *BlockBuilder
- func (bb *BlockBuilder) Seal() *BlockBuilder
- func (bb *BlockBuilder) Sealed(sealed bool) *BlockBuilder
- func (bb *BlockBuilder) Sign(sign []byte) *BlockBuilder
- func (bb *BlockBuilder) SignKey(key signature.PrivateKey) *BlockBuilder
- func (bb *BlockBuilder) SignPair(pair *keyutil.AddrKeyPair) *BlockBuilder
- func (bb *BlockBuilder) SignProposer() *BlockBuilder
- func (bb *BlockBuilder) Stake() *BlockBuilder
- func (bb *BlockBuilder) Supply(supply string) *BlockBuilder
- func (bb *BlockBuilder) Timestamp(ts int64) *BlockBuilder
- func (bb *BlockBuilder) Tx() *TxBuilder
- func (bb *BlockBuilder) TxRoot(root []byte) *BlockBuilder
- func (bb *BlockBuilder) UpdateDynastyState(parent *core.Block) *BlockBuilder
- type Expect
- func (e *Expect) Balance(addr common.Address, med float64) *Expect
- func (e *Expect) GetNonce(addr common.Address) uint64
- func (e *Expect) LastPointsTs(addr common.Address, ts int64) *Expect
- func (e *Expect) LastUnstakingTs(addr common.Address, ts int64) *Expect
- func (e *Expect) Nonce(addr common.Address, nonce uint64) *Expect
- func (e *Expect) Points(addr common.Address, bandwidth *util.Uint128) *Expect
- func (e *Expect) Staking(addr common.Address, med float64) *Expect
- func (e *Expect) Unstaking(addr common.Address, med float64) *Expect
- type TxBuilder
- func (tb *TxBuilder) Add() *BlockBuilder
- func (tb *TxBuilder) Build() *core.Transaction
- func (tb *TxBuilder) BuildBytes() []byte
- func (tb *TxBuilder) BuildCtx() *core.TxContext
- func (tb *TxBuilder) BuildProto() *corepb.Transaction
- func (tb *TxBuilder) CalcHash() *TxBuilder
- func (tb *TxBuilder) ChainID(chainID uint32) *TxBuilder
- func (tb *TxBuilder) Execute() *BlockBuilder
- func (tb *TxBuilder) ExecuteErr(err error) *BlockBuilder
- func (tb *TxBuilder) From(addr common.Address) *TxBuilder
- func (tb *TxBuilder) Hash(hash []byte) *TxBuilder
- func (tb *TxBuilder) Nonce(nonce uint64) *TxBuilder
- func (tb *TxBuilder) Payer(addr common.Address) *TxBuilder
- func (tb *TxBuilder) PayerSign(sign []byte) *TxBuilder
- func (tb *TxBuilder) Payload(payload transaction.Payload) *TxBuilder
- func (tb *TxBuilder) RandomTx() *TxBuilder
- func (tb *TxBuilder) RandomTxs(n int) []*core.Transaction
- func (tb *TxBuilder) Sign(sign []byte) *TxBuilder
- func (tb *TxBuilder) SignKey(key signature.PrivateKey) *TxBuilder
- func (tb *TxBuilder) SignPair(pair *keyutil.AddrKeyPair) *TxBuilder
- func (tb *TxBuilder) SignPairWithNonce(pair *keyutil.AddrKeyPair, nonce uint64) *TxBuilder
- func (tb *TxBuilder) SignPayerKey(key signature.PrivateKey) *TxBuilder
- func (tb *TxBuilder) SignPayerPair(pair *keyutil.AddrKeyPair) *TxBuilder
- func (tb *TxBuilder) StakeTx(pair *keyutil.AddrKeyPair, med float64) *TxBuilder
- func (tb *TxBuilder) To(addr common.Address) *TxBuilder
- func (tb *TxBuilder) Type(txType string) *TxBuilder
- func (tb *TxBuilder) UnstakeTx(pair *keyutil.AddrKeyPair, med float64) *TxBuilder
- func (tb *TxBuilder) Value(med float64) *TxBuilder
- func (tb *TxBuilder) ValueRaw(value *util.Uint128) *TxBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ChainID is chain id for test configuration. ChainID uint32 = 1 // DynastySize is dynasty size for test configuration DynastySize = 3 )
Functions ¶
func FloatToUint128 ¶
FloatToUint128 covert float to uint128 (precision is only 1e-03)
func NewTestGenesisBlock ¶
func NewTestGenesisBlock(t *testing.T, dynastySize int) (genesis *core.Block, dynasties keyutil.AddrKeyPairs, distributed keyutil.AddrKeyPairs)
NewTestGenesisBlock returns a genesis block for tests.
func NewTestGenesisConf ¶
func NewTestGenesisConf(t *testing.T, dynastySize int) (genesis *corepb.Genesis, dynasties keyutil.AddrKeyPairs, distributed keyutil.AddrKeyPairs)
NewTestGenesisConf returns a genesis configuration for tests.
Types ¶
type BlockBuilder ¶
type BlockBuilder struct { B *core.BlockTestWrap Dynasties keyutil.AddrKeyPairs TokenDist keyutil.AddrKeyPairs KeyPairs keyutil.AddrKeyPairs // contains filtered or unexported fields }
BlockBuilder is structure for building block
func (*BlockBuilder) AccountRoot ¶
func (bb *BlockBuilder) AccountRoot(root []byte) *BlockBuilder
AccountRoot sets account root.
func (*BlockBuilder) AddKeyPairs ¶
func (bb *BlockBuilder) AddKeyPairs(keyPairs keyutil.AddrKeyPairs) *BlockBuilder
AddKeyPairs sets key pairs on block builder
func (*BlockBuilder) AddTx ¶
func (bb *BlockBuilder) AddTx(tx *core.Transaction) *BlockBuilder
AddTx add transaction
func (*BlockBuilder) Block ¶
func (bb *BlockBuilder) Block(b *core.Block) *BlockBuilder
Block sets block
func (*BlockBuilder) BuildBytes ¶
func (bb *BlockBuilder) BuildBytes() []byte
BuildBytes builds block in bytes.
func (*BlockBuilder) BuildProto ¶
func (bb *BlockBuilder) BuildProto() *corepb.Block
BuildProto builds block in protobuf format.
func (*BlockBuilder) CalcHash ¶
func (bb *BlockBuilder) CalcHash() *BlockBuilder
CalcHash calculate hash
func (*BlockBuilder) ChainID ¶
func (bb *BlockBuilder) ChainID(chainID uint32) *BlockBuilder
ChainID sets chain ID.
func (*BlockBuilder) ChildNextDynasty ¶
func (bb *BlockBuilder) ChildNextDynasty() *BlockBuilder
ChildNextDynasty create first child block of next dynasty
func (*BlockBuilder) ChildWithTimestamp ¶
func (bb *BlockBuilder) ChildWithTimestamp(ts int64) *BlockBuilder
ChildWithTimestamp create child block on specific timestamp
func (*BlockBuilder) Clone ¶
func (bb *BlockBuilder) Clone() *BlockBuilder
Clone clones block on block builders (State of block must unprepared)
func (*BlockBuilder) Coinbase ¶
func (bb *BlockBuilder) Coinbase(addr common.Address) *BlockBuilder
Coinbase sets coinbase.
func (*BlockBuilder) DposRoot ¶
func (bb *BlockBuilder) DposRoot(root []byte) *BlockBuilder
DposRoot sets dpos root.
func (*BlockBuilder) ExecuteTx ¶
func (bb *BlockBuilder) ExecuteTx(tx *core.Transaction) *BlockBuilder
ExecuteTx execute transaction
func (*BlockBuilder) ExecuteTxErr ¶
func (bb *BlockBuilder) ExecuteTxErr(tx *core.Transaction, expected error) *BlockBuilder
ExecuteTxErr expect error occurred on executing
func (*BlockBuilder) FindProposer ¶
func (bb *BlockBuilder) FindProposer() *keyutil.AddrKeyPair
FindProposer finds proposer.
func (*BlockBuilder) Flush ¶
func (bb *BlockBuilder) Flush() *BlockBuilder
Flush saves state to storage TODO remove prepare, flush calls
func (*BlockBuilder) Genesis ¶
func (bb *BlockBuilder) Genesis() *BlockBuilder
Genesis create genesis block
func (*BlockBuilder) GetProposer ¶
func (bb *BlockBuilder) GetProposer() common.Address
GetProposer returns proposer.
func (*BlockBuilder) Height ¶
func (bb *BlockBuilder) Height(height uint64) *BlockBuilder
Height sets block height.
func (*BlockBuilder) ParentHash ¶
func (bb *BlockBuilder) ParentHash(hash []byte) *BlockBuilder
ParentHash sets parenthash
func (*BlockBuilder) PayReward ¶
func (bb *BlockBuilder) PayReward() *BlockBuilder
PayReward pay reward and update reward and supply
func (*BlockBuilder) Prepare ¶
func (bb *BlockBuilder) Prepare() *BlockBuilder
Prepare prepare block state
func (*BlockBuilder) Reward ¶
func (bb *BlockBuilder) Reward(reward uint64) *BlockBuilder
Reward sets reward.
func (*BlockBuilder) Seal ¶
func (bb *BlockBuilder) Seal() *BlockBuilder
Seal set root hash on header
func (*BlockBuilder) Sealed ¶
func (bb *BlockBuilder) Sealed(sealed bool) *BlockBuilder
Sealed sets sealed
func (*BlockBuilder) Sign ¶
func (bb *BlockBuilder) Sign(sign []byte) *BlockBuilder
Sign sets signature.
func (*BlockBuilder) SignKey ¶
func (bb *BlockBuilder) SignKey(key signature.PrivateKey) *BlockBuilder
SignKey signs by private key
func (*BlockBuilder) SignPair ¶
func (bb *BlockBuilder) SignPair(pair *keyutil.AddrKeyPair) *BlockBuilder
SignPair set coinbase, seal, calculate hash and sign with key pair
func (*BlockBuilder) SignProposer ¶
func (bb *BlockBuilder) SignProposer() *BlockBuilder
SignProposer find proposer and sign with key pair
func (*BlockBuilder) Stake ¶
func (bb *BlockBuilder) Stake() *BlockBuilder
Stake executes stake transactions.
func (*BlockBuilder) Supply ¶
func (bb *BlockBuilder) Supply(supply string) *BlockBuilder
Supply sets supply.
func (*BlockBuilder) Timestamp ¶
func (bb *BlockBuilder) Timestamp(ts int64) *BlockBuilder
Timestamp sets timestamp.
func (*BlockBuilder) TxRoot ¶
func (bb *BlockBuilder) TxRoot(root []byte) *BlockBuilder
TxRoot sets data state root.
func (*BlockBuilder) UpdateDynastyState ¶
func (bb *BlockBuilder) UpdateDynastyState(parent *core.Block) *BlockBuilder
UpdateDynastyState update dynasty state
type Expect ¶
type Expect struct {
// contains filtered or unexported fields
}
Expect is a structure for expect
func (*Expect) LastPointsTs ¶
LastPointsTs compares last update time of points
func (*Expect) LastUnstakingTs ¶
LastUnstakingTs compares last update time of unstaking
type TxBuilder ¶
type TxBuilder struct {
// contains filtered or unexported fields
}
TxBuilder is a structure for transaction builder
func (*TxBuilder) Add ¶
func (tb *TxBuilder) Add() *BlockBuilder
Add add transaction on block builder
func (*TxBuilder) BuildBytes ¶
BuildBytes build marshaled transaction
func (*TxBuilder) BuildProto ¶
func (tb *TxBuilder) BuildProto() *corepb.Transaction
BuildProto build protobuf transaction
func (*TxBuilder) Execute ¶
func (tb *TxBuilder) Execute() *BlockBuilder
Execute excute transaction on block builder
func (*TxBuilder) ExecuteErr ¶
func (tb *TxBuilder) ExecuteErr(err error) *BlockBuilder
ExecuteErr expect error occurred on executing
func (*TxBuilder) Payload ¶
func (tb *TxBuilder) Payload(payload transaction.Payload) *TxBuilder
Payload sets payload
func (*TxBuilder) RandomTxs ¶
func (tb *TxBuilder) RandomTxs(n int) []*core.Transaction
RandomTxs generate random transactions
func (*TxBuilder) SignKey ¶
func (tb *TxBuilder) SignKey(key signature.PrivateKey) *TxBuilder
SignKey sign by private key
func (*TxBuilder) SignPair ¶
func (tb *TxBuilder) SignPair(pair *keyutil.AddrKeyPair) *TxBuilder
SignPair set from, seal ,calculate hash and sign with key pair
func (*TxBuilder) SignPairWithNonce ¶
func (tb *TxBuilder) SignPairWithNonce(pair *keyutil.AddrKeyPair, nonce uint64) *TxBuilder
SignPairWithNonce set from, calculate hash, and sign with key pair.
func (*TxBuilder) SignPayerKey ¶
func (tb *TxBuilder) SignPayerKey(key signature.PrivateKey) *TxBuilder
SignPayerKey sign by payer private key TODO Make SignPayerKey consistent with SignKey
func (*TxBuilder) SignPayerPair ¶
func (tb *TxBuilder) SignPayerPair(pair *keyutil.AddrKeyPair) *TxBuilder
SignPayerPair sets payer and sign transaction by payer key.
func (*TxBuilder) StakeTx ¶
func (tb *TxBuilder) StakeTx(pair *keyutil.AddrKeyPair, med float64) *TxBuilder
StakeTx generate stake Tx