forked from TrueCloudLab/neoneo-go
Merge pull request #1068 from nspcc-dev/fix/free
Remove logic related to free transactions
This commit is contained in:
commit
c281944c9b
18 changed files with 22 additions and 106 deletions
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 5195086
|
Magic: 5195086
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.001
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c
|
- 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c
|
||||||
|
@ -19,11 +18,7 @@ ProtocolConfiguration:
|
||||||
- seed5.neo.org:10333
|
- seed5.neo.org:10333
|
||||||
VerifyBlocks: true
|
VerifyBlocks: true
|
||||||
VerifyTransactions: false
|
VerifyTransactions: false
|
||||||
FreeGasLimit: 10.0
|
|
||||||
MaxTransactionsPerBlock: 500
|
MaxTransactionsPerBlock: 500
|
||||||
MaxFreeTransactionsPerBlock: 20
|
|
||||||
MaxFreeTransactionSize: 1024
|
|
||||||
FeePerExtraByte: 0.00001
|
|
||||||
|
|
||||||
ApplicationConfiguration:
|
ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 1
|
SecondsPerBlock: 1
|
||||||
LowPriorityThreshold: 0.001
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 56753
|
Magic: 56753
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 1951352142
|
Magic: 1951352142
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 023e9b32ea89b94d066e649b124fd50e396ee91369e8e2a6ae1b11c170d022256d
|
- 023e9b32ea89b94d066e649b124fd50e396ee91369e8e2a6ae1b11c170d022256d
|
||||||
|
@ -19,11 +18,7 @@ ProtocolConfiguration:
|
||||||
- seed5t.neo.org:20333
|
- seed5t.neo.org:20333
|
||||||
VerifyBlocks: true
|
VerifyBlocks: true
|
||||||
VerifyTransactions: false
|
VerifyTransactions: false
|
||||||
FreeGasLimit: 10.0
|
|
||||||
MaxTransactionsPerBlock: 500
|
MaxTransactionsPerBlock: 500
|
||||||
MaxFreeTransactionsPerBlock: 20
|
|
||||||
MaxFreeTransactionSize: 1024
|
|
||||||
FeePerExtraByte: 0.00001
|
|
||||||
|
|
||||||
ApplicationConfiguration:
|
ApplicationConfiguration:
|
||||||
# LogPath could be set up in case you need stdout logs to some proper file.
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
ProtocolConfiguration:
|
ProtocolConfiguration:
|
||||||
Magic: 42
|
Magic: 42
|
||||||
SecondsPerBlock: 15
|
SecondsPerBlock: 15
|
||||||
LowPriorityThreshold: 0.000
|
|
||||||
MemPoolSize: 50000
|
MemPoolSize: 50000
|
||||||
StandbyValidators:
|
StandbyValidators:
|
||||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
|
|
@ -2,24 +2,13 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProtocolConfiguration represents the protocol config.
|
// ProtocolConfiguration represents the protocol config.
|
||||||
type (
|
type (
|
||||||
ProtocolConfiguration struct {
|
ProtocolConfiguration struct {
|
||||||
// FeePerExtraByte sets the expected per-byte fee for
|
|
||||||
// transactions exceeding the MaxFreeTransactionSize.
|
|
||||||
FeePerExtraByte float64 `yaml:"FeePerExtraByte"`
|
|
||||||
// FreeGasLimit is an amount of GAS which can be spent for free.
|
|
||||||
FreeGasLimit util.Fixed8 `yaml:"FreeGasLimit"`
|
|
||||||
LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"`
|
|
||||||
Magic netmode.Magic `yaml:"Magic"`
|
Magic netmode.Magic `yaml:"Magic"`
|
||||||
MaxTransactionsPerBlock int `yaml:"MaxTransactionsPerBlock"`
|
MaxTransactionsPerBlock int `yaml:"MaxTransactionsPerBlock"`
|
||||||
// Maximum size of low priority transaction in bytes.
|
|
||||||
MaxFreeTransactionSize int `yaml:"MaxFreeTransactionSize"`
|
|
||||||
// Maximum number of low priority transactions accepted into block.
|
|
||||||
MaxFreeTransactionsPerBlock int `yaml:"MaxFreeTransactionsPerBlock"`
|
|
||||||
MemPoolSize int `yaml:"MemPoolSize"`
|
MemPoolSize int `yaml:"MemPoolSize"`
|
||||||
// SaveStorageBatch enables storage batch saving before every persist.
|
// SaveStorageBatch enables storage batch saving before every persist.
|
||||||
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
SaveStorageBatch bool `yaml:"SaveStorageBatch"`
|
||||||
|
|
|
@ -229,10 +229,6 @@ func newTestChain(t *testing.T) *core.Blockchain {
|
||||||
return chain
|
return chain
|
||||||
}
|
}
|
||||||
|
|
||||||
type feer struct{}
|
|
||||||
|
|
||||||
func (fs *feer) IsLowPriority(util.Fixed8) bool { return false }
|
|
||||||
|
|
||||||
var neoOwner = testchain.MultisigScriptHash()
|
var neoOwner = testchain.MultisigScriptHash()
|
||||||
|
|
||||||
func addSender(t *testing.T, txs ...*transaction.Transaction) {
|
func addSender(t *testing.T, txs ...*transaction.Transaction) {
|
||||||
|
|
|
@ -156,18 +156,6 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
|
||||||
cfg.MaxTransactionsPerBlock = 0
|
cfg.MaxTransactionsPerBlock = 0
|
||||||
log.Info("MaxTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxTransactionsPerBlock", cfg.MaxTransactionsPerBlock))
|
log.Info("MaxTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxTransactionsPerBlock", cfg.MaxTransactionsPerBlock))
|
||||||
}
|
}
|
||||||
if cfg.MaxFreeTransactionsPerBlock <= 0 {
|
|
||||||
cfg.MaxFreeTransactionsPerBlock = 0
|
|
||||||
log.Info("MaxFreeTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxFreeTransactionsPerBlock", cfg.MaxFreeTransactionsPerBlock))
|
|
||||||
}
|
|
||||||
if cfg.MaxFreeTransactionSize <= 0 {
|
|
||||||
cfg.MaxFreeTransactionSize = 0
|
|
||||||
log.Info("MaxFreeTransactionSize is not set or wrong, setting default value (unlimited)", zap.Int("MaxFreeTransactionSize", cfg.MaxFreeTransactionSize))
|
|
||||||
}
|
|
||||||
if cfg.FeePerExtraByte <= 0 {
|
|
||||||
cfg.FeePerExtraByte = 0
|
|
||||||
log.Info("FeePerExtraByte is not set or wrong, setting default value", zap.Float64("FeePerExtraByte", cfg.FeePerExtraByte))
|
|
||||||
}
|
|
||||||
bc := &Blockchain{
|
bc := &Blockchain{
|
||||||
config: cfg,
|
config: cfg,
|
||||||
dao: dao.NewSimple(s, cfg.Magic),
|
dao: dao.NewSimple(s, cfg.Magic),
|
||||||
|
@ -605,9 +593,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
|
||||||
v := SpawnVM(systemInterop)
|
v := SpawnVM(systemInterop)
|
||||||
v.LoadScriptWithFlags(tx.Script, smartcontract.All)
|
v.LoadScriptWithFlags(tx.Script, smartcontract.All)
|
||||||
v.SetPriceGetter(getPrice)
|
v.SetPriceGetter(getPrice)
|
||||||
if bc.config.FreeGasLimit > 0 {
|
v.GasLimit = tx.SystemFee
|
||||||
v.GasLimit = bc.config.FreeGasLimit + tx.SystemFee
|
|
||||||
}
|
|
||||||
|
|
||||||
err := v.Run()
|
err := v.Run()
|
||||||
if !v.HasFailed() {
|
if !v.HasFailed() {
|
||||||
|
@ -1102,12 +1088,6 @@ func (bc *Blockchain) FeePerByte() util.Fixed8 {
|
||||||
return util.Fixed8(1000)
|
return util.Fixed8(1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLowPriority checks given fee for being less than configured
|
|
||||||
// LowPriorityThreshold.
|
|
||||||
func (bc *Blockchain) IsLowPriority(fee util.Fixed8) bool {
|
|
||||||
return fee < util.Fixed8FromFloat(bc.GetConfig().LowPriorityThreshold)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMemPool returns the memory pool of the blockchain.
|
// GetMemPool returns the memory pool of the blockchain.
|
||||||
func (bc *Blockchain) GetMemPool() *mempool.Pool {
|
func (bc *Blockchain) GetMemPool() *mempool.Pool {
|
||||||
return &bc.memPool
|
return &bc.memPool
|
||||||
|
@ -1119,15 +1099,6 @@ func (bc *Blockchain) ApplyPolicyToTxSet(txes []*transaction.Transaction) []*tra
|
||||||
if bc.config.MaxTransactionsPerBlock != 0 && len(txes) > bc.config.MaxTransactionsPerBlock {
|
if bc.config.MaxTransactionsPerBlock != 0 && len(txes) > bc.config.MaxTransactionsPerBlock {
|
||||||
txes = txes[:bc.config.MaxTransactionsPerBlock]
|
txes = txes[:bc.config.MaxTransactionsPerBlock]
|
||||||
}
|
}
|
||||||
maxFree := bc.config.MaxFreeTransactionsPerBlock
|
|
||||||
if maxFree != 0 {
|
|
||||||
lowStart := sort.Search(len(txes), func(i int) bool {
|
|
||||||
return bc.IsLowPriority(txes[i].NetworkFee)
|
|
||||||
})
|
|
||||||
if lowStart+maxFree < len(txes) {
|
|
||||||
txes = txes[:lowStart+maxFree]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return txes
|
return txes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,14 +1198,6 @@ func (bc *Blockchain) PoolTx(t *transaction.Transaction) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Policying.
|
// Policying.
|
||||||
txSize := io.GetVarSize(t)
|
|
||||||
maxFree := bc.config.MaxFreeTransactionSize
|
|
||||||
if maxFree != 0 && txSize > maxFree {
|
|
||||||
if bc.IsLowPriority(t.NetworkFee) ||
|
|
||||||
t.NetworkFee < util.Fixed8FromFloat(bc.config.FeePerExtraByte)*util.Fixed8(txSize-maxFree) {
|
|
||||||
return ErrPolicy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := bc.memPool.Add(t, bc); err != nil {
|
if err := bc.memPool.Add(t, bc); err != nil {
|
||||||
switch err {
|
switch err {
|
||||||
case mempool.ErrOOM:
|
case mempool.ErrOOM:
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
|
|
||||||
// Feer is an interface that abstract the implementation of the fee calculation.
|
// Feer is an interface that abstract the implementation of the fee calculation.
|
||||||
type Feer interface {
|
type Feer interface {
|
||||||
IsLowPriority(util.Fixed8) bool
|
|
||||||
FeePerByte() util.Fixed8
|
FeePerByte() util.Fixed8
|
||||||
GetUtilityTokenBalance(util.Uint160) util.Fixed8
|
GetUtilityTokenBalance(util.Uint160) util.Fixed8
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ var (
|
||||||
type item struct {
|
type item struct {
|
||||||
txn *transaction.Transaction
|
txn *transaction.Transaction
|
||||||
timeStamp time.Time
|
timeStamp time.Time
|
||||||
isLowPrio bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// items is a slice of item.
|
// items is a slice of item.
|
||||||
|
@ -63,14 +62,6 @@ func (p *item) CompareTo(otherP *item) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.isLowPrio && otherP.isLowPrio {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.isLowPrio && !otherP.isLowPrio {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fees sorted ascending.
|
// Fees sorted ascending.
|
||||||
if ret := p.txn.FeePerByte().CompareTo(otherP.txn.FeePerByte()); ret != 0 {
|
if ret := p.txn.FeePerByte().CompareTo(otherP.txn.FeePerByte()); ret != 0 {
|
||||||
return ret
|
return ret
|
||||||
|
@ -151,7 +142,6 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error {
|
||||||
txn: t,
|
txn: t,
|
||||||
timeStamp: time.Now().UTC(),
|
timeStamp: time.Now().UTC(),
|
||||||
}
|
}
|
||||||
pItem.isLowPrio = fee.IsLowPriority(pItem.txn.NetworkFee)
|
|
||||||
mp.lock.Lock()
|
mp.lock.Lock()
|
||||||
if !mp.checkTxConflicts(t, fee) {
|
if !mp.checkTxConflicts(t, fee) {
|
||||||
mp.lock.Unlock()
|
mp.lock.Unlock()
|
||||||
|
|
|
@ -13,14 +13,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type FeerStub struct {
|
type FeerStub struct {
|
||||||
lowPriority bool
|
|
||||||
feePerByte util.Fixed8
|
feePerByte util.Fixed8
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FeerStub) IsLowPriority(util.Fixed8) bool {
|
|
||||||
return fs.lowPriority
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
||||||
return fs.feePerByte
|
return fs.feePerByte
|
||||||
}
|
}
|
||||||
|
@ -50,14 +45,12 @@ func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMemPoolAddRemove(t *testing.T) {
|
func TestMemPoolAddRemove(t *testing.T) {
|
||||||
var fs = &FeerStub{lowPriority: false}
|
var fs = &FeerStub{}
|
||||||
t.Run("low priority", func(t *testing.T) { testMemPoolAddRemoveWithFeer(t, fs) })
|
testMemPoolAddRemoveWithFeer(t, fs)
|
||||||
fs.lowPriority = true
|
|
||||||
t.Run("high priority", func(t *testing.T) { testMemPoolAddRemoveWithFeer(t, fs) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverCapacity(t *testing.T) {
|
func TestOverCapacity(t *testing.T) {
|
||||||
var fs = &FeerStub{lowPriority: true}
|
var fs = &FeerStub{}
|
||||||
const mempoolSize = 10
|
const mempoolSize = 10
|
||||||
mp := NewMemPool(mempoolSize)
|
mp := NewMemPool(mempoolSize)
|
||||||
|
|
||||||
|
@ -110,9 +103,9 @@ func TestOverCapacity(t *testing.T) {
|
||||||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||||
|
|
||||||
// High priority always wins over low priority.
|
// High priority always wins over low priority.
|
||||||
fs.lowPriority = false
|
|
||||||
for i := 0; i < mempoolSize; i++ {
|
for i := 0; i < mempoolSize; i++ {
|
||||||
tx := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
tx := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
||||||
|
tx.NetworkFee = util.Fixed8FromFloat(0.00008)
|
||||||
tx.Nonce = txcnt
|
tx.Nonce = txcnt
|
||||||
txcnt++
|
txcnt++
|
||||||
require.NoError(t, mp.Add(tx, fs))
|
require.NoError(t, mp.Add(tx, fs))
|
||||||
|
@ -120,16 +113,16 @@ func TestOverCapacity(t *testing.T) {
|
||||||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||||
}
|
}
|
||||||
// Good luck with low priority now.
|
// Good luck with low priority now.
|
||||||
fs.lowPriority = true
|
|
||||||
tx = transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
tx = transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
||||||
tx.Nonce = txcnt
|
tx.Nonce = txcnt
|
||||||
|
tx.NetworkFee = util.Fixed8FromFloat(0.00007)
|
||||||
require.Error(t, mp.Add(tx, fs))
|
require.Error(t, mp.Add(tx, fs))
|
||||||
require.Equal(t, mempoolSize, mp.Count())
|
require.Equal(t, mempoolSize, mp.Count())
|
||||||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetVerified(t *testing.T) {
|
func TestGetVerified(t *testing.T) {
|
||||||
var fs = &FeerStub{lowPriority: true}
|
var fs = &FeerStub{}
|
||||||
const mempoolSize = 10
|
const mempoolSize = 10
|
||||||
mp := NewMemPool(mempoolSize)
|
mp := NewMemPool(mempoolSize)
|
||||||
|
|
||||||
|
@ -152,7 +145,7 @@ func TestGetVerified(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoveStale(t *testing.T) {
|
func TestRemoveStale(t *testing.T) {
|
||||||
var fs = &FeerStub{lowPriority: true}
|
var fs = &FeerStub{}
|
||||||
const mempoolSize = 10
|
const mempoolSize = 10
|
||||||
mp := NewMemPool(mempoolSize)
|
mp := NewMemPool(mempoolSize)
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,14 @@ func TestNativeContract_Invoke(t *testing.T) {
|
||||||
tx.ValidUntilBlock = validUntil
|
tx.ValidUntilBlock = validUntil
|
||||||
require.NoError(t, addSender(tx))
|
require.NoError(t, addSender(tx))
|
||||||
require.NoError(t, signTx(chain, tx))
|
require.NoError(t, signTx(chain, tx))
|
||||||
b := chain.newBlock(tx)
|
|
||||||
|
// Enough for Call and other opcodes, but not enough for "sum" call.
|
||||||
|
tx2 := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2)
|
||||||
|
tx2.ValidUntilBlock = chain.blockHeight + 1
|
||||||
|
require.NoError(t, addSender(tx2))
|
||||||
|
require.NoError(t, signTx(chain, tx2))
|
||||||
|
|
||||||
|
b := chain.newBlock(tx, tx2)
|
||||||
require.NoError(t, chain.AddBlock(b))
|
require.NoError(t, chain.AddBlock(b))
|
||||||
|
|
||||||
res, err := chain.GetAppExecResult(tx.Hash())
|
res, err := chain.GetAppExecResult(tx.Hash())
|
||||||
|
@ -117,6 +124,10 @@ func TestNativeContract_Invoke(t *testing.T) {
|
||||||
require.Equal(t, smartcontract.IntegerType, res.Stack[0].Type)
|
require.Equal(t, smartcontract.IntegerType, res.Stack[0].Type)
|
||||||
require.EqualValues(t, 42, res.Stack[0].Value)
|
require.EqualValues(t, 42, res.Stack[0].Value)
|
||||||
|
|
||||||
|
res, err = chain.GetAppExecResult(tx2.Hash())
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, "FAULT", res.VMState)
|
||||||
|
|
||||||
require.NoError(t, chain.persist())
|
require.NoError(t, chain.persist())
|
||||||
select {
|
select {
|
||||||
case index := <-tn.blocks:
|
case index := <-tn.blocks:
|
||||||
|
|
|
@ -123,10 +123,6 @@ func (chain testChain) GetMemPool() *mempool.Pool {
|
||||||
panic("TODO")
|
panic("TODO")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (chain testChain) IsLowPriority(util.Fixed8) bool {
|
|
||||||
panic("TODO")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (chain testChain) GetGoverningTokenBalance(acc util.Uint160) (util.Fixed8, uint32) {
|
func (chain testChain) GetGoverningTokenBalance(acc util.Uint160) (util.Fixed8, uint32) {
|
||||||
panic("TODO")
|
panic("TODO")
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,10 +85,6 @@ func initServerWithInMemoryChain(t *testing.T) (*core.Blockchain, *Server, *http
|
||||||
|
|
||||||
type FeerStub struct{}
|
type FeerStub struct{}
|
||||||
|
|
||||||
func (fs *FeerStub) IsLowPriority(util.Fixed8) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue