@@ -297,9 +297,8 @@ func TestProofEncodingGroupKeyRevealV1(t *testing.T) {
297297 require .NoError (t , err )
298298 proof .AdditionalInputs = []File {* file , * file }
299299
300- var proofBuf bytes.Buffer
301- require .NoError (t , proof .Encode (& proofBuf ))
302- proofBytes := proofBuf .Bytes ()
300+ proofBytes , err := proof .Bytes ()
301+ require .NoError (t , err )
303302
304303 var decodedProof Proof
305304 require .NoError (
@@ -324,9 +323,8 @@ func TestProofEncoding(t *testing.T) {
324323 require .NoError (t , err )
325324 proof .AdditionalInputs = []File {* file , * file }
326325
327- var proofBuf bytes.Buffer
328- require .NoError (t , proof .Encode (& proofBuf ))
329- proofBytes := proofBuf .Bytes ()
326+ proofBytes , err := proof .Bytes ()
327+ require .NoError (t , err )
330328
331329 var decodedProof Proof
332330 require .NoError (t , decodedProof .Decode (bytes .NewReader (proofBytes )))
@@ -363,7 +361,7 @@ func TestProofEncoding(t *testing.T) {
363361 require .NoError (t , err )
364362 proof .AdditionalInputs = []File {* file , * file }
365363
366- proofBuf . Reset ()
364+ var proofBuf bytes. Buffer
367365 require .NoError (t , proof .Encode (& proofBuf ))
368366 var decodedProof2 Proof
369367 require .NoError (t , decodedProof2 .Decode (& proofBuf ))
@@ -821,8 +819,7 @@ func TestGenesisProofVerification(t *testing.T) {
821819 )
822820 require .ErrorIs (t , err , tc .expectedErr )
823821
824- var buf bytes.Buffer
825- err = genesisProof .Encode (& buf )
822+ genesisProofBytes , err := genesisProof .Bytes ()
826823 require .NoError (tt , err )
827824
828825 if tc .expectedErr == nil {
@@ -833,7 +830,7 @@ func TestGenesisProofVerification(t *testing.T) {
833830 t , & genesisProof ,
834831 ),
835832 Expected : hex .EncodeToString (
836- buf . Bytes () ,
833+ genesisProofBytes ,
837834 ),
838835 Comment : tc .name ,
839836 },
@@ -1233,12 +1230,11 @@ func runBIPTestVector(t *testing.T, testVectors *TestVectors) {
12331230
12341231 p := validCase .Proof .ToProof (tt )
12351232
1236- var buf bytes.Buffer
1237- err := p .Encode (& buf )
1233+ proofBytes , err := p .Bytes ()
12381234 require .NoError (tt , err )
12391235
12401236 areEqual := validCase .Expected == hex .EncodeToString (
1241- buf . Bytes () ,
1237+ proofBytes ,
12421238 )
12431239
12441240 // Make sure the proof in the test vectors doesn't use
@@ -1302,7 +1298,7 @@ func runBIPTestVector(t *testing.T, testVectors *TestVectors) {
13021298 // Make sure we still fail the test.
13031299 require .Equal (
13041300 tt , validCase .Expected ,
1305- hex .EncodeToString (buf . Bytes () ),
1301+ hex .EncodeToString (proofBytes ),
13061302 )
13071303 }
13081304
@@ -1453,11 +1449,10 @@ func TestProofUnknownOddType(t *testing.T) {
14531449 // The proof should've changed, to make sure the unknown
14541450 // value was taken into account when creating the
14551451 // serialized proof.
1456- var newBuf bytes.Buffer
1457- err := parsedProof .Encode (& newBuf )
1452+ parsedProofBytes , err := parsedProof .Bytes ()
14581453 require .NoError (t , err )
14591454
1460- require .NotEqual (t , knownProofBytes , newBuf . Bytes () )
1455+ require .NotEqual (t , knownProofBytes , parsedProofBytes )
14611456
14621457 parsedProof .UnknownOddTypes = nil
14631458 require .Equal (t , & knownProof , parsedProof )
0 commit comments