forked from quic-go/quic-go
rename the KeyPhase to KeyPhaseBit
This commit is contained in:
22
internal/protocol/key_phase.go
Normal file
22
internal/protocol/key_phase.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package protocol
|
||||
|
||||
// KeyPhaseBit is the key phase bit
|
||||
type KeyPhaseBit bool
|
||||
|
||||
const (
|
||||
// KeyPhaseZero is key phase 0
|
||||
KeyPhaseZero KeyPhaseBit = false
|
||||
// KeyPhaseOne is key phase 1
|
||||
KeyPhaseOne KeyPhaseBit = true
|
||||
)
|
||||
|
||||
func (p KeyPhaseBit) String() string {
|
||||
if p == KeyPhaseZero {
|
||||
return "0"
|
||||
}
|
||||
return "1"
|
||||
}
|
||||
|
||||
func (p KeyPhaseBit) Next() KeyPhaseBit {
|
||||
return !p
|
||||
}
|
||||
18
internal/protocol/key_phase_test.go
Normal file
18
internal/protocol/key_phase_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Key Phases", func() {
|
||||
It("has the correct string representation", func() {
|
||||
Expect(KeyPhaseZero.String()).To(Equal("0"))
|
||||
Expect(KeyPhaseOne.String()).To(Equal("1"))
|
||||
})
|
||||
|
||||
It("returns the next key phase", func() {
|
||||
Expect(KeyPhaseZero.Next()).To(Equal(KeyPhaseOne))
|
||||
Expect(KeyPhaseOne.Next()).To(Equal(KeyPhaseZero))
|
||||
})
|
||||
})
|
||||
@@ -34,27 +34,6 @@ func (t PacketType) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// KeyPhase is the key phase
|
||||
type KeyPhase bool
|
||||
|
||||
const (
|
||||
// KeyPhaseZero is key phase 0
|
||||
KeyPhaseZero KeyPhase = false
|
||||
// KeyPhaseOne is key phase 1
|
||||
KeyPhaseOne KeyPhase = true
|
||||
)
|
||||
|
||||
func (p KeyPhase) String() string {
|
||||
if p == KeyPhaseZero {
|
||||
return "0"
|
||||
}
|
||||
return "1"
|
||||
}
|
||||
|
||||
func (p KeyPhase) Next() KeyPhase {
|
||||
return !p
|
||||
}
|
||||
|
||||
// A ByteCount in QUIC
|
||||
type ByteCount uint64
|
||||
|
||||
|
||||
@@ -15,16 +15,4 @@ var _ = Describe("Protocol", func() {
|
||||
Expect(PacketType(10).String()).To(Equal("unknown packet type: 10"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("Key Phases", func() {
|
||||
It("has the correct string representation", func() {
|
||||
Expect(KeyPhaseZero.String()).To(Equal("0"))
|
||||
Expect(KeyPhaseOne.String()).To(Equal("1"))
|
||||
})
|
||||
|
||||
It("returns the next key phase", func() {
|
||||
Expect(KeyPhaseZero.Next()).To(Equal(KeyPhaseOne))
|
||||
Expect(KeyPhaseOne.Next()).To(Equal(KeyPhaseZero))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user