Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Oct 3, 2024
1 parent 53a284c commit df7f4e0
Show file tree
Hide file tree
Showing 13 changed files with 6,469 additions and 6,903 deletions.
5,708 changes: 2,854 additions & 2,854 deletions cmd/hidden_lake/_test/result/coverage.out

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions pkg/network/anonymity/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,9 @@ func TestPanicNewQBProblemProcessor(t *testing.T) {
func TestSettings(t *testing.T) {
t.Parallel()

for i := 0; i < 3; i++ {
for i := 0; i < 4; i++ {
testSettings(t, i)
}

defer func() {
if r := recover(); r == nil {
t.Error("nothing panics")
return
}
}()

// check FMessageConstructSettings
_ = (&sSettings{
FMainPoolCapacity: testutils.TCQueueCapacity,
FRandPoolCapacity: testutils.TCQueueCapacity,
FQueuePeriod: 500 * time.Millisecond,
}).mustNotNull()
}

func testSettings(t *testing.T, n int) {
Expand All @@ -91,19 +77,34 @@ func testSettings(t *testing.T, n int) {
switch n {
case 0:
_ = NewSettings(&SSettings{
FMessageConstructSettings: net_message.NewConstructSettings(&net_message.SConstructSettings{
FSettings: net_message.NewSettings(&net_message.SSettings{}),
}),
FRandPoolCapacity: testutils.TCQueueCapacity,
FQueuePeriod: 500 * time.Millisecond,
})
case 1:
_ = NewSettings(&SSettings{
FMessageConstructSettings: net_message.NewConstructSettings(&net_message.SConstructSettings{
FSettings: net_message.NewSettings(&net_message.SSettings{}),
}),
FMainPoolCapacity: testutils.TCQueueCapacity,
FQueuePeriod: 500 * time.Millisecond,
})
case 2:
_ = NewSettings(&SSettings{
FMessageConstructSettings: net_message.NewConstructSettings(&net_message.SConstructSettings{
FSettings: net_message.NewSettings(&net_message.SSettings{}),
}),
FMainPoolCapacity: testutils.TCQueueCapacity,
FRandPoolCapacity: testutils.TCQueueCapacity,
})
case 3:
_ = NewSettings(&SSettings{
FMainPoolCapacity: testutils.TCQueueCapacity,
FRandPoolCapacity: testutils.TCQueueCapacity,
FQueuePeriod: 500 * time.Millisecond,
})
}
}

Expand Down
25 changes: 6 additions & 19 deletions pkg/network/anonymity/queue/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ type sSettings struct {

func NewSettings(pSett *SSettings) ISettings {
return (&sSettings{
FMessageConstructSettings: func() net_message.IConstructSettings {
if pSett.FMessageConstructSettings == nil {
return net_message.NewConstructSettings(&net_message.SConstructSettings{})
}
return pSett.FMessageConstructSettings
}(),
FNetworkMask: pSett.FNetworkMask,
FMainPoolCapacity: pSett.FMainPoolCapacity,
FRandPoolCapacity: pSett.FRandPoolCapacity,
FQueuePeriod: pSett.FQueuePeriod,
FRandQueuePeriod: pSett.FRandQueuePeriod,
FMessageConstructSettings: pSett.FMessageConstructSettings,
FNetworkMask: pSett.FNetworkMask,
FMainPoolCapacity: pSett.FMainPoolCapacity,
FRandPoolCapacity: pSett.FRandPoolCapacity,
FQueuePeriod: pSett.FQueuePeriod,
FRandQueuePeriod: pSett.FRandQueuePeriod,
}).mustNotNull()
}

Expand All @@ -57,14 +52,6 @@ func (p *sSettings) GetMessageConstructSettings() net_message.IConstructSettings
return p.FMessageConstructSettings
}

func (p *sSettings) GetParallel() uint64 {
return p.FMessageConstructSettings.GetParallel()
}

func (p *sSettings) GetRandMessageSizeBytes() uint64 {
return p.FMessageConstructSettings.GetRandMessageSizeBytes()
}

func (p *sSettings) GetNetworkMask() uint32 {
return p.FNetworkMask
}
Expand Down
31 changes: 14 additions & 17 deletions pkg/network/conn/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,9 @@ func TestError(t *testing.T) {
func TestSettings(t *testing.T) {
t.Parallel()

for i := 0; i < 5; i++ {
for i := 0; i < 6; i++ {
testSettings(t, i)
}

defer func() {
if r := recover(); r == nil {
t.Error("nothing panics")
return
}
}()

// check FMessageSettings
_ = (&sSettings{
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
FReadTimeout: time.Minute,
FWriteTimeout: time.Minute,
}).mustNotNull()
}

func testSettings(t *testing.T, n int) {
Expand All @@ -105,39 +89,52 @@ func testSettings(t *testing.T, n int) {
switch n {
case 0:
_ = NewSettings(&SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
FReadTimeout: time.Minute,
FWriteTimeout: time.Minute,
})
case 1:
_ = NewSettings(&SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FDialTimeout: time.Minute,
FReadTimeout: time.Minute,
FWriteTimeout: time.Minute,
})
case 2:
_ = NewSettings(&SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
FWriteTimeout: time.Minute,
})
case 3:
_ = NewSettings(&SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
FReadTimeout: time.Minute,
})
case 4:
_ = NewSettings(&SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FReadTimeout: time.Minute,
FWriteTimeout: time.Minute,
})
case 5:
_ = NewSettings(&SSettings{
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
FReadTimeout: time.Minute,
FWriteTimeout: time.Minute,
})
}
}

Expand Down
7 changes: 1 addition & 6 deletions pkg/network/conn/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ type sSettings struct {

func NewSettings(pSett *SSettings) ISettings {
return (&sSettings{
FMessageSettings: func() net_message.ISettings {
if pSett.FMessageSettings == nil {
return net_message.NewSettings(&net_message.SSettings{})
}
return pSett.FMessageSettings
}(),
FMessageSettings: pSett.FMessageSettings,
FLimitMessageSizeBytes: pSett.FLimitMessageSizeBytes,
FWaitReadTimeout: pSett.FWaitReadTimeout,
FDialTimeout: pSett.FDialTimeout,
Expand Down
12 changes: 10 additions & 2 deletions pkg/network/message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,22 @@ func TestError(t *testing.T) {
func TestSettings(t *testing.T) {
t.Parallel()

for i := 0; i < 1; i++ {
testSettings(t, i)
}
}

func testSettings(t *testing.T, n int) {
defer func() {
if r := recover(); r == nil {
t.Error("nothing panics")
return
}
}()

_ = (&sConstructSettings{}).mustNotNull()
switch n { // nolint: gocritic
case 0:
_ = NewConstructSettings(&SConstructSettings{})
}
}

func TestMessage(t *testing.T) {
Expand Down
7 changes: 1 addition & 6 deletions pkg/network/message/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ type sSettings struct {

func NewConstructSettings(pSett *SConstructSettings) IConstructSettings {
return (&sConstructSettings{
FSettings: func() ISettings {
if pSett.FSettings == nil {
return NewSettings(&SSettings{})
}
return pSett.FSettings
}(),
FSettings: pSett.FSettings,
FParallel: pSett.FParallel,
FRandMessageSizeBytes: pSett.FRandMessageSizeBytes,
}).mustNotNull()
Expand Down
3 changes: 3 additions & 0 deletions pkg/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func testSettings(t *testing.T, n int) {
FReadTimeout: tcTimeWait,
FWriteTimeout: tcTimeWait,
FConnSettings: conn.NewSettings(&conn.SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
Expand All @@ -68,6 +69,7 @@ func testSettings(t *testing.T, n int) {
FMaxConnects: testutils.TCMaxConnects,
FWriteTimeout: tcTimeWait,
FConnSettings: conn.NewSettings(&conn.SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
Expand All @@ -81,6 +83,7 @@ func testSettings(t *testing.T, n int) {
FMaxConnects: testutils.TCMaxConnects,
FReadTimeout: tcTimeWait,
FConnSettings: conn.NewSettings(&conn.SSettings{
FMessageSettings: message.NewSettings(&message.SSettings{}),
FLimitMessageSizeBytes: testutils.TCMessageSize,
FWaitReadTimeout: time.Hour,
FDialTimeout: time.Minute,
Expand Down
10 changes: 5 additions & 5 deletions pkg/network/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ var (

type SSettings sSettings
type sSettings struct {
FConnSettings conn.ISettings
FAddress string
FMaxConnects uint64
FReadTimeout time.Duration
FWriteTimeout time.Duration
FConnSettings conn.ISettings
}

func NewSettings(pSett *SSettings) ISettings {
return (&sSettings{
FConnSettings: pSett.FConnSettings,
FAddress: pSett.FAddress,
FMaxConnects: pSett.FMaxConnects,
FReadTimeout: pSett.FReadTimeout,
FWriteTimeout: pSett.FWriteTimeout,
FConnSettings: pSett.FConnSettings,
}).mustNotNull()
}

func (p *sSettings) mustNotNull() ISettings {
if p.FConnSettings == nil {
panic(`p.FConnSettings == nil`)
}
if p.FMaxConnects == 0 {
panic(`p.FMaxConnects == 0`)
}
Expand All @@ -39,9 +42,6 @@ func (p *sSettings) mustNotNull() ISettings {
if p.FWriteTimeout == 0 {
panic(`p.FWriteTimeout == 0`)
}
if p.FConnSettings == nil {
panic(`p.FConnSettings == nil`)
}
return p
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/network/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type INode interface {
}

type ISettings interface {
GetConnSettings() conn.ISettings
GetAddress() string
GetMaxConnects() uint64
GetReadTimeout() time.Duration
GetWriteTimeout() time.Duration
GetConnSettings() conn.ISettings
}
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.
Loading

0 comments on commit df7f4e0

Please sign in to comment.