mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Add record verifier and encoding
This commit is contained in:
parent
3ab01e7d96
commit
79d0352d6d
10 changed files with 358 additions and 113 deletions
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
anystore "github.com/anyproto/any-store"
|
||||
"github.com/anyproto/go-chash"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
"storj.io/drpc"
|
||||
|
@ -44,114 +43,12 @@ import (
|
|||
"github.com/anyproto/any-sync/net/streampool/streamhandler"
|
||||
"github.com/anyproto/any-sync/node/nodeclient"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
"github.com/anyproto/any-sync/nodeconf/testconf"
|
||||
"github.com/anyproto/any-sync/testutil/accounttest"
|
||||
"github.com/anyproto/any-sync/util/crypto"
|
||||
"github.com/anyproto/any-sync/util/syncqueues"
|
||||
)
|
||||
|
||||
type mockConf struct {
|
||||
id string
|
||||
networkId string
|
||||
configuration nodeconf.Configuration
|
||||
}
|
||||
|
||||
func (m *mockConf) NetworkCompatibilityStatus() nodeconf.NetworkCompatibilityStatus {
|
||||
return nodeconf.NetworkCompatibilityStatusOk
|
||||
}
|
||||
|
||||
func (m *mockConf) Init(a *app.App) (err error) {
|
||||
accountKeys := a.MustComponent(accountService.CName).(accountService.Service).Account()
|
||||
networkId := accountKeys.SignKey.GetPublic().Network()
|
||||
node := nodeconf.Node{
|
||||
PeerId: accountKeys.PeerId,
|
||||
Addresses: []string{"127.0.0.1:4430"},
|
||||
Types: []nodeconf.NodeType{nodeconf.NodeTypeTree},
|
||||
}
|
||||
m.id = networkId
|
||||
m.networkId = networkId
|
||||
m.configuration = nodeconf.Configuration{
|
||||
Id: networkId,
|
||||
NetworkId: networkId,
|
||||
Nodes: []nodeconf.Node{node},
|
||||
CreationTime: time.Now(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) Name() (name string) {
|
||||
return nodeconf.CName
|
||||
}
|
||||
|
||||
func (m *mockConf) Run(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) Close(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) Id() string {
|
||||
return m.id
|
||||
}
|
||||
|
||||
func (m *mockConf) Configuration() nodeconf.Configuration {
|
||||
return m.configuration
|
||||
}
|
||||
|
||||
func (m *mockConf) NodeIds(spaceId string) []string {
|
||||
var nodeIds []string
|
||||
for _, node := range m.configuration.Nodes {
|
||||
nodeIds = append(nodeIds, node.PeerId)
|
||||
}
|
||||
return nodeIds
|
||||
}
|
||||
|
||||
func (m *mockConf) IsResponsible(spaceId string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *mockConf) FilePeers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) ConsensusPeers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) CoordinatorPeers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) NamingNodePeers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) PaymentProcessingNodePeers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) PeerAddresses(peerId string) (addrs []string, ok bool) {
|
||||
if peerId == m.configuration.Nodes[0].PeerId {
|
||||
return m.configuration.Nodes[0].Addresses, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (m *mockConf) CHash() chash.CHash {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockConf) Partition(spaceId string) (part int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *mockConf) NodeTypes(nodeId string) []nodeconf.NodeType {
|
||||
if nodeId == m.configuration.Nodes[0].PeerId {
|
||||
return m.configuration.Nodes[0].Types
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ nodeclient.NodeClient = (*mockNodeClient)(nil)
|
||||
|
||||
type mockNodeClient struct {
|
||||
|
@ -654,7 +551,7 @@ func newFixture(t *testing.T) *spaceFixture {
|
|||
app: &app.App{},
|
||||
config: &mockConfig{},
|
||||
account: &accounttest.AccountTestService{},
|
||||
configurationService: &mockConf{},
|
||||
configurationService: &testconf.StubConf{},
|
||||
streamOpener: newStreamOpener("spaceId"),
|
||||
peerManagerProvider: &testPeerManagerProvider{},
|
||||
storageProvider: &spaceStorageProvider{rootPath: t.TempDir()},
|
||||
|
@ -699,7 +596,7 @@ func newPeerFixture(t *testing.T, spaceId string, keys *accountdata.AccountKeys,
|
|||
app: &app.App{},
|
||||
config: &mockConfig{},
|
||||
account: accounttest.NewWithAcc(keys),
|
||||
configurationService: &mockConf{},
|
||||
configurationService: &testconf.StubConf{},
|
||||
storageProvider: provider,
|
||||
streamOpener: newStreamOpener(spaceId),
|
||||
peerManagerProvider: &testPeerManagerProvider{},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue