Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
9fa8209c
Unverified
Commit
9fa8209c
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
rpc/v0: add simmple test for go-wire codec of CallTx
parent
e7ee11fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rpc/v0/json_service_data_test.go
+71
-0
71 additions, 0 deletions
rpc/v0/json_service_data_test.go
with
71 additions
and
0 deletions
rpc/v0/json_service_data_test.go
0 → 100644
+
71
−
0
View file @
9fa8209c
// Copyright 2017 Monax Industries Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
rpc_v0
import
(
"encoding/json"
"testing"
"github.com/eris-ltd/eris-db/rpc"
"github.com/eris-ltd/eris-db/txs"
"github.com/stretchr/testify/assert"
)
var
testBroadcastCallTxJsonRequest
=
[]
byte
(
`
{
"id": "57EC1D39-7B3D-4F96-B286-8FC128177AFC4",
"jsonrpc": "2.0",
"method": "erisdb.broadcastTx",
"params": [
2,
{
"address": "5A9083BB0EFFE4C8EB2ADD29174994F73E77D418",
"data": "2F2397A00000000000000000000000000000000000000000000000000000000000003132",
"fee": 1,
"gas_limit": 1000000,
"input": {
"address": "BE18FDCBF12BF99F4D75325E17FF2E78F1A35FE8",
"amount": 1,
"pub_key": [
1,
"8D1611925948DC2EDDF739FB65CE517757D286155A039B28441C3349BE9A8C38"
],
"sequence": 2,
"signature": [
1,
"B090D622F143ECEDA9B9E7B15485CE7504453C05434951CF867B013D80ED1BD2A0CA32846FC175D234CDFB9D5C3D792759E8FE79FD4DB3006B24950EE3C37D00"
]
}
}
]
}`
)
// strictly test the codec for go-wire encoding of the Json format,
// This should restore compatibility with the format on v0.11.4
// (which was broken on v0.12)
func
TestCallTxJsonFormatCodec
(
t
*
testing
.
T
)
{
codec
:=
NewTCodec
()
param
:=
new
(
txs
.
Tx
)
// Create new request object and unmarshal.
request
:=
&
rpc
.
RPCRequest
{}
assert
.
NoError
(
t
,
json
.
Unmarshal
(
testBroadcastCallTxJsonRequest
,
request
),
"Provided JSON test data does not unmarshal to rpc.RPCRequest object."
)
assert
.
NoError
(
t
,
codec
.
DecodeBytes
(
param
,
request
.
Params
),
"RPC codec failed to decode params as transaction type."
)
_
,
ok
:=
(
*
param
)
.
(
*
txs
.
CallTx
)
assert
.
True
(
t
,
ok
,
"Type byte 0x02 should unmarshal into CallTx."
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment