forked from pactus-project/pactus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
106 lines (88 loc) · 2.95 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package wallet
import (
"context"
"fmt"
"github.com/pactus-project/pactus/types/tx"
pactus "github.com/pactus-project/pactus/www/grpc/gen/go"
)
type blockchainServer struct{}
type transactionServer struct{}
var (
tBlockchainInfoResponse *pactus.GetBlockchainInfoResponse
tAccountResponse *pactus.GetAccountResponse
tValidatorResponse *pactus.GetValidatorResponse
)
func (s *blockchainServer) GetBlockchainInfo(_ context.Context,
_ *pactus.GetBlockchainInfoRequest,
) (*pactus.GetBlockchainInfoResponse, error) {
return tBlockchainInfoResponse, nil
}
func (s *blockchainServer) GetConsensusInfo(_ context.Context,
_ *pactus.GetConsensusInfoRequest,
) (*pactus.GetConsensusInfoResponse, error) {
return &pactus.GetConsensusInfoResponse{}, nil
}
func (s *blockchainServer) GetBlockHash(_ context.Context,
_ *pactus.GetBlockHashRequest,
) (*pactus.GetBlockHashResponse, error) {
return &pactus.GetBlockHashResponse{}, nil
}
func (s *blockchainServer) GetBlockHeight(_ context.Context,
_ *pactus.GetBlockHeightRequest,
) (*pactus.GetBlockHeightResponse, error) {
return &pactus.GetBlockHeightResponse{}, nil
}
func (s *blockchainServer) GetBlock(_ context.Context,
_ *pactus.GetBlockRequest,
) (*pactus.GetBlockResponse, error) {
return &pactus.GetBlockResponse{}, nil
}
func (s *blockchainServer) GetAccount(_ context.Context,
_ *pactus.GetAccountRequest,
) (*pactus.GetAccountResponse, error) {
if tAccountResponse != nil {
return tAccountResponse, nil
}
return nil, fmt.Errorf("unknown request")
}
func (s *blockchainServer) GetValidatorAddresses(_ context.Context,
_ *pactus.GetValidatorAddressesRequest,
) (*pactus.GetValidatorAddressesResponse, error) {
return &pactus.GetValidatorAddressesResponse{}, nil
}
func (s *blockchainServer) GetValidatorByNumber(_ context.Context,
_ *pactus.GetValidatorByNumberRequest,
) (*pactus.GetValidatorResponse, error) {
return &pactus.GetValidatorResponse{}, nil
}
func (s *blockchainServer) GetValidator(_ context.Context,
_ *pactus.GetValidatorRequest,
) (*pactus.GetValidatorResponse, error) {
if tValidatorResponse != nil {
return tValidatorResponse, nil
}
return nil, fmt.Errorf("unknown request")
}
func (s *blockchainServer) GetPublicKey(_ context.Context,
_ *pactus.GetPublicKeyRequest,
) (*pactus.GetPublicKeyResponse, error) {
return &pactus.GetPublicKeyResponse{}, nil
}
func (s *transactionServer) GetTransaction(_ context.Context,
_ *pactus.GetTransactionRequest,
) (*pactus.GetTransactionResponse, error) {
return &pactus.GetTransactionResponse{}, nil
}
func (s *transactionServer) CalculateFee(_ context.Context,
_ *pactus.CalculateFeeRequest,
) (*pactus.CalculateFeeResponse, error) {
return &pactus.CalculateFeeResponse{Fee: 0}, nil
}
func (s *transactionServer) SendRawTransaction(_ context.Context,
req *pactus.SendRawTransactionRequest,
) (*pactus.SendRawTransactionResponse, error) {
trx, _ := tx.FromBytes(req.Data)
return &pactus.SendRawTransactionResponse{
Id: trx.ID().Bytes(),
}, nil
}