X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/a2ef262a164fc735b9b8471ac0c8001eea2b9bf6..dd88b8567d1377f50ab6955f6a30db830d94ebd9:/hotline/server_blackbox_test.go diff --git a/hotline/server_blackbox_test.go b/hotline/server_blackbox_test.go index 06e7771..888ca3f 100644 --- a/hotline/server_blackbox_test.go +++ b/hotline/server_blackbox_test.go @@ -25,23 +25,23 @@ func assertTransferBytesEqual(t *testing.T, wantHexDump string, got []byte) bool return true } - var clean []byte - clean = append(clean, got[:92]...) // keep the first 92 bytes - clean = append(clean, make([]byte, 16)...) // replace the next 16 bytes for create/modify timestamps - clean = append(clean, got[108:]...) // keep the rest - + clean := slices.Concat( + got[:92], + make([]byte, 16), + got[108:], + ) return assert.Equal(t, wantHexDump, hex.Dump(clean)) } var tranSortFunc = func(a, b Transaction) int { return cmp.Compare( - binary.BigEndian.Uint16(a.clientID[:]), - binary.BigEndian.Uint16(b.clientID[:]), + binary.BigEndian.Uint16(a.ClientID[:]), + binary.BigEndian.Uint16(b.ClientID[:]), ) } -// tranAssertEqual compares equality of transactions slices after stripping out the random transaction ID -func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool { +// TranAssertEqual compares equality of transactions slices after stripping out the random transaction Type +func TranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool { var newT1 []Transaction var newT2 []Transaction @@ -49,12 +49,13 @@ func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool { trans.ID = [4]byte{0, 0, 0, 0} var fs []Field for _, field := range trans.Fields { - if field.ID == [2]byte{0x00, 0x6b} { // FieldRefNum + if field.Type == FieldRefNum { // FieldRefNum continue } - if field.ID == [2]byte{0x00, 0x72} { // FieldChatID + if field.Type == FieldChatID { // FieldChatID continue } + fs = append(fs, field) } trans.Fields = fs @@ -65,12 +66,13 @@ func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool { trans.ID = [4]byte{0, 0, 0, 0} var fs []Field for _, field := range trans.Fields { - if field.ID == [2]byte{0x00, 0x6b} { // FieldRefNum + if field.Type == FieldRefNum { // FieldRefNum continue } - if field.ID == [2]byte{0x00, 0x72} { // FieldChatID + if field.Type == FieldChatID { // FieldChatID continue } + fs = append(fs, field) } trans.Fields = fs