Commit graph

223 commits

Author SHA1 Message Date
Roman Khimov
2c2f91564f rpc: comment out getBlock and getRawTransaction
After the 8388f4a55e Golint quickly pointed that
these are unused, so comment 'em out for now.
2019-09-03 18:25:19 +03:00
Roman Khimov
6bfcc615b2 *: fix some misspellings
Found by goreport.
2019-09-03 18:20:05 +03:00
Roman Khimov
22bea5eccf core: remove ineffective assignment from test code
Spotted by goreport:
  Line 89: warning: ineffectual assignment to hash (ineffassign)
2019-09-03 18:17:44 +03:00
Roman Khimov
8388f4a55e rpc: unexport methods returning internal structures
Golint:
pkg/rpc/rpc.go:15:67: exported method GetBlock returns unexported type *rpc.response, which can be annoying to use
pkg/rpc/rpc.go:82:64: exported method GetRawTransaction returns unexported type *rpc.response, which can be annoying to use
pkg/rpc/rpc.go:97:52: exported method SendRawTransaction returns unexported type *rpc.response, which can be annoying to use

Refs. #213.
2019-09-03 18:16:48 +03:00
Roman Khimov
1fd5e5928c rpc: fix bad name spellings noted by golint
pkg/rpc/neoScanBalanceGetter.go:54:56: method parameter assetIdUint should be assetIDUint
pkg/rpc/neoScanBalanceGetter.go:62:3: var assetId should be assetID
pkg/rpc/server_test.go:27:5: var testRpcCases should be testRPCCases
pkg/rpc/txTypes.go:19:3: struct field assetId should be assetID
pkg/rpc/txTypes.go:39:35: interface method parameter assetId should be assetID
pkg/rpc/types.go:115:2: struct field TxId should be TxID

Refs. #213.
2019-09-03 18:16:48 +03:00
Roman Khimov
db9e37b3bb *: fix golint's omit type suggestions
pkg/core/transaction/attribute.go:67:14: should omit type uint8 from declaration of var urllen; it will be inferred from the right-hand side
pkg/crypto/keys/publickey.go:184:8: should omit type []byte from declaration of var b; it will be inferred from the right-hand side
pkg/network/payload/version_test.go:15:12: should omit type bool from declaration of var relay; it will be inferred from the right-hand side

Refs. #213.
2019-09-03 18:16:48 +03:00
Roman Khimov
a74518691c crypto: improve error messages for base58
Golint:
  error strings should not be capitalized or end with punctuation or a newline

Refs. #213.
2019-09-03 18:16:48 +03:00
Roman Khimov
89ed00ddfb core: simplify GetTransationResults() based on golint suggestion
Golint:
  pkg/core/blockchain.go:796:9: if block ends with a return statement, so drop
    this else and outdent its block (move short variable declaration to its own
    line if necessary)

Refs. #213.
2019-09-03 18:16:48 +03:00
Roman Khimov
0c160a81fe transaction: use increments instead of '+1's
Fixes golint warning:
  should replace sz += 1 with sz++

Refs. #213.
2019-09-03 18:01:37 +03:00
Roman Khimov
a9b9c9226d *: add/fix godoc comments to satisfy golint
Fixes things like:
 * exported type/method/function X should have comment or be unexported
 * comment on exported type/method/function X should be of the form "X ..."
   (with optional leading article)

Refs. #213.
2019-09-03 17:57:51 +03:00
Roman Khimov
42dfca47cf vm: fix double VM run from CLI
Fixes one more instruction being ran when VM FAULTs:

NEO-GO-VM > run
NEO-GO-VM > error encountered at instruction 6 (ROLL)
NEO-GO-VM > runtime error: invalid memory address or nil pointer dereference
FAULT
NEO-GO-VM > error encountered at instruction 7 (SETITEM)
NEO-GO-VM > interface conversion: interface {} is []vm.StackItem, not []uint8

Refs. #96.
2019-08-31 09:06:56 +03:00
Roman Khimov
428e789ddc vm: produce better error for ROLL with wrong index
Current VM implementation doesn't return errors for many operations, so the
only way to handle it here is to check for NULL. Refs. #96.
2019-08-31 09:04:59 +03:00
Roman Khimov
6767bb5446 transaction: move state test from dev 2019-08-30 19:35:57 +03:00
Roman Khimov
b8adc36e6a transaction: add missing alloc in state decoder
Fixes panic two lines below:
panic: runtime error: index out of range [recovered]
        panic: runtime error: index out of range
2019-08-30 19:34:26 +03:00
Roman Khimov
203aab6a7e transaction: add binary encoding for publish
And expand the test to check for it. Fixes #319.
2019-08-30 19:19:43 +03:00
Roman Khimov
af212f496e transaction: implement encoding for state 2019-08-30 19:13:19 +03:00
Roman Khimov
868c9d6e8c transaction: add miner tx test from dev 2019-08-30 18:53:26 +03:00
Roman Khimov
88a47aeeb4 transaction: move enrollment test from dev into the master 2019-08-30 18:28:12 +03:00
Roman Khimov
aa94ae70b6 transaction: move and adapt test from dev
Slightly increases coverage for transaction package.
2019-08-30 18:23:53 +03:00
Roman Khimov
d6686350ee transaction: auto-generate stringer interface for AttrUsage 2019-08-30 17:44:36 +03:00
Roman Khimov
3495fecc65 transaction: fix DescriptionURL attribute handling
Both dev and master actually did it wrong.
2019-08-30 16:51:18 +03:00
Roman Khimov
e72a8bbecd network: decode CMDGetData the same way as CMDInv
As they're the same wrt the payload.
2019-08-30 13:14:12 +03:00
Roman Khimov
17679c3b94 core: add block test from dev branch
And drop it from _pkg.dev. Adapted for master.
2019-08-30 11:41:10 +03:00
Roman Khimov
683424cce8 transaction: implement proper Size() everywhere
Will be needed for the block test from `dev`.
2019-08-30 11:41:10 +03:00
Roman Khimov
200cce9f02 transaction: fix Size() calculation for attribute
It wasn't accounting for attr.Data length properly.
2019-08-30 11:41:10 +03:00
Roman Khimov
8ececdc9a7 transaction: fix invocation decoding for different versions
Quick fix similar to abc5833853 + uncomment the
test case for it.

Closes #173.
2019-08-30 11:41:10 +03:00
Roman Khimov
2ef2c0b84c transaction: properly print number in attribute log msg 2019-08-30 11:41:10 +03:00
Roman Khimov
c093f070d3 core: add EncodeBinary() support for the block 2019-08-30 11:41:10 +03:00
Roman Khimov
e03eac9dcc payload: move one test from dev for inventory
And drop it from the _pkg.dev.
2019-08-30 11:41:10 +03:00
Roman Khimov
6cf74e2d83 payload: fix wrong stringer impl for InventoryType 2019-08-30 11:41:10 +03:00
Roman Khimov
f636bb9b6e payload: extend headers test, add limit
... from _pkg.dev and drop headers parsing there.
2019-08-30 11:41:10 +03:00
Roman Khimov
2d94a1e337 network: add getblocks message parsing
It has identical structure to the `getheaders`.
2019-08-29 21:23:57 +03:00
Roman Khimov
01c96fbc50 payload: improve address test
Check that the structure has proper values stored.
2019-08-29 21:23:57 +03:00
Roman Khimov
650a1d4bcc payload: expand version test with explicit data checks 2019-08-29 21:23:57 +03:00
Roman Khimov
2e3172f8a5 payload: fix tests to use asserts
Like in 483b875f4a.
2019-08-29 21:23:57 +03:00
Roman Khimov
c949d2ec53 payload: fix Size() calculation for version
UserAgent is variable-length-encoded. Fix associated test.
2019-08-29 21:23:57 +03:00
Vsevolod Brekelov
abc5833853 transaction: add version check for publish
-Version check done before reading NeedStorage flag
-Add testify according to review
2019-08-29 19:14:22 +03:00
Roman Khimov
4f23117d32 payload: fix wrong useragent parsing in version
C# code reads is as a proper variable-length string, so it's not limited to
252 bytes.
2019-08-29 13:42:16 +03:00
Roman Khimov
7b46f9bb86 util: add error check to Read/WriteVarUint
Fixes possibility of bogus reads/writes. Suggested by @im-kulikov.
2019-08-29 13:26:03 +03:00
Roman Khimov
15311f202b util: drop io, reuse its tests for binaryRW 2019-08-28 19:45:17 +03:00
Roman Khimov
eba83a0e31 smartcontract: use new binaryReader/Writer API from util 2019-08-28 19:45:17 +03:00
Roman Khimov
361724a33e pkg/core: use util.binaryReader/Writer
Simplify error handling.
2019-08-28 19:45:17 +03:00
Roman Khimov
459542a978 pkg/network: convert to using binaryReader/Writer 2019-08-28 19:45:17 +03:00
Roman Khimov
07096a551b util: move strange Read2000Uint256Hashes() into storage
It's the only user of it.
2019-08-28 14:38:57 +03:00
Roman Khimov
672668b9fb util: use more consistent and explicit naming for BR/BW 2019-08-28 13:24:06 +03:00
Roman Khimov
6409cc753c util: move binaryReader/Writer from _pkg.dev
These are useful and nice.
2019-08-28 12:44:23 +03:00
Roman Khimov
a436e22ec1 pkg/network: sort messages
Just for convenience.
2019-08-27 20:12:01 +03:00
Roman Khimov
0f265a6a04 _pkg.dev: drop wire/command
Transferring some missing commands to pkg/network.
2019-08-27 20:08:48 +03:00
Roman Khimov
e89e78159b _pkg.dev: drop wire/protocol package
Move service definitions from it into version (just to save them), but other
than that it's useless for master that has configs ruling the networks.
2019-08-27 19:56:12 +03:00
Roman Khimov
2a8e420608 nep2: fix comment, NEP-2 is about keys, not wallets 2019-08-27 17:47:07 +03:00