Skip to content

Commit

Permalink
use t.Run in broadcastclient tests
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Nov 18, 2024
1 parent fb5886e commit ed39624
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions broadcastclient/broadcastclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,30 @@ import (
"github.com/offchainlabs/nitro/wsbroadcastserver"
)

func TestReceiveMessagesWithoutCompression(t *testing.T) {
func TestReceiveMessages(t *testing.T) {
t.Parallel()
testReceiveMessages(t, false, false, false, false)
}

func TestReceiveMessagesWithCompression(t *testing.T) {
t.Parallel()
testReceiveMessages(t, true, true, false, false)
}

func TestReceiveMessagesWithServerOptionalCompression(t *testing.T) {
t.Parallel()
testReceiveMessages(t, true, true, false, false)
}

func TestReceiveMessagesWithServerOnlyCompression(t *testing.T) {
t.Parallel()
testReceiveMessages(t, false, true, false, false)
}

func TestReceiveMessagesWithClientOnlyCompression(t *testing.T) {
t.Parallel()
testReceiveMessages(t, true, false, false, false)
}

func TestReceiveMessagesWithRequiredCompression(t *testing.T) {
t.Parallel()
testReceiveMessages(t, true, true, true, false)
}

func TestReceiveMessagesWithRequiredCompressionButClientDisabled(t *testing.T) {
t.Parallel()
testReceiveMessages(t, false, true, true, true)
t.Run("withoutCompression", func(t *testing.T) {
testReceiveMessages(t, false, false, false, false)
})
t.Run("withServerOptionalCompression", func(t *testing.T) {
testReceiveMessages(t, true, true, false, false)
})
t.Run("withServerOnlyCompression", func(t *testing.T) {
testReceiveMessages(t, false, true, false, false)
})
t.Run("withClientOnlyCompression", func(t *testing.T) {
testReceiveMessages(t, true, false, false, false)
})
t.Run("withRequiredCompression", func(t *testing.T) {
testReceiveMessages(t, true, true, true, false)
})
t.Run("withRequiredCompressionButClientDisabled", func(t *testing.T) {
testReceiveMessages(t, false, true, true, true)
})
}

func testReceiveMessages(t *testing.T, clientCompression bool, serverCompression bool, serverRequire bool, expectNoMessagesReceived bool) {
t.Helper()
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down

0 comments on commit ed39624

Please sign in to comment.