-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b047334
commit 71abc3d
Showing
24 changed files
with
2,074 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,350 @@ | ||
package testchain | ||
|
||
import ( | ||
"math/big" | ||
"strings" | ||
"sync/atomic" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/config" | ||
"github.com/nspcc-dev/neo-go/pkg/core/block" | ||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer" | ||
"github.com/nspcc-dev/neo-go/pkg/core/mempool" | ||
"github.com/nspcc-dev/neo-go/pkg/core/state" | ||
"github.com/nspcc-dev/neo-go/pkg/core/transaction" | ||
"github.com/nspcc-dev/neo-go/pkg/crypto" | ||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" | ||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" | ||
"github.com/nspcc-dev/neo-go/pkg/util" | ||
"github.com/nspcc-dev/neo-go/pkg/vm" | ||
) | ||
|
||
// TestChain is a fake structure which implements Blockchainer interface. | ||
type TestChain struct { | ||
Blockheight uint32 | ||
UtilityTokenBalance *big.Int | ||
FeePerByteValue int64 | ||
P2PSigExtEnabled bool | ||
DepositBalance *big.Int | ||
DepositExpiration uint32 | ||
NotaryScriptHash util.Uint160 | ||
MaxNotValidBeforeDelta uint32 | ||
} | ||
|
||
// ApplyPolicyToTxSet implements Blockchainer interface. | ||
func (chain TestChain) ApplyPolicyToTxSet([]*transaction.Transaction) []*transaction.Transaction { | ||
panic("TODO") | ||
} | ||
|
||
// GetConfig implements Blockchainer interface. | ||
func (chain TestChain) GetConfig() config.ProtocolConfiguration { | ||
panic("TODO") | ||
} | ||
|
||
// CalculateClaimable implements Blockchainer interface. | ||
func (chain TestChain) CalculateClaimable(util.Uint160, uint32) (*big.Int, error) { | ||
panic("TODO") | ||
} | ||
|
||
// FeePerByte implements Blockchainer interface. | ||
func (chain TestChain) FeePerByte() int64 { | ||
if chain.FeePerByteValue != 0 { | ||
return chain.FeePerByteValue | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// P2PSigExtensionsEnabled implements Blockchainer interface. | ||
func (chain TestChain) P2PSigExtensionsEnabled() bool { | ||
return chain.P2PSigExtEnabled | ||
} | ||
|
||
// GetMaxBlockSystemFee implements Blockchainer interface. | ||
func (chain TestChain) GetMaxBlockSystemFee() int64 { | ||
panic("TODO") | ||
} | ||
|
||
// GetMaxBlockSize implements Blockchainer interface. | ||
func (chain TestChain) GetMaxBlockSize() uint32 { | ||
panic("TODO") | ||
} | ||
|
||
// AddHeaders implements Blockchainer interface. | ||
func (chain TestChain) AddHeaders(...*block.Header) error { | ||
panic("TODO") | ||
} | ||
|
||
// AddBlock implements Blockchainer interface. | ||
func (chain *TestChain) AddBlock(block *block.Block) error { | ||
if block.Index == chain.Blockheight+1 { | ||
atomic.StoreUint32(&chain.Blockheight, block.Index) | ||
} | ||
return nil | ||
} | ||
|
||
// AddStateRoot implements Blockchainer interface. | ||
func (chain *TestChain) AddStateRoot(r *state.MPTRoot) error { | ||
panic("TODO") | ||
} | ||
|
||
// BlockHeight implements Blockchainer interface. | ||
func (chain *TestChain) BlockHeight() uint32 { | ||
return atomic.LoadUint32(&chain.Blockheight) | ||
} | ||
|
||
// Close implements Blockchainer interface. | ||
func (chain *TestChain) Close() { | ||
panic("TODO") | ||
} | ||
|
||
// GetDepositExpiration implements Blockchainer interface. | ||
func (chain *TestChain) GetDepositExpiration(acc util.Uint160) uint32 { | ||
if chain.DepositExpiration != 0 { | ||
return chain.DepositExpiration | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// GetDepositBalance implements Blockchainer interface. | ||
func (chain *TestChain) GetDepositBalance(acc util.Uint160) *big.Int { | ||
if chain.DepositBalance != nil { | ||
return chain.DepositBalance | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// GetMaxNotValidBeforeDelta implements Blockchainer interface. | ||
func (chain *TestChain) GetMaxNotValidBeforeDelta() uint32 { | ||
if chain.MaxNotValidBeforeDelta != 0 { | ||
return chain.MaxNotValidBeforeDelta | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// GetMaxVerificationGAS implements Blockchainer interface. | ||
func (chain *TestChain) GetMaxVerificationGAS() int64 { | ||
panic("TODO") | ||
} | ||
|
||
// GetPolicer implements Blockchainer interface. | ||
func (chain *TestChain) GetPolicer() blockchainer.Policer { | ||
return chain | ||
} | ||
|
||
// RegisterPostBlock implements Blockchainer interface. | ||
func (chain *TestChain) RegisterPostBlock(f func(blockchainer.Blockchainer, *mempool.Pool, *block.Block)) { | ||
panic("TODO") | ||
} | ||
|
||
// HeaderHeight implements Blockchainer interface. | ||
func (chain TestChain) HeaderHeight() uint32 { | ||
return 0 | ||
} | ||
|
||
// GetAppExecResults implements Blockchainer interface. | ||
func (chain TestChain) GetAppExecResults(hash util.Uint256, trig trigger.Type) ([]state.AppExecResult, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetBlock implements Blockchainer interface. | ||
func (chain TestChain) GetBlock(hash util.Uint256) (*block.Block, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetCommittee implements Blockchainer interface. | ||
func (chain TestChain) GetCommittee() (keys.PublicKeys, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetContractState implements Blockchainer interface. | ||
func (chain TestChain) GetContractState(hash util.Uint160) *state.Contract { | ||
panic("TODO") | ||
} | ||
|
||
// GetContractScriptHash implements Blockchainer interface. | ||
func (chain TestChain) GetContractScriptHash(id int32) (util.Uint160, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetNativeContractScriptHash implements Blockchainer interface. | ||
func (chain TestChain) GetNativeContractScriptHash(name string) (util.Uint160, error) { | ||
switch strings.ToLower(name) { | ||
case "notary": | ||
if !chain.NotaryScriptHash.Equals(util.Uint160{}) { | ||
return chain.NotaryScriptHash, nil | ||
} | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// GetHeaderHash implements Blockchainer interface. | ||
func (chain TestChain) GetHeaderHash(int) util.Uint256 { | ||
return util.Uint256{} | ||
} | ||
|
||
// GetHeader implements Blockchainer interface. | ||
func (chain TestChain) GetHeader(hash util.Uint256) (*block.Header, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetNextBlockValidators implements Blockchainer interface. | ||
func (chain TestChain) GetNextBlockValidators() ([]*keys.PublicKey, error) { | ||
panic("TODO") | ||
} | ||
|
||
// ForEachNEP17Transfer implements Blockchainer interface. | ||
func (chain TestChain) ForEachNEP17Transfer(util.Uint160, func(*state.NEP17Transfer) (bool, error)) error { | ||
panic("TODO") | ||
} | ||
|
||
// GetNEP17Balances implements Blockchainer interface. | ||
func (chain TestChain) GetNEP17Balances(util.Uint160) *state.NEP17Balances { | ||
panic("TODO") | ||
} | ||
|
||
// GetValidators implements Blockchainer interface. | ||
func (chain TestChain) GetValidators() ([]*keys.PublicKey, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetStandByCommittee implements Blockchainer interface. | ||
func (chain TestChain) GetStandByCommittee() keys.PublicKeys { | ||
panic("TODO") | ||
} | ||
|
||
// GetStandByValidators implements Blockchainer interface. | ||
func (chain TestChain) GetStandByValidators() keys.PublicKeys { | ||
panic("TODO") | ||
} | ||
|
||
// GetEnrollments implements Blockchainer interface. | ||
func (chain TestChain) GetEnrollments() ([]state.Validator, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetStateProof implements Blockchainer interface. | ||
func (chain TestChain) GetStateProof(util.Uint256, []byte) ([][]byte, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetStateRoot implements Blockchainer interface. | ||
func (chain TestChain) GetStateRoot(height uint32) (*state.MPTRootState, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetStorageItem implements Blockchainer interface. | ||
func (chain TestChain) GetStorageItem(id int32, key []byte) *state.StorageItem { | ||
panic("TODO") | ||
} | ||
|
||
// GetTestVM implements Blockchainer interface. | ||
func (chain TestChain) GetTestVM(tx *transaction.Transaction, b *block.Block) *vm.VM { | ||
panic("TODO") | ||
} | ||
|
||
// GetStorageItems implements Blockchainer interface. | ||
func (chain TestChain) GetStorageItems(id int32) (map[string]*state.StorageItem, error) { | ||
panic("TODO") | ||
} | ||
|
||
// CurrentHeaderHash implements Blockchainer interface. | ||
func (chain TestChain) CurrentHeaderHash() util.Uint256 { | ||
return util.Uint256{} | ||
} | ||
|
||
// CurrentBlockHash implements Blockchainer interface. | ||
func (chain TestChain) CurrentBlockHash() util.Uint256 { | ||
return util.Uint256{} | ||
} | ||
|
||
// HasBlock implements Blockchainer interface. | ||
func (chain TestChain) HasBlock(util.Uint256) bool { | ||
return false | ||
} | ||
|
||
// HasTransaction implements Blockchainer interface. | ||
func (chain TestChain) HasTransaction(util.Uint256) bool { | ||
return false | ||
} | ||
|
||
// GetTransaction implements Blockchainer interface. | ||
func (chain TestChain) GetTransaction(util.Uint256) (*transaction.Transaction, uint32, error) { | ||
panic("TODO") | ||
} | ||
|
||
// GetMemPool implements Blockchainer interface. | ||
func (chain TestChain) GetMemPool() *mempool.Pool { | ||
panic("TODO") | ||
} | ||
|
||
// GetGoverningTokenBalance implements Blockchainer interface. | ||
func (chain TestChain) GetGoverningTokenBalance(acc util.Uint160) (*big.Int, uint32) { | ||
panic("TODO") | ||
} | ||
|
||
// GetUtilityTokenBalance implements Blockchainer interface. | ||
func (chain TestChain) GetUtilityTokenBalance(uint160 util.Uint160) *big.Int { | ||
if chain.UtilityTokenBalance != nil { | ||
return chain.UtilityTokenBalance | ||
} | ||
panic("TODO") | ||
} | ||
|
||
// PoolTx implements Blockchainer interface. | ||
func (chain TestChain) PoolTx(*transaction.Transaction, ...*mempool.Pool) error { | ||
panic("TODO") | ||
} | ||
|
||
// RunWithCurrentState implements Blockchainer interface. | ||
func (chain TestChain) RunWithCurrentState(f func() error) error { | ||
panic("TODO") | ||
} | ||
|
||
// SubscribeForBlocks implements Blockchainer interface. | ||
func (chain TestChain) SubscribeForBlocks(ch chan<- *block.Block) { | ||
panic("TODO") | ||
} | ||
|
||
// SubscribeForExecutions implements Blockchainer interface. | ||
func (chain TestChain) SubscribeForExecutions(ch chan<- *state.AppExecResult) { | ||
panic("TODO") | ||
} | ||
|
||
// SubscribeForNotifications implements Blockchainer interface. | ||
func (chain TestChain) SubscribeForNotifications(ch chan<- *state.NotificationEvent) { | ||
panic("TODO") | ||
} | ||
|
||
// SubscribeForTransactions implements Blockchainer interface. | ||
func (chain TestChain) SubscribeForTransactions(ch chan<- *transaction.Transaction) { | ||
panic("TODO") | ||
} | ||
|
||
// VerifyTx implements Blockchainer interface. | ||
func (chain TestChain) VerifyTx(*transaction.Transaction) error { | ||
panic("TODO") | ||
} | ||
|
||
// VerifyWitness implements Blockchainer interface. | ||
func (TestChain) VerifyWitness(util.Uint160, crypto.Verifiable, *transaction.Witness, int64) error { | ||
panic("TODO") | ||
} | ||
|
||
// UnsubscribeFromBlocks implements Blockchainer interface. | ||
func (chain TestChain) UnsubscribeFromBlocks(ch chan<- *block.Block) { | ||
panic("TODO") | ||
} | ||
|
||
// UnsubscribeFromExecutions implements Blockchainer interface. | ||
func (chain TestChain) UnsubscribeFromExecutions(ch chan<- *state.AppExecResult) { | ||
panic("TODO") | ||
} | ||
|
||
// UnsubscribeFromNotifications implements Blockchainer interface. | ||
func (chain TestChain) UnsubscribeFromNotifications(ch chan<- *state.NotificationEvent) { | ||
panic("TODO") | ||
} | ||
|
||
// UnsubscribeFromTransactions implements Blockchainer interface. | ||
func (chain TestChain) UnsubscribeFromTransactions(ch chan<- *transaction.Transaction) { | ||
panic("TODO") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.