From 7affd6f488cdb83e0b83ec0a0a3ee807b55b7509 Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Mon, 5 Sep 2022 14:32:29 +0100 Subject: [PATCH] fix for flaky payloadManager test --- server/payload_manager_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/payload_manager_test.go b/server/payload_manager_test.go index 016363895..c95bce723 100644 --- a/server/payload_manager_test.go +++ b/server/payload_manager_test.go @@ -1,6 +1,7 @@ package server import ( + "bytes" "crypto/sha256" "fmt" "io/ioutil" @@ -186,7 +187,14 @@ func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_MarshalToProtobuf() { h := sha256.New() h.Write(pb) - pms.Require().Exactly([]byte{0x70, 0xf2, 0xe5, 0x37, 0xff, 0x7d, 0x2d, 0x7b, 0x8a, 0x4b, 0x53, 0x1f, 0xfe, 0x3e, 0xea, 0x5e, 0x4d, 0xe1, 0xad, 0x44, 0xe8, 0x22, 0x5c, 0x84, 0x30, 0xd6, 0x75, 0x1a, 0xbd, 0x53, 0x59, 0xce}, h.Sum(nil)) + hashA := []byte{0x70, 0xf2, 0xe5, 0x37, 0xff, 0x7d, 0x2d, 0x7b, 0x8a, 0x4b, 0x53, 0x1f, 0xfe, 0x3e, 0xea, 0x5e, 0x4d, 0xe1, 0xad, 0x44, 0xe8, 0x22, 0x5c, 0x84, 0x30, 0xd6, 0x75, 0x1a, 0xbd, 0x53, 0x59, 0xce} + hashB := []byte{0xeb, 0xb7, 0x34, 0x94, 0x1d, 0x8d, 0x88, 0xdf, 0xa2, 0xfa, 0xc2, 0x9e, 0x11, 0xba, 0xa5, 0xc5, 0x95, 0x51, 0x73, 0xb, 0x9a, 0xb1, 0x92, 0xf9, 0xa2, 0x55, 0x5f, 0x50, 0x81, 0xe2, 0xf9, 0x46} + + // Because file-walk will pull files in an unpredictable order from a target dir + // there are 2 potential valid hashes, because there are 2 key files in the test dir + if bytes.Compare(hashA, h.Sum(nil)) != 0 { + pms.Require().Exactly(hashB, h.Sum(nil)) + } } func (pms *PayloadMarshallerSuite) TestPayloadMarshaller_UnmarshalProtobuf() {