Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
asabya committed Oct 23, 2024
1 parent 8dd0f0f commit c74d0a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
9 changes: 5 additions & 4 deletions pkg/act/act_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func TestACT(t *testing.T) {
if err != nil {
t.Fatal(err)
}
<-time.After(1 * time.Second)
}
}
list, err := ownerACT.GetList()
Expand Down Expand Up @@ -253,7 +254,7 @@ func TestACT(t *testing.T) {
pod1 := pod.NewPod(mockClient, fd, ownerAcc, tm, sm, -1, 0, logger)
ownerACT := NewACT(mockClient, fd, ownerAcc, tm, logger)
granteeAcc := accounts[1]
_, err := ownerACT.CreateUpdateACT(acts[0], granteeAcc.GetUserAccountInfo().GetPublicKey(), nil)
_, err := ownerACT.CreateUpdateACT(acts[1], granteeAcc.GetUserAccountInfo().GetPublicKey(), nil)
if err != nil {
t.Fatal(err)
}
Expand All @@ -273,18 +274,18 @@ func TestACT(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = ownerACT.GrantAccess(acts[0], reference)
_, err = ownerACT.GrantAccess(acts[1], reference)
if err != nil {
t.Fatal(err)
}
<-time.After(1 * time.Second)
}
contents, err := ownerACT.GetContentList(acts[0])
contents, err := ownerACT.GetContentList(acts[1])
if err != nil {
t.Fatal(err)
}
if len(contents) != 9 {
t.Fatal("contents not matching")
t.Fatal("contents not matching", len(contents))
}

})
Expand Down
19 changes: 3 additions & 16 deletions pkg/act/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ func (t *ACT) SaveGrantedPod(actName string, c *Content) error {
return err
}
// check if act with name already exists
act, ok := list[actName]
_, ok := list[actName]
if ok {
return ErrACTAlreadyExists
}
reference, err := swarm.ParseHexAddress(c.Reference)
if err != nil {
return err
}
act = &Act{
a := &Act{
Name: actName,
CreatedAt: c.AddedAt,
HistoryRef: swarm.ZeroAddress,
GranteesRef: reference,
Content: []*Content{c},
}
list[actName] = act
list[actName] = a
return t.storeUserACTs(list)
}

Expand Down Expand Up @@ -173,19 +173,6 @@ func encodeKey(key *ecdsa.PublicKey) (string, error) {
return hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(key)), nil
}

func parseKeys(list []string) ([]*ecdsa.PublicKey, error) {
parsedList := make([]*ecdsa.PublicKey, 0, len(list))
for _, g := range list {
h, err := parseKey(g)
if err != nil {
return []*ecdsa.PublicKey{}, err
}
parsedList = append(parsedList, h)
}

return parsedList, nil
}

func parseKey(g string) (*ecdsa.PublicKey, error) {
h, err := hex.DecodeString(g)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/act/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (t *ACT) CreateUpdateACT(actName string, publicKeyGrant, publicKeyRevoke *e

var (
resp = &api.GranteesPostResponse{}
grantList = []*ecdsa.PublicKey{}
revokeList = []*ecdsa.PublicKey{}
grantList []*ecdsa.PublicKey
revokeList []*ecdsa.PublicKey
owner = t.acc.GetUserAccountInfo().GetAddress()
topic = fmt.Sprintf("%s-%s", actName, owner.String())
topicBytes = utils.HashString(topic)
Expand All @@ -88,7 +88,6 @@ func (t *ACT) CreateUpdateACT(actName string, publicKeyGrant, publicKeyRevoke *e
if err != nil {
return nil, err
}

err = t.fd.CreateFeed(owner, topicBytes, resp.HistoryReference.Bytes(), nil)
if err != nil {
return nil, err
Expand All @@ -107,6 +106,7 @@ func (t *ACT) CreateUpdateACT(actName string, publicKeyGrant, publicKeyRevoke *e
} else {
revokeList = nil
}

resp, err = t.act.RevokeGrant(context.Background(), act.GranteesRef, act.HistoryRef, grantList, revokeList)
if err != nil {
return nil, err
Expand Down

0 comments on commit c74d0a6

Please sign in to comment.