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
This commit is contained in:
parent
a5e85d69de
commit
095653af23
22 changed files with 879 additions and 68 deletions
|
@ -116,7 +116,7 @@ var testRpcCases = []tc{
|
|||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["45a41306c846ea80290416143e8e856559818065be3f4e143c60e43a", 1] }`,
|
||||
method: "getrawtransaction_4",
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params","data":"param at index 0, (45a41306c846ea80290416143e8e856559818065be3f4e143c60e43a), could not be decode to Uint256: expected string size of 64 got 56"},"id":1}`,
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params"},"id":1}`,
|
||||
},
|
||||
|
||||
// Good case, valid transaction
|
||||
|
@ -216,6 +216,27 @@ var testRpcCases = []tc{
|
|||
method: "validateaddress_4",
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params"},"id":1}`,
|
||||
},
|
||||
|
||||
// Good case
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "sendrawtransaction", "params": ["80000190274d792072617720636f6e7472616374207472616e73616374696f6e206465736372697074696f6e01949354ea0a8b57dfee1e257a1aedd1e0eea2e5837de145e8da9c0f101bfccc8e0100029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500a3e11100000000ea610aa6db39bd8c8556c9569d94b5e5a5d0ad199b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc5004f2418010000001cc9c05cefffe6cdd7b182816a9152ec218d2ec0014140dbd3cddac5cb2bd9bf6d93701f1a6f1c9dbe2d1b480c54628bbb2a4d536158c747a6af82698edf9f8af1cac3850bcb772bd9c8e4ac38f80704751cc4e0bd0e67232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"] }`,
|
||||
method: "sendrawtransaction_1",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":true,"id":1}`,
|
||||
},
|
||||
|
||||
/* Good case: TODO: uncomment this test case once https://github.com/CityOfZion/neo-go/issues/173 is fixed!
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "sendrawtransaction", "params": ["d1001b00046e616d6567d3d8602814a429a91afdbaa3914884a1c90c733101201cc9c05cefffe6cdd7b182816a9152ec218d2ec000000141403387ef7940a5764259621e655b3c621a6aafd869a611ad64adcc364d8dd1edf84e00a7f8b11b630a377eaef02791d1c289d711c08b7ad04ff0d6c9caca22cfe6232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"] }`,
|
||||
method: "sendrawtransaction_2",
|
||||
expectedResult: `{"jsonrpc":"2.0","result":true,"id":1}`,
|
||||
},*/
|
||||
|
||||
// Bad case, incorrect raw transaction
|
||||
{
|
||||
rpcCall: `{ "jsonrpc": "2.0", "id": 1, "method": "sendrawtransaction", "params": ["0274d792072617720636f6e7472616374207472616e73616374696f6e206465736372697074696f6e01949354ea0a8b57dfee1e257a1aedd1e0eea2e5837de145e8da9c0f101bfccc8e0100029b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc500a3e11100000000ea610aa6db39bd8c8556c9569d94b5e5a5d0ad199b7cffdaa674beae0f930ebe6085af9093e5fe56b34a5c220ccdcf6efc336fc5004f2418010000001cc9c05cefffe6cdd7b182816a9152ec218d2ec0014140dbd3cddac5cb2bd9bf6d93701f1a6f1c9dbe2d1b480c54628bbb2a4d536158c747a6af82698edf9f8af1cac3850bcb772bd9c8e4ac38f80704751cc4e0bd0e67232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"] }`,
|
||||
method: "sendrawtransaction_1",
|
||||
expectedResult: `{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid Params"},"id":1}`,
|
||||
},
|
||||
}
|
||||
|
||||
func TestHandler(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue