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
|
```proto
|
||||||
enum TransactionType {
|
enum TransactionType {
|
||||||
@ -65,7 +65,7 @@ message Block {
|
|||||||
```
|
```
|
||||||
google.protobuf.Empty
|
google.protobuf.Empty
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -80,7 +80,7 @@ bdchain.api.ClientVersionResponse
|
|||||||
```
|
```
|
||||||
(empty)
|
(empty)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Response**
|
**Response**
|
||||||
```yaml
|
```yaml
|
||||||
version: 'TxLedgerGo/v0.0.1alpha/darwin/go1.11'
|
version: 'TxLedgerGo/v0.0.1alpha/darwin/go1.11'
|
||||||
@ -99,7 +99,7 @@ message CreateLedgerRequest {
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```proto
|
```proto
|
||||||
message CreateLedgerResponse {
|
message CreateLedgerResponse {
|
||||||
bool ok = 1;
|
bool ok = 1;
|
||||||
@ -137,7 +137,7 @@ name: '' (defualt value)
|
|||||||
```yaml
|
```yaml
|
||||||
code: Code.InvalidArgument
|
code: Code.InvalidArgument
|
||||||
message: 'name must not be empty'
|
message: 'name must not be empty'
|
||||||
details:
|
details:
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -172,7 +172,7 @@ message GetLedgersResponse {
|
|||||||
ledgers:
|
ledgers:
|
||||||
- 'first'
|
- 'first'
|
||||||
- 'second'
|
- 'second'
|
||||||
- 'third'
|
- 'third'
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -197,7 +197,7 @@ message SendTransactionRequest {
|
|||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```proto
|
```proto
|
||||||
message SendTransactionResponse {
|
message SendTransactionResponse {
|
||||||
bytes hash = 1;
|
bytes hash = 1;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -257,7 +257,7 @@ details:
|
|||||||
```
|
```
|
||||||
google.protobuf.Empty
|
google.protobuf.Empty
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -272,10 +272,10 @@ bdchain.api.ClientVersionResponse
|
|||||||
```
|
```
|
||||||
(empty)
|
(empty)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Response**
|
**Response**
|
||||||
```yaml
|
```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;
|
string ledger = 1;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```proto
|
```proto
|
||||||
@ -345,7 +345,7 @@ message GetBlockByNumberRequest {
|
|||||||
bool full_transaction = 3;
|
bool full_transaction = 3;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -445,7 +445,7 @@ message GetBlockByHashRequest {
|
|||||||
bool full_transaction = 3;
|
bool full_transaction = 3;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -490,7 +490,7 @@ message GetTransactionByHashRequest {
|
|||||||
bytes hash = 2;
|
bytes hash = 2;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -536,7 +536,7 @@ message GetTransactionByBlockNumberAndIndexRequest {
|
|||||||
uint32 index = 3;
|
uint32 index = 3;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -583,7 +583,7 @@ message GetTransactionByBlockHashAndIndexRequest {
|
|||||||
uint32 index = 3;
|
uint32 index = 3;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
### 编译
|
### 编译
|
||||||
|
|
||||||
1. 准备好 Go 环境
|
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` 目录
|
3. 切换工作目录到 `mockserver` 目录
|
||||||
4. 使用 `go get -d ./...` 安装此项目依赖
|
4. 使用 `go get -d ./...` 安装此项目依赖
|
||||||
5. 使用 `go build` 编译
|
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