Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ec1d3b87d |
14
README.md
14
README.md
@@ -41,7 +41,7 @@ git config --global url."git@gitea.internetapi.cn:".insteadOf "https://gitea.int
|
|||||||
go env -w GOPRIVATE="go.yandata.net"
|
go env -w GOPRIVATE="go.yandata.net"
|
||||||
|
|
||||||
# 安装SDK
|
# 安装SDK
|
||||||
go get go.yandata.net/iod/iod/go-trustlog
|
go get go.yandata.net/wangsiyuan/go-trustlog
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1. 基本使用 - 发布操作
|
### 1. 基本使用 - 发布操作
|
||||||
@@ -52,8 +52,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/highclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/highclient"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -96,7 +96,7 @@ func main() {
|
|||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ func main() {
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/queryclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/queryclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -189,7 +189,7 @@ func main() {
|
|||||||
### 4. 数据库查询(持久化后)
|
### 4. 数据库查询(持久化后)
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
import "go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
repo := persistence.NewOperationRepository(db, log)
|
repo := persistence.NewOperationRepository(db, log)
|
||||||
@@ -388,7 +388,7 @@ op.ServerIP = &serverIP // 可选
|
|||||||
### 3. 自定义签名
|
### 3. 自定义签名
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "go.yandata.net/iod/iod/go-trustlog/api/sm2signer"
|
import "go.yandata.net/wangsiyuan/go-trustlog/api/sm2signer"
|
||||||
|
|
||||||
// 使用SM2算法签名
|
// 使用SM2算法签名
|
||||||
signer := sm2signer.NewSM2Signer(privateKeyBytes)
|
signer := sm2signer.NewSM2Signer(privateKeyBytes)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
"github.com/apache/pulsar-client-go/pulsar"
|
"github.com/apache/pulsar-client-go/pulsar"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
"github.com/apache/pulsar-client-go/pulsar"
|
"github.com/apache/pulsar-client-go/pulsar"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
//go:generate protoc --go_out=./pb --go-grpc_out=./pb --go_opt=module=go.yandata.net/iod/iod/go-trustlog/api/grpc/pb --go-grpc_opt=module=go.yandata.net/iod/iod/go-trustlog/api/grpc/pb --proto_path=. ./common.proto ./operation.proto ./record.proto
|
//go:generate protoc --go_out=./pb --go-grpc_out=./pb --go_opt=module=go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb --go-grpc_opt=module=go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb --proto_path=. ./common.proto ./operation.proto ./record.proto
|
||||||
// 注意:common.proto 必须首先列出,因为 operation.proto 和 record.proto 都依赖它
|
// 注意:common.proto 必须首先列出,因为 operation.proto 和 record.proto 都依赖它
|
||||||
// 生成的代码将包含 common.pb.go,其中定义了 Proof 类型
|
// 生成的代码将包含 common.pb.go,其中定义了 Proof 类型
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
|
|
||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import (
|
|||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/highclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/highclient"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockPublisher 模拟 message.Publisher.
|
// MockPublisher 模拟 message.Publisher.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewLogger(t *testing.T) {
|
func TestNewLogger(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
_ "github.com/crpt/go-crpt/ed25519" // 注册 Ed25519
|
_ "github.com/crpt/go-crpt/ed25519" // 注册 Ed25519
|
||||||
_ "github.com/crpt/go-crpt/sm2" // 注册 SM2
|
_ "github.com/crpt/go-crpt/sm2" // 注册 SM2
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigSigner 基于配置的通用签名器
|
// ConfigSigner 基于配置的通用签名器
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewConfigSigner_SM2(t *testing.T) {
|
func TestNewConfigSigner_SM2(t *testing.T) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FromProtobuf 将protobuf的OperationData转换为model.Operation.
|
// FromProtobuf 将protobuf的OperationData转换为model.Operation.
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFromProtobuf_Nil(t *testing.T) {
|
func TestFromProtobuf_Nil(t *testing.T) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
_ "github.com/crpt/go-crpt/ed25519" // Import Ed25519
|
_ "github.com/crpt/go-crpt/ed25519" // Import Ed25519
|
||||||
_ "github.com/crpt/go-crpt/sm2" // Import SM2
|
_ "github.com/crpt/go-crpt/sm2" // Import SM2
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SignatureAlgorithm 定义支持的签名算法类型.
|
// SignatureAlgorithm 定义支持的签名算法类型.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCryptoConfig_Validate(t *testing.T) {
|
func TestCryptoConfig_Validate(t *testing.T) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Envelope 包装序列化后的数据,包含元信息和报文体。
|
// Envelope 包装序列化后的数据,包含元信息和报文体。
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSignVerifyDataConsistency 详细测试加签和验签的数据一致性.
|
// TestSignVerifyDataConsistency 详细测试加签和验签的数据一致性.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSignVerifyConsistency 测试加签和验签的一致性
|
// TestSignVerifyConsistency 测试加签和验签的一致性
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewEnvelopeConfig(t *testing.T) {
|
func TestNewEnvelopeConfig(t *testing.T) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetHashTool(t *testing.T) {
|
func TestGetHashTool(t *testing.T) {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOperation_Key(t *testing.T) {
|
func TestOperation_Key(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestOperation_TimestampNanosecondPrecision 验证 Operation 的时间戳在 CBOR 序列化/反序列化后能保留纳秒精度
|
// TestOperation_TimestampNanosecondPrecision 验证 Operation 的时间戳在 CBOR 序列化/反序列化后能保留纳秒精度
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MerkleTreeProofItem 表示Merkle树证明项.
|
// MerkleTreeProofItem 表示Merkle树证明项.
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProofFromProtobuf_Nil(t *testing.T) {
|
func TestProofFromProtobuf_Nil(t *testing.T) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Record 表示一条记录。
|
// Record 表示一条记录。
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRecord_Key(t *testing.T) {
|
func TestRecord_Key(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestRecord_TimestampNanosecondPrecision 验证 Record 的时间戳在 CBOR 序列化/反序列化后能保留纳秒精度
|
// TestRecord_TimestampNanosecondPrecision 验证 Record 的时间戳在 CBOR 序列化/反序列化后能保留纳秒精度
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/crpt/go-crpt"
|
"github.com/crpt/go-crpt"
|
||||||
_ "github.com/crpt/go-crpt/sm2" // Import SM2 to register it
|
_ "github.com/crpt/go-crpt/sm2" // Import SM2 to register it
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestComputeSignature_EmptyPrivateKey(t *testing.T) {
|
func TestComputeSignature_EmptyPrivateKey(t *testing.T) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Signer 签名器接口,用于抽象不同的签名算法实现。
|
// Signer 签名器接口,用于抽象不同的签名算法实现。
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewSM2Signer(t *testing.T) {
|
func TestNewSM2Signer(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSM2HashConsistency 验证SM2加签和验签的一致性
|
// TestSM2HashConsistency 验证SM2加签和验签的一致性
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSM2RequiresHash 测试SM2是否要求预先hash数据
|
// TestSM2RequiresHash 测试SM2是否要求预先hash数据
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestValidationResult_IsProcessing(t *testing.T) {
|
func TestValidationResult_IsProcessing(t *testing.T) {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import (
|
|||||||
|
|
||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// operationPublisherAdapter 适配器,将 PersistenceClient 的 publishToTrustlog 方法适配为 OperationPublisher 接口
|
// operationPublisherAdapter 适配器,将 PersistenceClient 的 publishToTrustlog 方法适配为 OperationPublisher 接口
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import (
|
|||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestClusterSafety_MultipleCursorWorkers 测试多个 Cursor Worker 并发安全
|
// TestClusterSafety_MultipleCursorWorkers 测试多个 Cursor Worker 并发安全
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import (
|
|||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestCursorInitialization 验证 cursor 初始化逻辑
|
// TestCursorInitialization 验证 cursor 初始化逻辑
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OperationRecord 操作记录(包含数据库扩展字段)
|
// OperationRecord 操作记录(包含数据库扩展字段)
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import (
|
|||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 端到端集成测试配置
|
// 端到端集成测试配置
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
"github.com/go-logr/logr"
|
"github.com/go-logr/logr"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Example_dbOnly 演示仅落库策略
|
// Example_dbOnly 演示仅落库策略
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPersistenceManager_DBOnly(t *testing.T) {
|
func TestPersistenceManager_DBOnly(t *testing.T) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestPG_Query_Integration 测试 PostgreSQL 查询功能集成
|
// TestPG_Query_Integration 测试 PostgreSQL 查询功能集成
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/adapter"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/adapter"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestOperationRepository_Query(t *testing.T) {
|
func TestOperationRepository_Query(t *testing.T) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OperationQueryRequest 操作记录查询请求
|
// OperationQueryRequest 操作记录查询请求
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// setupTestDB 创建测试用的 SQLite 内存数据库
|
// setupTestDB 创建测试用的 SQLite 内存数据库
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
"github.com/ThreeDotsLabs/watermill/message"
|
"github.com/ThreeDotsLabs/watermill/message"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RetryWorkerConfig 重试工作器配置
|
// RetryWorkerConfig 重试工作器配置
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/persistence"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/persistence"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Standalone tests - 独立测试,不依赖复杂模块
|
// Standalone tests - 独立测试,不依赖复杂模块
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PersistenceStrategy 存证策略枚举
|
// PersistenceStrategy 存证策略枚举
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/grpcclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/grpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/queryclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/queryclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestNewClient_ErrorCases 测试客户端创建的错误情况
|
// TestNewClient_ErrorCases 测试客户端创建的错误情况
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import (
|
|||||||
"google.golang.org/grpc/test/bufconn"
|
"google.golang.org/grpc/test/bufconn"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/grpc/pb"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/grpc/pb"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/model"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/model"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/api/queryclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/api/queryclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bufSize = 1024 * 1024
|
const bufSize = 1024 * 1024
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module go.yandata.net/iod/iod/go-trustlog
|
module go.yandata.net/wangsiyuan/go-trustlog
|
||||||
|
|
||||||
go 1.25
|
go 1.25
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/grpcclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/grpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfig_GetAddrs(t *testing.T) {
|
func TestConfig_GetAddrs(t *testing.T) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/grpcclient"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/grpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mockClient 用于测试的模拟客户端.
|
// mockClient 用于测试的模拟客户端.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMarshalCanonical(t *testing.T) {
|
func TestMarshalCanonical(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCBORTimePrecision(t *testing.T) {
|
func TestCBORTimePrecision(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewTLVReader(t *testing.T) {
|
func TestNewTLVReader(t *testing.T) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewUUIDv7(t *testing.T) {
|
func TestNewUUIDv7(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/helpers"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetValidator(t *testing.T) {
|
func TestGetValidator(t *testing.T) {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
apilogger "go.yandata.net/iod/iod/go-trustlog/api/logger"
|
apilogger "go.yandata.net/wangsiyuan/go-trustlog/api/logger"
|
||||||
"go.yandata.net/iod/iod/go-trustlog/internal/logger"
|
"go.yandata.net/wangsiyuan/go-trustlog/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewWatermillLoggerAdapter(t *testing.T) {
|
func TestNewWatermillLoggerAdapter(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user