mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
*: gofmt -s
Appy gofmt for all the source tree.
This commit is contained in:
parent
90469399d7
commit
fabd11699a
17 changed files with 29 additions and 32 deletions
|
@ -16,11 +16,11 @@ const (
|
||||||
userAgentFormat = "/NEO-GO:%s/"
|
userAgentFormat = "/NEO-GO:%s/"
|
||||||
|
|
||||||
// ModeMainNet contains magic code used in the NEO main official network.
|
// ModeMainNet contains magic code used in the NEO main official network.
|
||||||
ModeMainNet NetMode = 0x00746e41 // 7630401
|
ModeMainNet NetMode = 0x00746e41 // 7630401
|
||||||
// ModeTestNet contains magic code used in the NEO testing network.
|
// ModeTestNet contains magic code used in the NEO testing network.
|
||||||
ModeTestNet NetMode = 0x74746e41 // 1953787457
|
ModeTestNet NetMode = 0x74746e41 // 1953787457
|
||||||
// ModePrivNet contains magic code usually used for NEO private networks.
|
// ModePrivNet contains magic code usually used for NEO private networks.
|
||||||
ModePrivNet NetMode = 56753 // docker privnet
|
ModePrivNet NetMode = 56753 // docker privnet
|
||||||
// ModeUnitTestNet is a stub magic code used for testing purposes.
|
// ModeUnitTestNet is a stub magic code used for testing purposes.
|
||||||
ModeUnitTestNet NetMode = 0
|
ModeUnitTestNet NetMode = 0
|
||||||
)
|
)
|
||||||
|
|
|
@ -250,7 +250,6 @@ func TestBlockSizeCalculation(t *testing.T) {
|
||||||
assert.Equal(t, "552102486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a7021024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d2102aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e2103b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c2103b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a2102ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba5542102df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e89509357ae", hex.EncodeToString(b.Script.VerificationScript))
|
assert.Equal(t, "552102486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a7021024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d2102aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e2103b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c2103b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a2102ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba5542102df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e89509357ae", hex.EncodeToString(b.Script.VerificationScript))
|
||||||
assert.Equal(t, "0006d3ff96e269f599eb1b5c5a527c218439e498dcc65b63794591bbcdc0516b", b.Hash().ReverseString())
|
assert.Equal(t, "0006d3ff96e269f599eb1b5c5a527c218439e498dcc65b63794591bbcdc0516b", b.Hash().ReverseString())
|
||||||
|
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
err = b.EncodeBinary(buf)
|
err = b.EncodeBinary(buf)
|
||||||
|
|
|
@ -67,7 +67,7 @@ func (attr *Attribute) EncodeBinary(w io.Writer) error {
|
||||||
var urllen = uint8(len(attr.Data))
|
var urllen = uint8(len(attr.Data))
|
||||||
bw.WriteLE(urllen)
|
bw.WriteLE(urllen)
|
||||||
fallthrough
|
fallthrough
|
||||||
case Script, ContractHash, Vote, Hash1, Hash2, Hash3, Hash4, Hash5, Hash6,
|
case Script, ContractHash, Vote, Hash1, Hash2, Hash3, Hash4, Hash5, Hash6,
|
||||||
Hash7, Hash8, Hash9, Hash10, Hash11, Hash12, Hash13, Hash14, Hash15:
|
Hash7, Hash8, Hash9, Hash10, Hash11, Hash12, Hash13, Hash14, Hash15:
|
||||||
bw.WriteLE(attr.Data)
|
bw.WriteLE(attr.Data)
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -13,7 +13,7 @@ type InvocationTX struct {
|
||||||
Script []byte
|
Script []byte
|
||||||
|
|
||||||
// Gas cost of the smart contract.
|
// Gas cost of the smart contract.
|
||||||
Gas util.Fixed8
|
Gas util.Fixed8
|
||||||
Version uint8
|
Version uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func NewInvocationTX(script []byte) *Transaction {
|
||||||
func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
|
func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
|
||||||
br := util.BinReader{R: r}
|
br := util.BinReader{R: r}
|
||||||
tx.Script = br.ReadBytes()
|
tx.Script = br.ReadBytes()
|
||||||
if (tx.Version >= 1) {
|
if tx.Version >= 1 {
|
||||||
br.ReadLE(&tx.Gas)
|
br.ReadLE(&tx.Gas)
|
||||||
} else {
|
} else {
|
||||||
tx.Gas = util.Fixed8FromInt64(0)
|
tx.Gas = util.Fixed8FromInt64(0)
|
||||||
|
@ -48,7 +48,7 @@ func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
|
||||||
func (tx *InvocationTX) EncodeBinary(w io.Writer) error {
|
func (tx *InvocationTX) EncodeBinary(w io.Writer) error {
|
||||||
bw := util.BinWriter{W: w}
|
bw := util.BinWriter{W: w}
|
||||||
bw.WriteBytes(tx.Script)
|
bw.WriteBytes(tx.Script)
|
||||||
if (tx.Version >= 1) {
|
if tx.Version >= 1 {
|
||||||
bw.WriteLE(tx.Gas)
|
bw.WriteLE(tx.Gas)
|
||||||
}
|
}
|
||||||
return bw.Err
|
return bw.Err
|
||||||
|
@ -57,7 +57,7 @@ func (tx *InvocationTX) EncodeBinary(w io.Writer) error {
|
||||||
// Size returns serialized binary size for this transaction.
|
// Size returns serialized binary size for this transaction.
|
||||||
func (tx *InvocationTX) Size() int {
|
func (tx *InvocationTX) Size() int {
|
||||||
sz := util.GetVarSize(tx.Script)
|
sz := util.GetVarSize(tx.Script)
|
||||||
if (tx.Version >= 1) {
|
if tx.Version >= 1 {
|
||||||
sz += tx.Gas.Size()
|
sz += tx.Gas.Size()
|
||||||
}
|
}
|
||||||
return sz
|
return sz
|
||||||
|
|
|
@ -40,7 +40,6 @@ func NEP2ScryptParams() ScryptParams {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// NEP2Encrypt encrypts a the PrivateKey using a given passphrase
|
// NEP2Encrypt encrypts a the PrivateKey using a given passphrase
|
||||||
// under the NEP-2 standard.
|
// under the NEP-2 standard.
|
||||||
func NEP2Encrypt(priv *PrivateKey, passphrase string) (s string, err error) {
|
func NEP2Encrypt(priv *PrivateKey, passphrase string) (s string, err error) {
|
||||||
|
|
|
@ -5,11 +5,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/internal/keytestcases"
|
"github.com/CityOfZion/neo-go/pkg/internal/keytestcases"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestPrivateKey(t *testing.T) {
|
func TestPrivateKey(t *testing.T) {
|
||||||
for _, testCase := range keytestcases.Arr {
|
for _, testCase := range keytestcases.Arr {
|
||||||
privKey, err := NewPrivateKeyFromHex(testCase.PrivateKey)
|
privKey, err := NewPrivateKeyFromHex(testCase.PrivateKey)
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto"
|
"github.com/CityOfZion/neo-go/pkg/crypto"
|
||||||
|
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ func (p *PublicKey) DecodeBinary(r io.Reader) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
x = new(big.Int).SetBytes(xbytes)
|
x = new(big.Int).SetBytes(xbytes)
|
||||||
ylsb := uint(prefix&0x1)
|
ylsb := uint(prefix & 0x1)
|
||||||
y, err = decodeCompressedY(x, ylsb)
|
y, err = decodeCompressedY(x, ylsb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (wif WIF) GetVerificationScript() []byte {
|
||||||
)
|
)
|
||||||
var (
|
var (
|
||||||
vScript []byte
|
vScript []byte
|
||||||
pubkey *PublicKey
|
pubkey *PublicKey
|
||||||
)
|
)
|
||||||
pubkey = wif.PrivateKey.PublicKey()
|
pubkey = wif.PrivateKey.PublicKey()
|
||||||
vScript = append([]byte{pushbytes33}, pubkey.Bytes()...)
|
vScript = append([]byte{pushbytes33}, pubkey.Bytes()...)
|
||||||
|
|
|
@ -352,5 +352,5 @@ func (s *Server) RelayDirectly(p Peer, inv *payload.Inventory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||||
"github.com/CityOfZion/neo-go/pkg/util"
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/CityOfZion/neo-go/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
// AccountState wrapper used for the representation of
|
// AccountState wrapper used for the representation of
|
||||||
// core.AccountState on the RPC Server.
|
// core.AccountState on the RPC Server.
|
||||||
type AccountState struct {
|
type AccountState struct {
|
||||||
Version uint8 `json:"version"`
|
Version uint8 `json:"version"`
|
||||||
ScriptHash util.Uint160 `json:"script_hash"`
|
ScriptHash util.Uint160 `json:"script_hash"`
|
||||||
IsFrozen bool `json:"frozen"`
|
IsFrozen bool `json:"frozen"`
|
||||||
Votes []*keys.PublicKey `json:"votes"`
|
Votes []*keys.PublicKey `json:"votes"`
|
||||||
Balances []Balance `json:"balances"`
|
Balances []Balance `json:"balances"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Balances type for sorting balances in rpc response
|
// Balances type for sorting balances in rpc response
|
||||||
|
|
|
@ -170,9 +170,9 @@ func TestVarSize(t *testing.T) {
|
||||||
"test_string_3",
|
"test_string_3",
|
||||||
41,
|
41,
|
||||||
},
|
},
|
||||||
{[]*smthSerializable{&smthSerializable{}, &smthSerializable{}},
|
{[]*smthSerializable{{}, {}},
|
||||||
"test_Serializable",
|
"test_Serializable",
|
||||||
2 * 42 + 1,
|
2*42 + 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
||||||
|
|
||||||
case token.LOR:
|
case token.LOR:
|
||||||
ast.Walk(c, n.X)
|
ast.Walk(c, n.X)
|
||||||
emitJmp(c.prog, vm.JMPIF, int16(len(c.l) - 3))
|
emitJmp(c.prog, vm.JMPIF, int16(len(c.l)-3))
|
||||||
ast.Walk(c, n.Y)
|
ast.Walk(c, n.Y)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ type testCase struct {
|
||||||
|
|
||||||
func run_testcases(t *testing.T, tcases []testCase) {
|
func run_testcases(t *testing.T, tcases []testCase) {
|
||||||
for _, tcase := range tcases {
|
for _, tcase := range tcases {
|
||||||
t.Run(tcase.name, func(t *testing.T) {eval(t, tcase.src, tcase.result)})
|
t.Run(tcase.name, func(t *testing.T) { eval(t, tcase.src, tcase.result) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"text/tabwriter"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
||||||
"github.com/CityOfZion/neo-go/pkg/util"
|
"github.com/CityOfZion/neo-go/pkg/util"
|
||||||
|
@ -308,7 +308,7 @@ func (v *VM) execute(ctx *Context, op Instruction) {
|
||||||
l := int(v.estack.Pop().BigInt().Int64())
|
l := int(v.estack.Pop().BigInt().Int64())
|
||||||
o := int(v.estack.Pop().BigInt().Int64())
|
o := int(v.estack.Pop().BigInt().Int64())
|
||||||
s := v.estack.Pop().Bytes()
|
s := v.estack.Pop().Bytes()
|
||||||
v.estack.PushVal(s[o:o+l])
|
v.estack.PushVal(s[o : o+l])
|
||||||
case LEFT:
|
case LEFT:
|
||||||
l := int(v.estack.Pop().BigInt().Int64())
|
l := int(v.estack.Pop().BigInt().Int64())
|
||||||
s := v.estack.Pop().Bytes()
|
s := v.estack.Pop().Bytes()
|
||||||
|
@ -416,7 +416,7 @@ func (v *VM) execute(ctx *Context, op Instruction) {
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
b := v.estack.Pop()
|
b := v.estack.Pop()
|
||||||
a := v.estack.Pop()
|
a := v.estack.Pop()
|
||||||
v.estack.PushVal(reflect.DeepEqual(a,b))
|
v.estack.PushVal(reflect.DeepEqual(a, b))
|
||||||
|
|
||||||
// Bit operations.
|
// Bit operations.
|
||||||
case INVERT:
|
case INVERT:
|
||||||
|
|
|
@ -773,9 +773,9 @@ func TestUNPACKGood(t *testing.T) {
|
||||||
assert.Equal(t, 5, vm.estack.Len())
|
assert.Equal(t, 5, vm.estack.Len())
|
||||||
assert.Equal(t, int64(len(elements)), vm.estack.Peek(0).BigInt().Int64())
|
assert.Equal(t, int64(len(elements)), vm.estack.Peek(0).BigInt().Int64())
|
||||||
for k, v := range elements {
|
for k, v := range elements {
|
||||||
assert.Equal(t, int64(v), vm.estack.Peek(k + 1).BigInt().Int64())
|
assert.Equal(t, int64(v), vm.estack.Peek(k+1).BigInt().Int64())
|
||||||
}
|
}
|
||||||
assert.Equal(t, int64(1), vm.estack.Peek(len(elements) + 1).BigInt().Int64())
|
assert.Equal(t, int64(1), vm.estack.Peek(len(elements)+1).BigInt().Int64())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestREVERSEBadNotArray(t *testing.T) {
|
func TestREVERSEBadNotArray(t *testing.T) {
|
||||||
|
@ -817,7 +817,7 @@ func TestREVERSEGood(t *testing.T) {
|
||||||
a := vm.estack.Peek(0).Array()
|
a := vm.estack.Peek(0).Array()
|
||||||
assert.Equal(t, len(elements), len(a))
|
assert.Equal(t, len(elements), len(a))
|
||||||
for k, v := range elements {
|
for k, v := range elements {
|
||||||
e := a[len(a) - 1 - k].Value().(*big.Int)
|
e := a[len(a)-1-k].Value().(*big.Int)
|
||||||
assert.Equal(t, int64(v), e.Int64())
|
assert.Equal(t, int64(v), e.Int64())
|
||||||
}
|
}
|
||||||
assert.Equal(t, int64(1), vm.estack.Peek(1).BigInt().Int64())
|
assert.Equal(t, int64(1), vm.estack.Peek(1).BigInt().Int64())
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package wallet
|
package wallet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/CityOfZion/neo-go/pkg/util"
|
|
||||||
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/CityOfZion/neo-go/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Account represents a NEO account. It holds the private and public key
|
// Account represents a NEO account. It holds the private and public key
|
||||||
|
|
Loading…
Reference in a new issue