Skip to content

Commit

Permalink
feat(act): test patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferenc Sárai committed Jul 26, 2024
1 parent a79b609 commit 39cb6d1
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions pkg/check/act/act.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: &timestamp})
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: &timestamp})
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")

Expand Down Expand Up @@ -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: &timestamp})
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
Expand Down

0 comments on commit 39cb6d1

Please sign in to comment.