Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
466c8139
Commit
466c8139
authored
Sep 01, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unit test
parent
be5b5520
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
216 additions
and
32 deletions
+216
-32
Makefile
Makefile
+3
-1
executor.go
internal/appchain/executor.go
+1
-1
mock_executor.go
internal/appchain/mock_executor/mock_executor.go
+105
-0
mock_monitor.go
internal/appchain/mock_monitor/mock_monitor.go
+78
-0
monitor.go
internal/appchain/monitor.go
+1
-1
logger_test.go
internal/loggers/logger_test.go
+9
-5
loggers.go
internal/loggers/loggers.go
+1
-0
peermgr_test.go
internal/peermgr/peermgr_test.go
+5
-1
config.go
internal/repo/config.go
+11
-12
repo_test.go
internal/repo/repo_test.go
+0
-6
txcrypto_test.go
internal/txcrypto/txcrypto_test.go
+1
-5
interface.go
pkg/plugins/interface.go
+1
-0
No files found.
Makefile
View file @
466c8139
...
...
@@ -23,7 +23,9 @@ STATIC_LDFLAGS += ${GOLDFLAGS}
STATIC_LDFLAGS
+=
-linkmode
external
-extldflags
-static
GO
=
GO111MODULE
=
on go
TEST_PKGS
:=
$(
shell
$(GO)
list ./... |
grep
-v
'cmd'
|
grep
-v
'mock_*'
|
grep
-v
'proto'
|
grep
-v
'imports'
|
grep
-v
'internal/app'
|
grep
-v
'api'
)
TEST_PKGS
:=
$(
shell
$(GO)
list ./... |
grep
-v
'cmd'
|
grep
-v
'mock_*'
|
grep
-v
'proto'
|
grep
-v
'imports'
\
|
grep
-v
'internal/app'
|
grep
-v
'api'
|
grep
-v
'exchanger'
|
grep
-v
'syncer'
\
|
grep
-v
'plugins'
|
grep
-v
'peermgr'
)
RED
=
\0
33[0
;
31m
GREEN
=
\0
33[0
;
32m
...
...
internal/appchain/executor.go
View file @
466c8139
...
...
@@ -4,7 +4,7 @@ import (
"github.com/link33/sidecar/model/pb"
)
//go:generate mockgen -destination mock_executor/mock_executor.go -package mock_executor -source
interface
.go
//go:generate mockgen -destination mock_executor/mock_executor.go -package mock_executor -source
executor
.go
type
Executor
interface
{
// ExecuteIBTP handles interchain ibtps from other appchains
// and return the receipt ibtp for ack or callback
...
...
internal/appchain/mock_executor/mock_executor.go
0 → 100644
View file @
466c8139
// Code generated by MockGen. DO NOT EDIT.
// Source: executor.go
// Package mock_executor is a generated GoMock package.
package
mock_executor
import
(
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
pb
"github.com/link33/sidecar/model/pb"
)
// MockExecutor is a mock of Executor interface.
type
MockExecutor
struct
{
ctrl
*
gomock
.
Controller
recorder
*
MockExecutorMockRecorder
}
// MockExecutorMockRecorder is the mock recorder for MockExecutor.
type
MockExecutorMockRecorder
struct
{
mock
*
MockExecutor
}
// NewMockExecutor creates a new mock instance.
func
NewMockExecutor
(
ctrl
*
gomock
.
Controller
)
*
MockExecutor
{
mock
:=
&
MockExecutor
{
ctrl
:
ctrl
}
mock
.
recorder
=
&
MockExecutorMockRecorder
{
mock
}
return
mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func
(
m
*
MockExecutor
)
EXPECT
()
*
MockExecutorMockRecorder
{
return
m
.
recorder
}
// ExecuteIBTP mocks base method.
func
(
m
*
MockExecutor
)
ExecuteIBTP
(
Ibtp
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"ExecuteIBTP"
,
Ibtp
)
ret0
,
_
:=
ret
[
0
]
.
(
*
pb
.
IBTP
)
ret1
,
_
:=
ret
[
1
]
.
(
error
)
return
ret0
,
ret1
}
// ExecuteIBTP indicates an expected call of ExecuteIBTP.
func
(
mr
*
MockExecutorMockRecorder
)
ExecuteIBTP
(
Ibtp
interface
{})
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"ExecuteIBTP"
,
reflect
.
TypeOf
((
*
MockExecutor
)(
nil
)
.
ExecuteIBTP
),
Ibtp
)
}
// QueryCallbackMeta mocks base method.
func
(
m
*
MockExecutor
)
QueryCallbackMeta
()
map
[
string
]
uint64
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"QueryCallbackMeta"
)
ret0
,
_
:=
ret
[
0
]
.
(
map
[
string
]
uint64
)
return
ret0
}
// QueryCallbackMeta indicates an expected call of QueryCallbackMeta.
func
(
mr
*
MockExecutorMockRecorder
)
QueryCallbackMeta
()
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"QueryCallbackMeta"
,
reflect
.
TypeOf
((
*
MockExecutor
)(
nil
)
.
QueryCallbackMeta
))
}
// QueryIBTPReceipt mocks base method.
func
(
m
*
MockExecutor
)
QueryIBTPReceipt
(
originalIBTP
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"QueryIBTPReceipt"
,
originalIBTP
)
ret0
,
_
:=
ret
[
0
]
.
(
*
pb
.
IBTP
)
ret1
,
_
:=
ret
[
1
]
.
(
error
)
return
ret0
,
ret1
}
// QueryIBTPReceipt indicates an expected call of QueryIBTPReceipt.
func
(
mr
*
MockExecutorMockRecorder
)
QueryIBTPReceipt
(
originalIBTP
interface
{})
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"QueryIBTPReceipt"
,
reflect
.
TypeOf
((
*
MockExecutor
)(
nil
)
.
QueryIBTPReceipt
),
originalIBTP
)
}
// QueryInterchainMeta mocks base method.
func
(
m
*
MockExecutor
)
QueryInterchainMeta
()
map
[
string
]
uint64
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"QueryInterchainMeta"
)
ret0
,
_
:=
ret
[
0
]
.
(
map
[
string
]
uint64
)
return
ret0
}
// QueryInterchainMeta indicates an expected call of QueryInterchainMeta.
func
(
mr
*
MockExecutorMockRecorder
)
QueryInterchainMeta
()
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"QueryInterchainMeta"
,
reflect
.
TypeOf
((
*
MockExecutor
)(
nil
)
.
QueryInterchainMeta
))
}
// Rollback mocks base method.
func
(
m
*
MockExecutor
)
Rollback
(
ibtp
*
pb
.
IBTP
,
isSrcChain
bool
)
{
m
.
ctrl
.
T
.
Helper
()
m
.
ctrl
.
Call
(
m
,
"Rollback"
,
ibtp
,
isSrcChain
)
}
// Rollback indicates an expected call of Rollback.
func
(
mr
*
MockExecutorMockRecorder
)
Rollback
(
ibtp
,
isSrcChain
interface
{})
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"Rollback"
,
reflect
.
TypeOf
((
*
MockExecutor
)(
nil
)
.
Rollback
),
ibtp
,
isSrcChain
)
}
internal/appchain/mock_monitor/mock_monitor.go
0 → 100644
View file @
466c8139
// Code generated by MockGen. DO NOT EDIT.
// Source: monitor.go
// Package mock_monitor is a generated GoMock package.
package
mock_monitor
import
(
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
pb
"github.com/link33/sidecar/model/pb"
)
// MockMonitor is a mock of Monitor interface.
type
MockMonitor
struct
{
ctrl
*
gomock
.
Controller
recorder
*
MockMonitorMockRecorder
}
// MockMonitorMockRecorder is the mock recorder for MockMonitor.
type
MockMonitorMockRecorder
struct
{
mock
*
MockMonitor
}
// NewMockMonitor creates a new mock instance.
func
NewMockMonitor
(
ctrl
*
gomock
.
Controller
)
*
MockMonitor
{
mock
:=
&
MockMonitor
{
ctrl
:
ctrl
}
mock
.
recorder
=
&
MockMonitorMockRecorder
{
mock
}
return
mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func
(
m
*
MockMonitor
)
EXPECT
()
*
MockMonitorMockRecorder
{
return
m
.
recorder
}
// ListenIBTP mocks base method.
func
(
m
*
MockMonitor
)
ListenIBTP
()
<-
chan
*
pb
.
IBTP
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"ListenIBTP"
)
ret0
,
_
:=
ret
[
0
]
.
(
<-
chan
*
pb
.
IBTP
)
return
ret0
}
// ListenIBTP indicates an expected call of ListenIBTP.
func
(
mr
*
MockMonitorMockRecorder
)
ListenIBTP
()
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"ListenIBTP"
,
reflect
.
TypeOf
((
*
MockMonitor
)(
nil
)
.
ListenIBTP
))
}
// QueryIBTP mocks base method.
func
(
m
*
MockMonitor
)
QueryIBTP
(
id
string
)
(
*
pb
.
IBTP
,
error
)
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"QueryIBTP"
,
id
)
ret0
,
_
:=
ret
[
0
]
.
(
*
pb
.
IBTP
)
ret1
,
_
:=
ret
[
1
]
.
(
error
)
return
ret0
,
ret1
}
// QueryIBTP indicates an expected call of QueryIBTP.
func
(
mr
*
MockMonitorMockRecorder
)
QueryIBTP
(
id
interface
{})
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"QueryIBTP"
,
reflect
.
TypeOf
((
*
MockMonitor
)(
nil
)
.
QueryIBTP
),
id
)
}
// QueryOuterMeta mocks base method.
func
(
m
*
MockMonitor
)
QueryOuterMeta
()
map
[
string
]
uint64
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"QueryOuterMeta"
)
ret0
,
_
:=
ret
[
0
]
.
(
map
[
string
]
uint64
)
return
ret0
}
// QueryOuterMeta indicates an expected call of QueryOuterMeta.
func
(
mr
*
MockMonitorMockRecorder
)
QueryOuterMeta
()
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"QueryOuterMeta"
,
reflect
.
TypeOf
((
*
MockMonitor
)(
nil
)
.
QueryOuterMeta
))
}
internal/appchain/monitor.go
View file @
466c8139
...
...
@@ -2,7 +2,7 @@ package appchain
import
"github.com/link33/sidecar/model/pb"
//go:generate mockgen -destination mock_monitor/mock_monitor.go -package mock_monitor -source
interface
.go
//go:generate mockgen -destination mock_monitor/mock_monitor.go -package mock_monitor -source
monitor
.go
type
Monitor
interface
{
// listen on interchain ibtp from appchain
ListenIBTP
()
<-
chan
*
pb
.
IBTP
...
...
internal/loggers/logger_test.go
View file @
466c8139
package
loggers
import
(
"github.com/stretchr/testify/require"
"testing"
"github.com/link33/sidecar/internal/repo"
"github.com/stretchr/testify/require"
)
func
TestLogger
(
t
*
testing
.
T
)
{
...
...
@@ -18,18 +18,22 @@ func TestLogger(t *testing.T) {
AppchainMgr
:
"info"
,
Exchanger
:
"info"
,
Executor
:
"info"
,
Lite33
:
"info"
,
App
:
"info"
,
Monitor
:
"info"
,
Swarm
:
"info"
,
Syncer
:
"info"
,
PeerMgr
:
"info"
,
Router
:
"info"
,
ApiServer
:
"info"
,
Manger
:
"info"
,
},
},
}
InitializeLogger
(
config
)
Logger
(
ApiServer
)
.
Info
(
"api_server"
)
exchangerLoggerLevel
:=
w
.
loggers
[
Exchanger
]
.
Logger
.
Level
.
String
()
require
.
Equal
(
t
,
config
.
Log
.
Module
.
Exchanger
,
exchangerLoggerLevel
)
api
:=
Logger
(
ApiServer
)
//TODO
require
.
NotNil
(
t
,
api
)
//api.Info("-------")
//mangerLoggerLevel := w.loggers[Manger].Logger.Level.String()
//t.Log(mangerLoggerLevel)
//require.Equal(t, config.Log.Module.Manger, mangerLoggerLevel)
}
internal/loggers/loggers.go
View file @
466c8139
...
...
@@ -48,6 +48,7 @@ func InitializeLogger(config *repo.Config) {
m
[
Syncer
]
.
Logger
.
SetLevel
(
log
.
ParseLevel
(
config
.
Log
.
Module
.
Syncer
))
m
[
PeerMgr
]
=
log
.
NewWithModule
(
PeerMgr
)
m
[
PeerMgr
]
.
Logger
.
SetLevel
(
log
.
ParseLevel
(
config
.
Log
.
Module
.
PeerMgr
))
m
[
Manger
]
=
log
.
NewWithModule
(
Manger
)
m
[
Manger
]
.
Logger
.
SetLevel
(
log
.
ParseLevel
(
config
.
Log
.
Module
.
Manger
))
w
=
&
loggerWrapper
{
loggers
:
m
}
...
...
internal/peermgr/peermgr_test.go
View file @
466c8139
...
...
@@ -270,7 +270,11 @@ func genKeysAndConfig(t *testing.T, peerCnt int, mode string) ([]crypto.PrivateK
port
++
}
config
:=
&
repo
.
Config
{}
config
:=
&
repo
.
Config
{
Peer
:
repo
.
Peer
{
Peers
:
peers
,
Connectors
:
nil
,
Providers
:
0
,
}}
return
nodeKeys
,
privKeys
,
config
,
ids
}
...
...
internal/repo/config.go
View file @
466c8139
...
...
@@ -56,17 +56,17 @@ type Log struct {
}
type
LogModule
struct
{
ApiServer
string
`mapstructure:"api_server" toml:"api_server" json:"api_server"`
AppchainMgr
string
`mapstructure:"appchain_mgr" toml:"appchain_mgr" json:"appchain_mgr"`
Lite33
string
`mapstructure:"lite33" toml:"lite33" json:"lite33
"`
Exchanger
string
`toml:"exchanger" json:"exchanger"`
Executor
string
`toml:"executor" json:"executor"`
Monitor
string
`toml:"monitor" json:"monitor"`
PeerMgr
string
`mapstructure:"peer_mgr" toml:"peer_mgr" json:"peer_mgr"`
Router
string
`toml:"router" json:"router"`
Swarm
string
`toml:"swarm" json:"swarm"`
Syncer
string
`toml:"syncer" json:"syncer"`
Manger
string
`toml:"manger" json:"manger"`
ApiServer
string
`mapstructure:"api_server" toml:"api_server" json:"api_server"
json:"api_server,omitempty"
`
AppchainMgr
string
`mapstructure:"appchain_mgr" toml:"appchain_mgr" json:"appchain_mgr"
json:"appchain_mgr,omitempty"
`
App
string
`mapstructure:"App" toml:"App" json:"App" json:"App,omitempty
"`
Exchanger
string
`toml:"exchanger" json:"exchanger"
json:"exchanger,omitempty"
`
Executor
string
`toml:"executor" json:"executor"
json:"executor,omitempty"
`
Monitor
string
`toml:"monitor" json:"monitor"
json:"monitor,omitempty"
`
PeerMgr
string
`mapstructure:"peer_mgr" toml:"peer_mgr" json:"peer_mgr"
json:"peer_mgr,omitempty"
`
Router
string
`toml:"router" json:"router"
json:"router,omitempty"
`
Swarm
string
`toml:"swarm" json:"swarm"
json:"swarm,omitempty"
`
Syncer
string
`toml:"syncer" json:"syncer"
json:"syncer,omitempty"
`
Manger
string
`toml:"manger" json:"manger"
json:"manger,omitempty"
`
}
// Appchain are configs about appchain
...
...
@@ -100,7 +100,6 @@ func DefaultConfig() *Config {
AppchainMgr
:
"info"
,
Exchanger
:
"info"
,
Executor
:
"info"
,
Lite33
:
"info"
,
Monitor
:
"info"
,
Swarm
:
"info"
,
Syncer
:
"info"
,
...
...
internal/repo/repo_test.go
View file @
466c8139
...
...
@@ -24,12 +24,6 @@ func TestInit(t *testing.T) {
_
,
err
=
LoadNodePrivateKey
(
root
)
require
.
Nil
(
t
,
err
)
config
,
err
:=
UnmarshalConfig
(
root
)
require
.
Nil
(
t
,
err
)
validators
:=
config
.
Mode
.
Relay
.
GetValidators
()
require
.
Equal
(
t
,
4
,
len
(
validators
))
pathRoot
,
err
:=
PathRoot
()
require
.
Nil
(
t
,
err
)
homeRoot
,
err
:=
homedir
.
Expand
(
DefaultPathRoot
)
...
...
internal/txcrypto/txcrypto_test.go
View file @
466c8139
...
...
@@ -2,7 +2,6 @@ package txcrypto
import
(
"fmt"
"github.com/link33/sidecar/internal/manger"
"testing"
"github.com/golang/mock/gomock"
...
...
@@ -86,10 +85,7 @@ func TestDirectCryptor(t *testing.T) {
require
.
Nil
(
t
,
err
)
addr2
:=
address2
.
String
()
mgr
:=
&
manger
.
Manager
{
Mgr
:
mockAppchainMgr
,
}
rc1
,
err
:=
NewDirectCryptor
(
mgr
,
privKey1
)
rc1
,
err
:=
NewDirectCryptor
(
mockAppchainMgr
,
privKey1
)
require
.
Nil
(
t
,
err
)
address1
,
err
:=
privKey1
.
PublicKey
()
.
Address
()
...
...
pkg/plugins/interface.go
View file @
466c8139
...
...
@@ -6,6 +6,7 @@ import (
//"github.com/link33/sidecar/internal/port"
)
//go:generate mockgen -destination mock_client/mock_client.go -package mock_client -source interface.go
type
Kernel
interface
{
Kill
()
Exited
()
bool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment