Commit graph

187 commits

Author SHA1 Message Date
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
Roman Khimov
b77e533d13 crypto/wallet: move public/private key into the new keys package
And drop associated _pkg.dev remnants (refs. #307).

Original `dev` branch had two separate packages for public and private keys,
but those are so intertwined (`TestHelper` subpackage is a proof) that it's
better unite them and all associated code (like WIF and NEP-2) in one
package. This patch also:
 * creates internal `keytestcases` package to share things with wallet (maybe
   it'll be changed in some future)
 * ports some tests from `dev`
 * ports Verify() method for public key from `dev`
 * expands TestPrivateKey() with public key check
2019-08-27 17:45:51 +03:00
Roman Khimov
2275b9e4ad _pkg.dev: drop address pkg, move test into crypto
address wrappers don't seem to fit well into master's code, so just drop 'em,
but pick the testing function with good known input/output pair.
2019-08-27 17:09:24 +03:00
Evgeniy Kulikov
96169ef266
Merge pull request #317 from nspcc-dev/fix/data-race-in-memeory-store
Fix DataRace in MemoryStore
- Add RWMutex to MemoryStore struct
- Use Lock/Unlock for writing
- Use RLock/RUnlock for reading
- Fix #313 issue
2019-08-27 16:51:54 +03:00
Evgeniy Kulikov
33f59debf2
store: Fix DataRace in MemoryStore
- Add RWMutex to MemoryStore struct
- Use Lock/Unlock for writing
- Use RLock/RUnlock for reading
- Fix #313 issue
2019-08-27 16:48:30 +03:00
Evgeniy Kulikov
78cf3e9c5f
Use our RFC6979 fork
- prepare fork
- update go-modules
- update dependencies
2019-08-27 13:07:02 +03:00
Roman Khimov
7165b5ab1e base58: add testing from _pkg.dev
And drop implementation in _pkg.dev, as it's redundant. Refs. #307.
2019-08-26 13:32:19 +03:00
Roman Khimov
ec7e17ffa6 pkg: make use of the new crypto/hash package
Simplifies a lot of code and removes some duplication. Unfortunately I had to
move test_util random functions in same commit to avoid cycle
dependencies. One of these random functions was also used in core/transaction
testing, to simplify things I've just dropped it there and used a static
string (which is nice to have for a test anyway).

There is still sha256 left in wallet (but it needs to pass Hash structure into
the signing function).
2019-08-26 13:32:19 +03:00
Roman Khimov
2fd782eee8 util: drop RandUint32()
I don't see anything useful in it, all the current users of it should just use
plain rand.Uint32() not limiting its output in any way.
2019-08-26 13:32:19 +03:00
Roman Khimov
3fa6ba9c7b hash: simplify ripemd160 usage
Go's Hash is explicitly specified to never return an error on Write(), and our
own decoding functions only check for length which is gonna be right in every
case so it makes no sense returning errors from these functions.
2019-08-26 13:32:19 +03:00
Roman Khimov
80c3c9035a hash: simplify Sha256 implementations
Use sha256.Sum256() and drop duplicating Sum() completely.
2019-08-26 13:32:19 +03:00
Roman Khimov
5c5878968b hask: import package from _pkg.dev, make it compile 2019-08-26 13:32:19 +03:00
Roman Khimov
37be2e215c array: add a test for even num of elements
And drop duplicating code from _pkg.dev.
2019-08-26 13:32:19 +03:00
Roman Khimov
0cde8d962d fixed8: switch to more uniform function naming 2019-08-26 13:32:19 +03:00
Roman Khimov
b0af8b306d fixed8: fix Satoshi() and add a test for it 2019-08-26 13:32:19 +03:00
Roman Khimov
20a4ad99b3 fixed8: add some testcases from dev, split Value functions
Add FloatValue() and rename Value() to Int64Value() for consistency.
2019-08-26 13:32:19 +03:00
Roman Khimov
a861f53733 fixed8: simplify arithmetic functions
I'm not sure they're of any use at all.
2019-08-26 13:32:19 +03:00
Roman Khimov
c67217159f fixed8: remove trailing zeroes from string representation
Add some testcases from `dev` branch (with less than zero case added) and
remove useless trailing zeroes from the resulting string.
2019-08-26 13:32:19 +03:00
Roman Khimov
d5d570f793 uint256: add Reverse(), change String() to be BE
This one makes a little more obvious that we're operating with LE
representations mostly. Refs. #307. See #314 also.
2019-08-26 13:32:19 +03:00
Roman Khimov
c1b1b6fca4 uint160: move ReverseString() from _pkg.dev
With associated test and drop duplicating Uint160 implementation from
_pkg.dev. It doesn't seem to be used in pkg code at the moment, but still it
can be useful. Refs #307.
2019-08-26 13:32:19 +03:00
Roman Khimov
18d971440b vm: expand binary expr tests with cases from #294
Make a full set of numeric/string comparisons with `==` and `!=` being
evaluated to true and false.
2019-08-20 20:43:43 +03:00
Roman Khimov
9b421874ae vm: enable assign/binary/numeric/struct tests
These were not used for some reason.
2019-08-20 20:37:06 +03:00
Roman Khimov
0309cff5a2 vm: implement EQUAL via reflection
Fixes failing tests.
2019-08-20 19:46:52 +03:00
Roman Khimov
4ccda04eea compiler: fix string/numbers equality/inequality gen again
Unfortunately d58fbe0c88 didn't really fix the
problem because tinfo.Type (the expression resulting type) actually is a bool
and we need to check its parameters. Also, there is need to fix the NEQ
operation.
2019-08-19 19:18:17 +03:00
Evgenii
d58fbe0c88 compiler: use separate opcodes for string and number equality 2019-08-16 16:56:09 +03:00
Roman Khimov
1e09037902 pkg/vm/compiler: update README
s/opdump/inspect/ and new sample output.
2019-08-15 19:53:21 +03:00
Roman Khimov
a1e3655560 interop: move into pkg/interop, replace pkg/vm/api
neo-storm has developed more wrappers for syscall APIs, so they can and should
be used as a drop-in replacement for pkg/vm/api. Moving it out of vm, as it's
not exactly related to the VM itself.
2019-08-15 19:41:51 +03:00
Roman Khimov
7cd91610df compiler: quick and dirty inspection fix for JMP instrs
These were interpreted completely wrong, they actually have two next bytes
indicating an offset. This patch is a quick fix, actually more work is needed
here to properly display various instructions.
2019-08-15 18:26:52 +03:00
Roman Khimov
1a4055a962 compiler: fix codegen for OR, fixes failing TestLOR
0880e88fa5 breaks it by introducing a new label
that is not counted here.
2019-08-15 18:25:22 +03:00
Roman Khimov
810f096811 compiler: change codegen to emit NUMEQUAL instead of EQUAL
This is wrong, see issue #294, but it makes our VM tests work (as VM is
missing EQUAL implementation), so until #294 is properly resolved we're better
have this kind of wrong code generation.
2019-08-15 18:22:56 +03:00
Evgenii
2daebdfce2 compiler: convert unary operators properly
Imported from CityOfZion/neo-storm#62 PR.
2019-08-14 20:08:17 +03:00
Evgenii
05c07a8567 compiler: fix argument handling for function arity >= 3
Imported from CityOfZion/neo-storm#61 PR.
2019-08-14 20:08:14 +03:00
Evgenii
5ba835d25b compiler: process packages in deterministic order
Imported from CityOfZion/neo-storm#60 PR.
2019-08-14 20:08:05 +03:00
1883a11f44 swap arguments for functions with more than 3 arguments (CityOfZion/neo-storm#51)
Imported from CityOfZion/neo-storm (402ebb1d6226e2a30d8fdc19663227361cc72ca0).
2019-08-14 19:14:08 +03:00
74602b6143 concatenate strings using CAT opcode (CityOfZion/neo-storm#54)
Imported from CityOfZion/neo-storm (7d759a23e3af792657c7515645b890eadfa7329f).
2019-08-14 19:14:07 +03:00