Roman Khimov
031a260cb1
util: add tests for BinaryReader/BinaryWriter
...
100% coverage.
2019-09-16 23:38:48 +03:00
Roman Khimov
72fc880182
util: remove bogus check from BinWriter.WriteVarUint()
...
val is uint64, it can't be less than zero by definition.
2019-09-16 23:38:48 +03:00
Roman Khimov
aacf58c9ab
util: add 'constructors' for BinReader/BinWriter
...
And an additional BufBinWriter to ease buffer management.
2019-09-16 23:38:48 +03:00
Roman Khimov
0838948540
Merge pull request #394 from nspcc-dev/fix/json-tests-bugs
...
VM: fix some bugs from neo-vm JSON tests
2019-09-16 19:46:12 +03:00
Roman Khimov
c98a626871
Merge pull request #399 from nspcc-dev/refactor_store
...
storage: refactor store, add Close()
2019-09-16 18:59:34 +03:00
Vsevolod Brekelov
264dfef370
storage: close function
...
add close function to storage interface
add common defer function call which will close db connection
remove context as soon as it's not needed anymore
updated unit tests
2019-09-16 18:52:47 +03:00
Roman Khimov
adba9e11ee
Merge pull request #396 from nspcc-dev/network-reconnections-and-fixes
...
This one fixes #390 and some connected problems. After this patchset the node reconnects to some other nodes if anything goes wrong and it better senses when something goes wrong. It also fixes some block handling problems based on the testnet connection experience.
2019-09-16 16:57:10 +03:00
Roman Khimov
b9ff4d929c
network: add getaddr message handling
...
Respond with known good addresses.
2019-09-16 16:32:04 +03:00
Roman Khimov
b2530a4c93
network: be more specific on port mismatch error
2019-09-16 16:32:04 +03:00
Roman Khimov
773ccc2b92
network: allow discoverer to reuse addresses
...
...and don't try to connect to the nodes we're already connected to.
Before this change we had a problem of discoverer throwing away good valid
addresses just because they are already known which lead to pool draining over
time (as address reuse was basically forbidden and getaddr may not get enough
new nodes).
2019-09-16 16:32:04 +03:00
Roman Khimov
46dc141c6c
network: enlarge address request queue
...
Queuing one message is not reliable enough, the peer that gets it can fail to
actually make a request, so make this queue a bit deeper to have a higher
chance of success.
2019-09-16 16:32:04 +03:00
Roman Khimov
d3bb8ddf8f
network: handle errors and connection close more correctly
...
This makes writer side handle errors properly and fixes communication between
reader and writer goroutine to always correctly unregister the peer. This is
especially important for the case where error occurs before handshake
completes as in this case we don't even have goroutine in startProtocol()
running.
2019-09-16 16:32:04 +03:00
Roman Khimov
76c7cff67f
network: make node strictly follow handshake procedure
...
Don't accept other messages before handshake is completed, check handshake
message sequence.
2019-09-16 16:32:04 +03:00
Roman Khimov
c6487423ae
network: close connection on disconnect
...
If it's already closed, this won't hurt, but in the case of logical error it
saves us from leaking this connection (and potentially, peer).
2019-09-16 16:26:30 +03:00
Roman Khimov
90e13debe4
network: implement getaddr sends and addr receival
...
Request new addresses if we're short on known addresses pool size.
2019-09-16 16:26:30 +03:00
Roman Khimov
2a49e68d77
network: start worker goroutine for every connection attempts
...
Prevents blocking on write to workCh which can be dangerous for the server.
2019-09-16 16:26:30 +03:00
Roman Khimov
b4e284f301
discovery: make pool management more reliable
...
Just drop excessive addresses, otherwise we can block for no good reason.
2019-09-16 16:26:30 +03:00
Roman Khimov
85f19936dd
network: implement connection retries
...
It's worth to try a bit more than once.
2019-09-16 16:26:30 +03:00
Roman Khimov
be6c905e5d
network: use and improve discovery mechanism for reconnections
...
This makes our node reconnect to other nodes if connection drops for some
reason. Fixes #390 .
2019-09-16 16:26:30 +03:00
Roman Khimov
b263c97bbb
core: add some mechanism to drop bad blocks from cache
...
If we can't persist anything from our cache there is something wrong with
it. Try to remediate some possible problems.
2019-09-16 16:26:30 +03:00
Evgenii Stratonikov
d2ccc3b017
vm: make REVERSE consume an item from stack
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
fd264cb06f
vm: make REVERSE work with structs
...
Also add more tests.
Extend `Array` method of `Element` to work with `StructItem`.
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
f0426ac2d5
vm: do nothing if SHL/SHR by 0
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9eca5ee317
vm: convert SIZE argument to bytearray
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
9780889239
vm: make NEWARRAY/NEWSTRUCT accept bytearray
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
09e197eaf3
vm: make PUSH0 create empty bytearray
...
Also make tests expect []byte{} instead of 0.
2019-09-16 15:50:51 +03:00
Evgenii Stratonikov
66501f9ef9
vm: make REMOVE consume array from stack
2019-09-16 15:50:14 +03:00
Evgenii Stratonikov
71cfd14b92
vm: create an array of false
items in NEWARRAY/NEWSTRUCT
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
bafdb916a0
vm: make PICKITEM accept bytearrays
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
1881adabb9
vm: fail if NIP has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
6e4014547d
vm: fail if DROP has no argument
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
729b7a0b24
vm: fail if ROT has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
cf7fbb80ba
vm: fail if EQUAL has not enough arguments
2019-09-16 15:24:58 +03:00
Evgenii Stratonikov
d257044298
vm: fail if XTUCK argument is 0
2019-09-16 15:24:58 +03:00
Roman Khimov
b21a220712
Merge pull request #381 from nspcc-dev/add_boltd
...
storage: add boltdb support, closes #335 .
2019-09-14 13:00:52 +03:00
Vsevolod Brekelov
2cabd5b274
storage: add boltDB unit tests
2019-09-14 10:29:08 +03:00
Vsevolod Brekelov
bfe5fd538e
storage: add boltDB support
...
closes #335
2019-09-14 10:28:43 +03:00
Evgenii Stratonikov
56ec097d76
vm: fix codegen for APPEND
2019-09-13 11:24:21 +03:00
Roman Khimov
521a707e33
core: don't print contracts in persistBlock()
...
Yeah, this really needs more love, but for now just don't spit 'em out on the
screen, please.
2019-09-12 16:12:12 +03:00
Roman Khimov
d0ffd165fd
Merge pull request #393 from nspcc-dev/assorted-db-handling-fixes-and-optimizations
...
Assorted db handling fixes and optimizations based on the testnet
connection experience.
2019-09-11 22:31:19 +03:00
Roman Khimov
4395cea344
storage: fix reading overlapping hash blocks from the DB
...
In the unlikely event of overlapping hash block written to the DB we might end
up with wrong hash list. That happened to me for some reason when synching
with the testnet leading to the following keys with respective values:
150000 -> 2000 hashes
152000 -> 2000 hashes
153999 -> 2000 hashes
Reading it hashes number 153999 and 154000 got the same values and the chain
couldn't sync correctly.
2019-09-11 20:33:41 +03:00
Roman Khimov
4f60fd3e8e
core: optimize persist() for the case when no next block found
...
If there is no next block in the cache, looping through the whole cache won't
help.
2019-09-11 20:32:30 +03:00
Roman Khimov
7812fb28ea
core: optimize blockchain init with existing DB
...
There is no need to generate genesis block (it's already in the DB) and we can
add all hashes at once without iterating over them.
2019-09-11 20:28:49 +03:00
Evgenii Stratonikov
68c6c93980
vm: do not allow APPEND to operate on bytearray
2019-09-11 17:17:37 +03:00
Evgenii Stratonikov
723dcc6e25
vm: make APPEND push no value on stack
2019-09-11 17:17:34 +03:00
Roman Khimov
8311bda355
vm: harden LEFT and RIGHT implementations against negative indexes
2019-09-11 14:51:04 +03:00
Roman Khimov
17f3a21e27
vm: harden SUBSTR implementation against bad index/offset values
...
The upper index bound for slices is capacity, not length. Check for negative
values also. Fixes #387 .
2019-09-11 14:37:41 +03:00
Roman Khimov
fc1075bf75
vm: protect PUSHDATA from short reads
...
Same thing done in a2a8981979
for PUSHBYTES,
failing to read the amount of bytes specified should lead to FAULT. Also
makes readUint16() and readUint32() panic as this is the behavior we want in
these cases. Add some tests along the way.
2019-09-11 12:35:37 +03:00
Roman Khimov
14c02cb3b1
Merge pull request #385 from nspcc-dev/vm-contract-invoke-parameters-332-part1
...
VM CLI improvements, part 1 of #332 work.
2019-09-10 23:55:23 +03:00
Roman Khimov
392a4c4f39
vm/cli: add some convenience heuristic to ease 'run' use
2019-09-10 23:31:06 +03:00
Roman Khimov
c5911c2f10
vm/cli: add support for bool type as 'run' parameter
2019-09-10 23:31:06 +03:00
Roman Khimov
982bdcd704
vm/cli: make operation mandatory if anything added to run
...
Matches neo-cli behavior.
2019-09-10 23:31:06 +03:00
Roman Khimov
5bd666b786
vm: return NOP as current instruction for just loaded VM
...
Before:
NEO-GO-VM > loadgo h.go
READY: loaded 16 instructions
NEO-GO-VM > ip
instruction pointer at -1 (PUSH0)
After:
NEO-GO-VM > loadgo h.go
READY: loaded 16 instructions
NEO-GO-VM > ip
instruction pointer at -1 (NOP)
I think NOP is a little less scary.
2019-09-10 23:31:06 +03:00
Roman Khimov
e872b6b421
vm/cli: redo the whole thing using abiosoft/ishell
...
Adds history support, better editing and way better help system. Expand on
some helps while at it.
2019-09-10 23:31:06 +03:00
Vsevolod Brekelov
0f31e7bf7f
unitTests: fix for failing test
...
should fix circleCI and now these tests using inmemory db
2019-09-10 23:21:26 +03:00
Roman Khimov
4d7456903b
Merge pull request #377 from nspcc-dev/config_for_db
...
storage: support of Redis and configuration for DB
Closes #336 .
2019-09-10 17:46:31 +03:00
Evgenii Stratonikov
31f4c7486b
vm: add tests for CAT
2019-09-10 17:33:42 +03:00
Evgenii Stratonikov
1289d0f7e9
vm: add tests for NOT
2019-09-10 17:29:10 +03:00
Evgenii Stratonikov
f2393e5efc
vm: implement * -> Boolean conversion
2019-09-10 17:29:10 +03:00
Evgenii Stratonikov
7e14c5a274
vm: implement * -> ByteArray conversion
2019-09-10 17:29:07 +03:00
Vsevolod Brekelov
06ecb1855e
storage: redis db unit test
2019-09-10 17:22:45 +03:00
Vsevolod Brekelov
4f680703a4
storage: multiple DB support and Redis support
...
add config which closes #336
add redis db support
2019-09-10 17:22:21 +03:00
Evgenii Stratonikov
9b10b4c4d8
vm: add tests for SIGN
2019-09-10 15:08:42 +03:00
Evgenii Stratonikov
52b0d661e0
vm: implement BigInt -> Boolean conversion
2019-09-10 14:19:36 +03:00
Roman Khimov
33bb371f9b
Merge pull request #380 from nspcc-dev/drop-endpoint-fix-321
...
util: drop Endpoint structure, fix #321
2019-09-09 19:39:49 +03:00
Roman Khimov
8d9bc83214
util: drop Endpoint structure, fix #321
...
I think it's useless, buggy and hides parsing errors for no good reason.
2019-09-09 17:54:38 +03:00
Evgenii
0b58ed4a22
vm: do not fault on LEFT with big index
...
Fixes #378 .
2019-09-09 17:29:31 +03:00
Roman Khimov
a039ae6cdb
Merge pull request #374 from nspcc-dev/makefile-and-gofmt
...
Makefile convenience targets and gofmt
2019-09-09 15:05:12 +03:00
Roman Khimov
b5d3c37a01
Merge pull request #375 from nspcc-dev/pushbytes-short-read-fix-361
...
vm: fix not failing PUSHBYTES* on short read
2019-09-09 15:02:56 +03:00
Roman Khimov
b8b26d8e79
core: fix 'implementation' misspell in test code
...
Found in the Go report card.
2019-09-09 14:53:50 +03:00
Roman Khimov
8db9d2a976
crypto: use mr-tron/base58 for base58
...
Use more fast and reliable implementation. Add some tests for our wrappers,
deduplicate code in PublicKey.Adress(). Fixes #355 .
2019-09-09 13:12:55 +03:00
Roman Khimov
a2a8981979
vm: fix not failing PUSHBYTES* on short read
...
Add some tests also. Fixes #361 .
2019-09-09 12:09:05 +03:00
Roman Khimov
fabd11699a
*: gofmt -s
...
Appy gofmt for all the source tree.
2019-09-09 12:02:24 +03:00
Roman Khimov
450063de7d
Merge pull request #362 from nspcc-dev/add-missing-opcodes-into-the-list
...
Add missing opcodes into the list
2019-09-09 11:24:39 +03:00
Roman Khimov
7b0c2781d2
vm: expand instruction list with commands from current VM spec
...
Current NEO documentation lists them:
https://docs.neo.org/docs/en-us/tooldev/advanced/neo_vm.html
CALL_* instructions were left out because of conflict with golint (but they're
removed in NEO 3.0 anyway, so wasting time on them makes no sense).
Update autogenerated instruction_string.go accordingly.
2019-09-08 20:46:35 +03:00
Evgenii
bcc8234155
vm: implement Array <-> Struct conversion
...
Reference VM implementation supports convertation from
Struct to Array via NEWARRAY and vice versa.
https://github.com/neo-project/neo-vm/pull/91
2019-09-08 13:40:21 +03:00
Roman Khimov
8c448ab890
util: add some tests to make GetVarSize() fully covered
2019-09-07 10:28:00 +03:00
Roman Khimov
7e8dc9ad66
vm: uncomment TestForLoopBigIter
...
It works just fine.
2019-09-07 10:10:11 +03:00
Roman Khimov
1c7d203993
compiler: drop TODO comment, #294 was fixed a while ago
2019-09-07 10:09:42 +03:00
Roman Khimov
8169edf04c
vm: expand PUSHBYTES instructions
...
Allows to reliably use String() on any of those. Update autogenerated
instruction_string.go accordingly.
2019-09-06 19:14:47 +03:00
Roman Khimov
aefe572df3
vm: implement UNPACK, REVERSE, REMOVE opcodes
...
Also expand makeStackItem() to accept slices of int for testing
convenience. Fixes #195 .
2019-09-06 19:00:34 +03:00
Roman Khimov
5bd50c7bcd
vm: add some tests for PACK instruction
2019-09-06 13:15:30 +03:00
Roman Khimov
b3ed3d24ee
vm: implement CAT, SUBSTR, LEFT and RIGHT
...
String instruction set.
2019-09-06 12:41:27 +03:00
Roman Khimov
3f40334979
vm: add generic stub for all unimplemented instructions
2019-09-05 17:35:30 +03:00
Roman Khimov
59de72f446
vm: implement INVERT instruction
2019-09-05 17:35:30 +03:00
Roman Khimov
b494e094c0
vm: add XDROP implementation
2019-09-05 17:35:30 +03:00
Roman Khimov
974f5db6bc
vm: add a TUCK implementation with tests
...
Also fix stack's InsertAt for the edge case of inserting into a position that
currently is empty (the first good TUCK test illustrates this).
2019-09-05 17:35:30 +03:00
Roman Khimov
eb224aeebe
vm: add some checks for OVER and PICK, add OVER tests
...
These actually behaved correctly because of deferred sigsegv recover, but I
think it would be nice to print something more meaningful for users.
2019-09-05 17:35:30 +03:00
Roman Khimov
85831e3e92
vm: fix XTUCK implementation, add tests
...
The code that we have actually implements XTUCK and not TUCK. And it's a bit
broken, so fix it and add some tests. The most interesting one (that required
to touch stack code) is the one when we have 1 element on the stack and are
trying to tell XTUCK to push 2 elements deep.
2019-09-05 17:34:25 +03:00
Roman Khimov
5f0f9e1638
vm: implement PICK instruction
2019-09-05 15:18:04 +03:00
Roman Khimov
b34a1b6c25
vm: harden tests against VM failures
...
Add a check for failed VM state, some of tests using logic values (like NZ
test) can succeed even with VM in FAULT state otherwise.
2019-09-05 15:09:08 +03:00
Roman Khimov
fcf9c1213b
vm: implement the NZ opcode
2019-09-05 15:05:44 +03:00
Roman Khimov
e537dc9ee4
keys: improve publick key checks with a check against P
...
ANSI X9.62 says that if x or y coordinate are greater than or equal to
curve.Params().P, the conversion should return an error (see ANSI X9.62:2005
Section A.5.8 Step b, which invokes Section A.5.5, which does the check and
rejects when x or y are too big.
See https://github.com/golang/go/issues/20482 for more details.
2019-09-05 12:34:12 +03:00
Roman Khimov
f12194f3b0
keys: deduplicate DecodeBytes/DecodeBinary for PrivateKey
...
They shared prefix logic for no good reason, don't do that.
2019-09-05 12:34:12 +03:00
Roman Khimov
2c3e92923f
keys: simplify error handling for PublicKey() and associated
...
PublicKey() for PrivateKey now just can't fail and it makes no sense to return
an error from it. There is a lot of associated functionality for which this
also is true, so adjust it accordingly and simplify a lot of code.
2019-09-05 12:34:12 +03:00
Roman Khimov
60bc2e8053
keys: simplify PublicKey() for PrivateKey
...
Public key is just a point, so use the coordinates obtained previously to
initialize the PublicKey structure without jumping through the hoops of
encoding/decoding.
2019-09-05 12:34:12 +03:00
Roman Khimov
f0fbe9f6c9
crypto: drop home-grown elliptic crypto, use crypto/elliptic
...
As NEO uses P256 we can use standard crypto/elliptic library for almost
everything, the only exception being decompression of the Y coordinate. For
some reason the standard library only supports uncompressed format in its
Marshal()/Unmarshal() functions. elliptic.P256() is known to have
constant-time implementation, so it fixes #245 (and the decompression using
big.Int operates on public key, so nobody really cares about that part being
constant-time).
New decompress function is inspired by
https://stackoverflow.com/questions/46283760 , even though the previous one
really did the same thing just in a little less obvious way.
2019-09-05 12:33:27 +03:00
Roman Khimov
0b884b92b3
crypto: use PrivateKey to generate a key pair
...
It makes no sense to provide an API for throw-away public keys, so obtain it
via a new real keypair generation where appropriate (and that's only needed
for testing).
2019-09-05 09:38:13 +03:00
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
Roman Khimov
5836ae6873
keys: change Signature() and Address() to not return errors
...
As they never can return any real one.
2019-08-27 17:46:01 +03:00
Roman Khimov
483b875f4a
keys: simplify tests with assert package
2019-08-27 17:46:01 +03:00