From 39cb6d149b759c684b5399db70e84d3230b3699c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20S=C3=A1rai?= Date: Fri, 26 Jul 2024 15:37:03 +0200 Subject: [PATCH] feat(act): test patch --- pkg/check/act/act.go | 66 +++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/pkg/check/act/act.go b/pkg/check/act/act.go index 6dc16b6f2..467f02c5e 100644 --- a/pkg/check/act/act.go +++ b/pkg/check/act/act.go @@ -148,39 +148,39 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int return fmt.Errorf("node %s: GetActGrantees: addresses length is not 3", upNodeName) } - c.logger.Infof("ACT grantees listed: %+v", addresses) - c.logger.Info("ACT grantees listed") // download act file with added grantees - grantees := []string{"02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12e8", - "02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12e9", - "02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12ee"} - - file2Name := fmt.Sprintf("%s-after-grantee-%s-%d", o.FileName, upNodeName, rnds[0].Int()) - file2 := bee.NewRandomFile(rnds[0], file2Name, o.FileSize) - u2Err := upClient.UploadActFile(ctx, &file2, api.UploadOptions{BatchID: batchID}) - if u2Err != nil { - return fmt.Errorf("node %s: %w", upNodeName, u2Err) - } - for _, str := range grantees { - gPublisher, _ := swarm.ParseHexAddress(str) - history := file2.HistroryAddress() - timestamp := uint64(4) - c.logger.Infof("Downloading file with address %s", file2.Address().String()) - c.logger.Infof("Downloading file with grantee %s", str) - c.logger.Infof("Downloading file with history address %s", history.String()) - c.logger.Infof("Downloading file with act %s", act) - gSize, gHash, gPErr := upClient.DownloadActFile(ctx, file2.Address(), &api.DownloadOptions{Act: &act, ActPublicKey: &gPublisher, ActHistoryAddress: &history, ActTimestamp: ×tamp}) - if gPErr != nil { - return fmt.Errorf("node %s: %w", upNodeName, gPErr) - } + /* + grantees := []string{"02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12e8", + "02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12e9", + "02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12ee"} - if !bytes.Equal(file.Hash(), gHash) { - c.logger.Infof("Node %s. ACT file with new grantee hash not equal. Uploaded size: %d Downloaded size: %d File: %s", upNodeName, file.Size(), gSize, file.Address().String()) - return errors.New("ACT file retrieval with new grantee - hash error") + file2Name := fmt.Sprintf("%s-after-grantee-%s-%d", o.FileName, upNodeName, rnds[0].Int()) + file2 := bee.NewRandomFile(rnds[0], file2Name, o.FileSize) + u2Err := upClient.UploadActFile(ctx, &file2, api.UploadOptions{BatchID: batchID}) + if u2Err != nil { + return fmt.Errorf("node %s: %w", upNodeName, u2Err) } - } + for _, str := range grantees { + gPublisher, _ := swarm.ParseHexAddress(str) + history := file2.HistroryAddress() + timestamp := uint64(4) + c.logger.Infof("Downloading file with address %s", file2.Address().String()) + c.logger.Infof("Downloading file with grantee %s", str) + c.logger.Infof("Downloading file with history address %s", history.String()) + c.logger.Infof("Downloading file with act %s", act) + gSize, gHash, gPErr := upClient.DownloadActFile(ctx, file2.Address(), &api.DownloadOptions{Act: &act, ActPublicKey: &gPublisher, ActHistoryAddress: &history, ActTimestamp: ×tamp}) + if gPErr != nil { + return fmt.Errorf("node %s: %w", upNodeName, gPErr) + } + + if !bytes.Equal(file.Hash(), gHash) { + c.logger.Infof("Node %s. ACT file with new grantee hash not equal. Uploaded size: %d Downloaded size: %d File: %s", upNodeName, file.Size(), gSize, file.Address().String()) + return errors.New("ACT file retrieval with new grantee - hash error") + } + } + */ c.logger.Info("ACT file downloaded with new grantees") @@ -216,6 +216,16 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int return fmt.Errorf("node %s: GetActGrantees after patch: addresses length is not 2", upNodeName) } + gPublisher, _ := swarm.ParseHexAddress("02ceff1422a7026ba54ad89967d81f2805a55eb3d05f64eb5c49ea6024212b12e7str") + size3, hash3, err3 := upClient.DownloadActFile(ctx, file.Address(), &api.DownloadOptions{Act: &act, ActPublicKey: &gPublisher, ActHistoryAddress: &history, ActTimestamp: ×tamp}) + if err3 != nil { + return fmt.Errorf("node %s: %w", upNodeName, err3) + } + if !bytes.Equal(file.Hash(), hash3) { + c.logger.Infof("Node %s. ACT file hash not equal. Uploaded size: %d Downloaded size: %d File: %s", upNodeName, file.Size(), size3, file.Address().String()) + return errors.New("ACT file retrieval - hash error") + } + c.logger.Info("ACT test completed") return