Skip to content

Commit bde1ed9

Browse files
committed
Use gofmt -s to help simplify many statements
1 parent ba0b4c6 commit bde1ed9

9 files changed

+39
-39
lines changed

Diff for: bytes_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import "testing"
44

55
func Test_FragmentedMessage_canBeConvertedToSliceOfByteSlices(t *testing.T) {
66
fragmented := []ValidMessage{
7-
ValidMessage{0x01, 0x02},
8-
ValidMessage{0x03, 0x04},
9-
ValidMessage{0x05, 0x06},
7+
{0x01, 0x02},
8+
{0x03, 0x04},
9+
{0x05, 0x06},
1010
}
1111

1212
assertDeepEquals(t, Bytes(fragmented), [][]byte{
13-
[]byte{0x01, 0x02},
14-
[]byte{0x03, 0x04},
15-
[]byte{0x05, 0x06},
13+
{0x01, 0x02},
14+
{0x03, 0x04},
15+
{0x05, 0x06},
1616
})
1717
}

Diff for: conversation.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c *Conversation) End() (toSend []ValidMessage, err error) {
116116
if c.msgState == encrypted {
117117
c.smp.wipe()
118118
// Error can only happen when Rand reader is broken
119-
toSend, _, err = c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{tlv{tlvType: tlvTypeDisconnected}})
119+
toSend, _, err = c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{{tlvType: tlvTypeDisconnected}})
120120
}
121121
c.lastMessageStateChange = time.Time{}
122122
c.ake = nil

Diff for: conversation_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func Test_End_whenStateIsEncrypted(t *testing.T) {
299299

300300
stub := bobContextAfterAKE()
301301
stub.msgState = encrypted
302-
expectedMsg, _, err := stub.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{tlv{tlvType: tlvTypeDisconnected}})
302+
expectedMsg, _, err := stub.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{{tlvType: tlvTypeDisconnected}})
303303

304304
assertDeepEquals(t, err, nil)
305305
assertDeepEquals(t, bob.msgState, plainText)
@@ -360,7 +360,7 @@ func Test_End_wipesKeys(t *testing.T) {
360360
bob.msgState = encrypted
361361
_, _ = bob.End()
362362
stub := bobContextAfterAKE()
363-
_, _, _ = stub.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{tlv{tlvType: tlvTypeDisconnected}})
363+
_, _, _ = stub.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{{tlvType: tlvTypeDisconnected}})
364364

365365
assertDeepEquals(t, dhKeyPair{}, bob.keys.ourCurrentDHKeys)
366366
assertDeepEquals(t, dhKeyPair{}, bob.keys.ourPreviousDHKeys)

Diff for: data_message_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func Test_processTLVs_ignoresInvalidTLVMessageTypes(t *testing.T) {
1111
var nilT []tlv
1212
tlvs := []tlv{
1313
fixtureMessage1().tlv(),
14-
tlv{
14+
{
1515
tlvType: 9,
1616
tlvLength: 1,
1717
tlvValue: []byte{0x01},
@@ -105,7 +105,7 @@ func Test_genDataMsg_setsLastMessageWhenNewMessageIsPlaintext(t *testing.T) {
105105

106106
assertDeepEquals(t, c.resend.pending(),
107107
[]messageToResend{
108-
messageToResend{MessagePlaintext(msg), nil},
108+
{MessagePlaintext(msg), nil},
109109
})
110110
}
111111

@@ -122,8 +122,8 @@ func Test_genDataMsg_hasEncryptedMessage(t *testing.T) {
122122

123123
func Test_genDataMsg_revealOldMACKeysFromKeyManagementContext(t *testing.T) {
124124
oldMACKeys := []macKey{
125-
macKey{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
126-
macKey{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
125+
{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
126+
{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
127127
}
128128

129129
c := bobContextAfterAKE()

Diff for: key_management_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func Test_rotateOurKeys_doesNotRotateIfWeDontReceiveOurCurrentKeyID(t *testing.T
200200

201201
func Test_revealMACKeys_ForgotOldKeysAfterBeenCalled(t *testing.T) {
202202
oldMACKeys := []macKey{
203-
macKey{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
203+
{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
204204
}
205205
c := keyManagementContext{
206206
oldMACKeys: oldMACKeys,
@@ -227,9 +227,9 @@ func Test_rotateTheirKey_revealAllMACKeysAssociatedWithTheirPreviousPubKey(t *te
227227

228228
c.macKeyHistory = macKeyHistory{
229229
items: []macKeyUsage{
230-
macKeyUsage{theirKeyID: 1, receivingKey: k2},
231-
macKeyUsage{theirKeyID: 2, receivingKey: k1},
232-
macKeyUsage{theirKeyID: 1, receivingKey: k2},
230+
{theirKeyID: 1, receivingKey: k2},
231+
{theirKeyID: 2, receivingKey: k1},
232+
{theirKeyID: 1, receivingKey: k2},
233233
},
234234
}
235235

@@ -258,9 +258,9 @@ func Test_rotateOurKey_revealAllMACKeysAssociatedWithOurPreviousPubKey(t *testin
258258

259259
c.macKeyHistory = macKeyHistory{
260260
items: []macKeyUsage{
261-
macKeyUsage{ourKeyID: 1, receivingKey: k2},
262-
macKeyUsage{ourKeyID: 2, receivingKey: k1},
263-
macKeyUsage{ourKeyID: 1, receivingKey: k2},
261+
{ourKeyID: 1, receivingKey: k2},
262+
{ourKeyID: 2, receivingKey: k1},
263+
{ourKeyID: 1, receivingKey: k2},
264264
},
265265
}
266266

Diff for: messages_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func Test_dataMsgDeserialze(t *testing.T) {
120120

121121
authenticator := []byte{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03}
122122
oldMACKeys := []macKey{
123-
macKey{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
124-
macKey{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
123+
{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
124+
{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
125125
}
126126

127127
msg = append(msg, flag)
@@ -268,8 +268,8 @@ func Test_dataMsgDeserialzeErrorWhenCorruptedRevealMACKeys(t *testing.T) {
268268

269269
authenticator := []byte{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03}
270270
oldMACKeys := []macKey{
271-
macKey{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
272-
macKey{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
271+
{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
272+
{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
273273
}
274274

275275
msg = append(msg, flag)
@@ -307,8 +307,8 @@ func Test_dataMsgDeserialzeErrorWhenCorruptedRevealMACKeyEnding(t *testing.T) {
307307

308308
authenticator := []byte{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03}
309309
oldMACKeys := []macKey{
310-
macKey{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
311-
macKey{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
310+
{0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
311+
{0x01, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03},
312312
}
313313

314314
msg = append(msg, flag)

Diff for: query_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ func Test_receiveQueryMessage_returnsErrorIfDhCommitMessageGeneratesError(t *tes
141141

142142
func Test_parseOTRQueryMessage(t *testing.T) {
143143
var exp = map[string][]int{
144-
"?OTR?": []int{1},
145-
"?OTRv2?": []int{2},
146-
"?OTRv23?": []int{2, 3},
147-
"?OTR?v2": []int{1, 2},
148-
"?OTRv248?": []int{2, 4, 8},
149-
"?OTR?v?": []int{1},
150-
"?OTRv?": []int{},
144+
"?OTR?": {1},
145+
"?OTRv2?": {2},
146+
"?OTRv23?": {2, 3},
147+
"?OTR?v2": {1, 2},
148+
"?OTRv248?": {2, 4, 8},
149+
"?OTR?v?": {1},
150+
"?OTRv?": {},
151151
}
152152

153153
for queryMsg, versions := range exp {

Diff for: send_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func Test_Send_saveLastMessageWhenMsgIsPlainTextAndEncryptedIsExpected(t *testin
7979

8080
assertDeepEquals(t, c.resend.pending(),
8181
[]messageToResend{
82-
messageToResend{MessagePlaintext(m), nil},
82+
{MessagePlaintext(m), nil},
8383
})
8484
}
8585

@@ -95,8 +95,8 @@ func Test_Send_saveLastMessageWhenMsgIsPlainTextAndEncryptedIsExpected_AndAddsAn
9595

9696
assertDeepEquals(t, c.resend.pending(),
9797
[]messageToResend{
98-
messageToResend{MessagePlaintext(m), []interface{}{42, "hello"}},
99-
messageToResend{MessagePlaintext(m2), []interface{}{15, "something"}},
98+
{MessagePlaintext(m), []interface{}{42, "hello"}},
99+
{MessagePlaintext(m2), []interface{}{15, "something"}},
100100
})
101101
}
102102

Diff for: wipe_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ func Test_wipe_keyManagementContext(t *testing.T) {
5858
theirPreviousDHPubKey: big.NewInt(6),
5959
counterHistory: counterHistory{
6060
counters: []*keyPairCounter{
61-
&keyPairCounter{1, 1, 1, 1},
61+
{1, 1, 1, 1},
6262
},
6363
},
6464
macKeyHistory: macKeyHistory{
6565
items: []macKeyUsage{
66-
macKeyUsage{
66+
{
6767
ourKeyID: 2,
6868
theirKeyID: 3,
6969
receivingKey: macKey{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4},
7070
},
7171
},
7272
},
7373
oldMACKeys: []macKey{
74-
macKey{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5},
74+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 6, 5},
7575
},
7676
}
7777

0 commit comments

Comments
 (0)