forked from TrueCloudLab/neoneo-go
integration: drop this old test
It's not very useful especially given that we have proper neo-bench now.
This commit is contained in:
parent
acc2265169
commit
9440e9acbc
3 changed files with 0 additions and 131 deletions
|
@ -1,20 +0,0 @@
|
|||
# Integration package
|
||||
The main goal is to have integration tests here.
|
||||
|
||||
### Performance test
|
||||
Right now we have `performance_test.go` to measure number of processed TX per second.
|
||||
In order to run it:
|
||||
```
|
||||
$ cd integration
|
||||
$ go test -bench=. -benchmem
|
||||
```
|
||||
|
||||
Result:
|
||||
```
|
||||
10000 402421 ns/op 177370 B/op 90 allocs/op
|
||||
PASS
|
||||
ok github.com/nspcc-dev/neo-go/integration 4.360s
|
||||
|
||||
```
|
||||
|
||||
Which means that in 4.360 seconds neo-go processes 10 000 transactions.
|
|
@ -1,105 +0,0 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/network"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
// Benchmark test to measure number of processed TX.
|
||||
// Same benchmark made on reference C# node https://github.com/neo-project/neo/issues/1321.
|
||||
func BenchmarkTXPerformanceTest(t *testing.B) {
|
||||
net := netmode.UnitTestNet
|
||||
configPath := "../config"
|
||||
cfg, err := config.Load(configPath, net)
|
||||
require.NoError(t, err, "could not load config")
|
||||
|
||||
logger := zaptest.NewLogger(t)
|
||||
memoryStore := storage.NewMemoryStore()
|
||||
chain, err := core.NewBlockchain(memoryStore, cfg.ProtocolConfiguration, logger)
|
||||
require.NoError(t, err, "could not create chain")
|
||||
|
||||
go chain.Run()
|
||||
|
||||
serverConfig := network.NewServerConfig(cfg)
|
||||
server, err := network.NewServer(serverConfig, chain, logger)
|
||||
require.NoError(t, err, "could not create server")
|
||||
data := prepareData(t)
|
||||
t.ResetTimer()
|
||||
|
||||
for n := 0; n < t.N; n++ {
|
||||
assert.Equal(t, network.RelaySucceed, server.RelayTxn(data[n]))
|
||||
assert.Equal(t, network.RelayAlreadyExists, server.RelayTxn(data[n]))
|
||||
}
|
||||
chain.Close()
|
||||
}
|
||||
|
||||
func prepareData(t *testing.B) []*transaction.Transaction {
|
||||
var data []*transaction.Transaction
|
||||
|
||||
wif := getWif(t)
|
||||
acc, err := wallet.NewAccountFromWIF(wif.S)
|
||||
require.NoError(t, err)
|
||||
|
||||
for n := 0; n < t.N; n++ {
|
||||
tx := getTX(t, wif)
|
||||
require.NoError(t, acc.SignTx(tx))
|
||||
data = append(data, tx)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// getWif returns Wif.
|
||||
func getWif(t *testing.B) *keys.WIF {
|
||||
var (
|
||||
wifEncoded = "KxhEDBQyyEFymvfJD96q8stMbJMbZUb6D1PmXqBWZDU2WvbvVs9o"
|
||||
version = byte(0x00)
|
||||
)
|
||||
wif, err := keys.WIFDecode(wifEncoded, version)
|
||||
require.NoError(t, err)
|
||||
return wif
|
||||
}
|
||||
|
||||
// getTX returns Invocation transaction with some random attributes in order to have different hashes.
|
||||
func getTX(t *testing.B, wif *keys.WIF) *transaction.Transaction {
|
||||
fromAddress := wif.PrivateKey.Address()
|
||||
fromAddressHash, err := address.StringToUint160(fromAddress)
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := transaction.New(netmode.UnitTestNet, []byte{0x51}, 1)
|
||||
tx.Version = 0
|
||||
tx.Signers = []transaction.Signer{
|
||||
{
|
||||
Account: fromAddressHash,
|
||||
Scopes: transaction.FeeOnly,
|
||||
},
|
||||
}
|
||||
return tx
|
||||
}
|
||||
|
||||
// String returns a random string with the n as its length.
|
||||
func randString(n int) string {
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = byte(Int(65, 90))
|
||||
}
|
||||
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// Int returns a random integer in [min,max).
|
||||
func Int(min, max int) int {
|
||||
return min + rand.Intn(max-min)
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
// Package integration contains integration tests.
|
||||
// See README.md for more info.
|
||||
// This file exists with the sole purpose to get rid of
|
||||
// "go build github.com/nspcc-dev/neo-go/integration: no non-test Go files in *"
|
||||
// when running `go test -coverpkg=all`.
|
||||
package integration
|
Loading…
Reference in a new issue