Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Nov 12, 2024
1 parent f3d7778 commit af5c34b
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 174 deletions.
20 changes: 3 additions & 17 deletions pkg/network/anonymity/anonymity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestNodeSettings(t *testing.T) {
func TestSettings(t *testing.T) {
t.Parallel()

for i := 0; i < 3; i++ {
for i := 0; i < 1; i++ {
testSettings(t, i)
}
}
Expand All @@ -89,22 +89,9 @@ func testSettings(t *testing.T, n int) {
return
}
}()
switch n {
switch n { // nolint: gocritic
case 0:
_ = NewSettings(&SSettings{
FNetworkMask: 1,
FFetchTimeout: time.Second,
})
case 1:
_ = NewSettings(&SSettings{
FServiceName: "TEST",
FFetchTimeout: time.Second,
})
case 2:
_ = NewSettings(&SSettings{
FServiceName: "TEST",
FNetworkMask: 1,
})
_ = NewSettings(&SSettings{})
}
}

Expand Down Expand Up @@ -694,7 +681,6 @@ func testNewNodeWithDB(timeWait time.Duration, addr string, db database.IKVDatab
node := NewNode(
NewSettings(&SSettings{
FServiceName: "TEST",
FNetworkMask: networkMask,
FFetchTimeout: timeWait,
}),
// internal_std_logger.NewStdLogger(&stLogging{}, internal_anon_logger.GetLogFunc()),
Expand Down
1 change: 0 additions & 1 deletion pkg/network/anonymity/examples/echo/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func newNode(serviceName, address string) anonymity.INode {
return anonymity.NewNode(
anonymity.NewSettings(&anonymity.SSettings{
FServiceName: serviceName,
FNetworkMask: networkMask,
FFetchTimeout: time.Minute,
}),
logger.NewLogger(
Expand Down
1 change: 0 additions & 1 deletion pkg/network/anonymity/examples/ping-pong/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func newNode(serviceName, address string) anonymity.INode {
return anonymity.NewNode(
anonymity.NewSettings(&anonymity.SSettings{
FServiceName: serviceName,
FNetworkMask: networkMask,
FFetchTimeout: time.Minute,
}),
logger.NewLogger(
Expand Down
12 changes: 0 additions & 12 deletions pkg/network/anonymity/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,17 @@ var (
type SSettings sSettings
type sSettings struct {
FServiceName string
FNetworkMask uint32
FFetchTimeout time.Duration
}

func NewSettings(pSett *SSettings) ISettings {
return (&sSettings{
FServiceName: pSett.FServiceName,
FNetworkMask: pSett.FNetworkMask,
FFetchTimeout: pSett.FFetchTimeout,
}).mustNotNull()
}

func (p *sSettings) mustNotNull() ISettings {
if p.FServiceName == "" {
panic(`p.FServiceName == ""`)
}
if p.FNetworkMask == 0 {
panic(`p.FNetworkMask == 0`)
}
if p.FFetchTimeout == 0 {
panic(`p.FFetchTimeout == 0`)
}
Expand All @@ -43,7 +35,3 @@ func (p *sSettings) GetServiceName() string {
func (p *sSettings) GetFetchTimeout() time.Duration {
return p.FFetchTimeout
}

func (p *sSettings) GetNetworkMask() uint32 {
return p.FNetworkMask
}
2 changes: 1 addition & 1 deletion test/result/badge_codelines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/result/badge_coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit af5c34b

Please sign in to comment.