Commit graph

19 commits

Author SHA1 Message Date
Roman Khimov
2daff0957a rpc: check for error responses in tests
sendrawtransaction_negative was actually wrong in trying to get
SendTXResponse, it received an error.
2019-09-24 18:47:23 +03:00
Vsevolod Brekelov
100fee164b unitTest: reworked RPC unit test
earlier we had an issue with failing test in #353 and other one #305.
Reworked these test to have in-memory database. This led to multiple
changes: made some functions like Hash and Persist public(otherwise
it's not possible to control state of the blockchain); removed
unit_tests storage package which was used mainly for leveldb in unit
tests.
I see these tests not really good since they look like e2e tests and
as for me should be run in separate step against dockerized env or
in case we want to check rpc handler we might want to rework it in order
to have interface for proper unit tests.
As for me this patchset at least makes as safe with not removing totally
previous tests and at the same time CircleCI will be happy now.
2019-09-18 18:21:16 +03:00
Vsevolod Brekelov
adc880d323 blockchain: server runs goroutine instead of blockchain init
rework initBlockChain in order to have controllable way of running
blockchain;
remove context from initBlockChain func;
2019-09-17 15:27:40 +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
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
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
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
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
dauTT
095653af23 Implement rpc server method: sendrawtransaction (#174)
* Added new config attributes: 'SecondsPerBlock','LowPriorityThreshold'

* Added new files:

* Added new method: CompareTo

* Fixed empty Slice case

* Added new methods: LessThan, GreaterThan, Equal, CompareTo

* Added new method: InputIntersection

* Added MaxTransactionSize, GroupOutputByAssetID

* Added ned method: ScriptHash

* Added new method: IsDoubleSpend

* Refactor blockchainer, Added Feer interface, Verify and GetMemPool method

* 1) Added MemPool
2) Added new methods to satisfy the blockchainer interface: IsLowPriority, Verify, GetMemPool

* Added new methods: RelayTxn, RelayDirectly

* Fixed tests

* Implemented RPC server method sendrawtransaction

* Refactor getrawtransaction, sendrawtransaction in separate methods

* Moved 'secondsPerBlock' to config file

* Implemented Kim suggestions:
1) Fixed data race issues
2) refactor Verify method
3) Get rid of unused InputIntersection  method due to refactoring Verify method
4) Fixed bug in https://github.com/CityOfZion/neo-go/pull/174#discussion_r264108135
5) minor simplications of the code

* Fixed minor issues related to

1) space
2) getter methods do not need pointer on the receiver
3) error message
4) refactoring  CompareTo method in uint256.go

* Fixed small issues

* Use sync.RWMutex instead of sync.Mutex

* Refined (R)Lock/(R)Unlock

* return error instead of bool in Verify methods
2019-03-20 12:30:05 +00:00
Evgeniy Kulikov
a5e85d69de Replace assertion for rpc/server_test.go (#156)
fix #155
fix circle-ci
2019-02-22 08:47:02 +01:00
dauTT
19201dcf52 Implemented rpc server method GetRawTransaction (#135)
* Added utility function GetVarSize

* 1) Added Size method: this implied that Fixed8 implements now the serializable interface. 2) Added few arithmetic operation (Add, Sub, div): this will be used to calculated networkfeeand feePerByte. Changed return value of the Value() method to int instead of int64. Modified fixed8_test accordingly.

* Implemented Size or MarshalJSON method.
- Structs accepting the Size method implement the serializable interface.
- Structs accepting the MarshalJSON method implements the customized json marshaller interface.

* Added fee calculation

* Implemented rcp server method GetRawTransaction

* Updated Tests

* Fixed:
1) NewFixed8 will accept as input int64
2) race condition affecting configDeafault, blockchainDefault

* Simplified Size calculation

* 1) Removed global variable blockchainDefault, configDefault
2) Extended Blockchainer interface to include the methods: References, FeePerByte, SystemFee, NetworkFee
3) Deleted fee_test.go, fee.go. Moved corresponding methods to blockchain_test.go and blockchain.go respectively
4) Amended tx_raw_output.go

* Simplified GetVarSize Method

* Replaced ValueAtAndType with ValueWithType

* Cosmetic changes + Added test case getrawtransaction_7

* Clean up Print statement

* Filled up keys

* Aligned verbose logic with the C#-neo implementation

* Implemented @Kim requests
Refactor server_test.go

* Small fixes

* Fixed verbose logic
Added more tests
Cosmetic changes

* Replaced assert.NoError with require.NoError

* Fixed tests by adding context.Background() as argument

* Fixed tests
2019-02-20 18:39:32 +01:00
Evgeniy Kulikov
20bb05b335 Fix #140 (improve error message) (#142)
- return errors like in C# code (neo-project/neo#587)
- update tests
- small refactoring
2019-02-20 16:28:11 +00:00
Evgeniy Kulikov
9c24bf9139 Blockchain graceful shutdown (#139)
* Blockchain graceful shutdown

- fix #138
- stop blockchain goroutine
- close leveldb database

* fix possible context leak (go vet)
2019-02-19 12:48:48 +01:00
Evgeniy Kulikov
001a0e601e Add RPC Server method ValidateAddress (#134)
* Add RPC Server method ValidateAddress

- implement rpc method validateaddress (https://docs.neo.org/en-us/node/cli/2.9.4/api/validateaddress.html)
- add tests
- add to README.md

* revert go.sum

* remove break

* more tests and C# errors

* simplify

* fix after master merge
2019-02-13 18:18:47 +00:00
Evgeniy Kulikov
763452fe33 Fix #130: Wrong answer for RPC server method getaccountstate (#131)
* Fix #130: Wrong answer for RPC server method getaccountstate

- fixed RPC Server response
- fixed RPC Server tests
- remove unused package from go.mod

* add index and type checker

* fix review comments (thx @aprasolova)
2019-02-13 18:01:52 +00:00
Evgeniy Kulikov
630919bf7d Fix typos and warnings for GoReport / GolangCiLinter (#132)
- typos
- gofmt -s
- govet warnings
- golangci-lint run
2019-02-09 16:53:58 +01:00
dauTT
7e43717657 Implemented rcp method GetAccountState (#124)
* Implemented rcp method GetAccountState

* code clean up

* Removed empty line

* Used consistently github.com/pkg/errors package. Amended error message

* Get rid of fmt.Sprintf and use either errors.Errorf or errors.Wrapf

* cosmetic changes
2019-02-08 09:04:38 +01:00
Evgeniy Kulikov
f000b76879 [FIX] Formatting and code-style (#118)
* [FIX] Formatting and code-style

- gofmt
- import resort
- prealloc slices
- simplify code

* fix vet
2019-01-25 12:20:35 +01:00
dauTT
1360e1de68 Added rpc unit tests (#107)
* Fixed small incosistencies related to comments and variable name

* For testing purposes we have to move the method newBlockchain from the cli/server/server.go to  pkg/core/blockchain.go. In addition we have to rename it to NewBlockchainLevelDB in order to be able to export it and avoid naming conflicts. In future we still need to think how to switch between different blockchain implementation easily but for the time being this is not possible.

* Added unit tests for the rpc server

* Added unit_testnet chain fixture

* fixed port number

* Added errors handling

* move unit_testnet chain from 'cli/chains' to 'pkg/rpc/chains'
2019-01-22 13:14:52 +01:00