Format test.md
This commit is contained in:
parent
77f2402609
commit
8e9d10c38b
32
test.md
32
test.md
@ -8,7 +8,7 @@ message ClientVersionResponse {
|
||||
}
|
||||
```
|
||||
|
||||
### TransactionType
|
||||
### TransactionType
|
||||
|
||||
```proto
|
||||
enum TransactionType {
|
||||
@ -65,7 +65,7 @@ message Block {
|
||||
```
|
||||
google.protobuf.Empty
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -80,7 +80,7 @@ bdchain.api.ClientVersionResponse
|
||||
```
|
||||
(empty)
|
||||
```
|
||||
|
||||
|
||||
**Response**
|
||||
```yaml
|
||||
version: 'TxLedgerGo/v0.0.1alpha/darwin/go1.11'
|
||||
@ -99,7 +99,7 @@ message CreateLedgerRequest {
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
|
||||
```proto
|
||||
message CreateLedgerResponse {
|
||||
bool ok = 1;
|
||||
@ -137,7 +137,7 @@ name: '' (defualt value)
|
||||
```yaml
|
||||
code: Code.InvalidArgument
|
||||
message: 'name must not be empty'
|
||||
details:
|
||||
details:
|
||||
```
|
||||
|
||||
---
|
||||
@ -172,7 +172,7 @@ message GetLedgersResponse {
|
||||
ledgers:
|
||||
- 'first'
|
||||
- 'second'
|
||||
- 'third'
|
||||
- 'third'
|
||||
```
|
||||
|
||||
---
|
||||
@ -197,7 +197,7 @@ message SendTransactionRequest {
|
||||
#### Response
|
||||
|
||||
```proto
|
||||
message SendTransactionResponse {
|
||||
message SendTransactionResponse {
|
||||
bytes hash = 1;
|
||||
}
|
||||
```
|
||||
@ -257,7 +257,7 @@ details:
|
||||
```
|
||||
google.protobuf.Empty
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -272,10 +272,10 @@ bdchain.api.ClientVersionResponse
|
||||
```
|
||||
(empty)
|
||||
```
|
||||
|
||||
|
||||
**Response**
|
||||
```yaml
|
||||
version: 'AcChainGo/v0.0.1alpha/darwin/go1.11'
|
||||
version: 'AcChainGo/v0.0.1alpha/darwin/go1.11'
|
||||
```
|
||||
|
||||
---
|
||||
@ -289,7 +289,7 @@ message BlockNumberRequest {
|
||||
string ledger = 1;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```proto
|
||||
@ -345,7 +345,7 @@ message GetBlockByNumberRequest {
|
||||
bool full_transaction = 3;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -445,7 +445,7 @@ message GetBlockByHashRequest {
|
||||
bool full_transaction = 3;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -490,7 +490,7 @@ message GetTransactionByHashRequest {
|
||||
bytes hash = 2;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -536,7 +536,7 @@ message GetTransactionByBlockNumberAndIndexRequest {
|
||||
uint32 index = 3;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
@ -583,7 +583,7 @@ message GetTransactionByBlockHashAndIndexRequest {
|
||||
uint32 index = 3;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Response
|
||||
|
||||
```
|
||||
|
@ -5,7 +5,7 @@
|
||||
### 编译
|
||||
|
||||
1. 准备好 Go 环境
|
||||
2. 下载 [BDChain Go SDK](https://phabricator.internetapi.cn/source/bdchain/repository/master/) 到 `GOPATH`
|
||||
2. 下载 [BDChain Go SDK](https://phabricator.internetapi.cn/source/bdchain-go-sdk/repository/master/) 到 `GOPATH`
|
||||
3. 切换工作目录到 `mockserver` 目录
|
||||
4. 使用 `go get -d ./...` 安装此项目依赖
|
||||
5. 使用 `go build` 编译
|
@ -1,52 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Errors
|
||||
var (
|
||||
ErrInvalidServer = errors.New("server is invalid")
|
||||
ErrInvalidRequest = errors.New("request is invalid")
|
||||
ErrInvalidParameter = errors.New("parameter is invalid")
|
||||
ErrTestNotImplemented = errors.New("test path not implemented")
|
||||
|
||||
ErrMultiple = errors.New("Multiple errors in transaction")
|
||||
ErrEmptyFrom = errors.New("from must not be empty")
|
||||
ErrInvalidTo = errors.New("to must be a valid 32-byte address")
|
||||
ErrEmptyName = errors.New("name must not be empty")
|
||||
)
|
||||
|
||||
func toStatusError(src error) error {
|
||||
/*__*/ if src == nil {
|
||||
return src
|
||||
} else if _, ok := src.(interface{ GRPCStatus() *status.Status }); ok {
|
||||
return src
|
||||
} else {
|
||||
switch errors.Cause(src) {
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
default:
|
||||
return src
|
||||
case ErrInvalidServer:
|
||||
fallthrough
|
||||
case ErrInvalidRequest:
|
||||
return status.Error(codes.Internal, src.Error())
|
||||
case ErrInvalidParameter:
|
||||
return status.Error(codes.InvalidArgument, src.Error())
|
||||
case ErrTestNotImplemented:
|
||||
return status.Error(codes.Unimplemented, src.Error())
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
case ErrEmptyName:
|
||||
fallthrough
|
||||
case ErrEmptyFrom:
|
||||
fallthrough
|
||||
case ErrInvalidTo:
|
||||
return status.Error(codes.InvalidArgument, src.Error())
|
||||
case ErrMultiple:
|
||||
return status.Error(codes.InvalidArgument, src.Error())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user