Skip to content

Commit

Permalink
fix: go vet and checkstatic issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chenchanglew committed Jan 31, 2024
1 parent 2f21f97 commit 17fca80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions samples/chaincode/secret-keeper-go/chaincode/secret-keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ func (t *SecretKeeper) AddUser(ctx contractapi.TransactionContextInterface, sig
if err != nil {
return err
}
if valid != true {
return fmt.Errorf("User are not allowed to perform this action.")
if !valid {
return fmt.Errorf("user are not allowed to perform this action")
}

// update the value
authSet, err := GetAuthList(ctx)
authSet, _ := GetAuthList(ctx)
authSet.Pubkey[pubkey] = struct{}{}

authSetJson, err := json.Marshal(authSet)
Expand All @@ -99,12 +99,12 @@ func (t *SecretKeeper) RemoveUser(ctx contractapi.TransactionContextInterface, s
if err != nil {
return err
}
if valid != true {
return fmt.Errorf("User are not allowed to perform this action.")
if !valid {
return fmt.Errorf("user are not allowed to perform this action")
}

// update the value
authSet, err := GetAuthList(ctx)
authSet, _ := GetAuthList(ctx)
delete(authSet.Pubkey, pubkey)

authSetJson, err := json.Marshal(authSet)
Expand All @@ -126,8 +126,8 @@ func (t *SecretKeeper) LockSecret(ctx contractapi.TransactionContextInterface, s
if err != nil {
return err
}
if valid != true {
return fmt.Errorf("User are not allowed to perform this action.")
if !valid {
return fmt.Errorf("user are not allowed to perform this action")
}

// update the value
Expand All @@ -154,8 +154,8 @@ func (t *SecretKeeper) RevealSecret(ctx contractapi.TransactionContextInterface,
if err != nil {
return nil, err
}
if valid != true {
return nil, fmt.Errorf("User are not allowed to perform this action.")
if !valid {
return nil, fmt.Errorf("user are not allowed to perform this action")
}

// reveal secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestNormalBehavior(t *testing.T) {
require.NoError(t, err)

_, authSetByte := chaincodeStub.PutStateArgsForCall(0)
_, secretByte := chaincodeStub.PutStateArgsForCall(1)
_, _ = chaincodeStub.PutStateArgsForCall(1)

aliceSig := "Alice"
bobSig := "Bob"
Expand All @@ -189,7 +189,7 @@ func TestNormalBehavior(t *testing.T) {
chaincodeStub.GetStateReturnsOnCall(2, authSetByte, nil)
err = secretKeeper.LockSecret(transactionContext, eveSig, newSecret)
require.NoError(t, err)
_, secretByte = chaincodeStub.PutStateArgsForCall(3)
_, secretByte := chaincodeStub.PutStateArgsForCall(3)

chaincodeStub.GetStateReturnsOnCall(3, authSetByte, nil)
chaincodeStub.GetStateReturnsOnCall(4, secretByte, nil)
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestRollbackAttack(t *testing.T) {
require.NoError(t, err)

_, authSetByte := chaincodeStub.PutStateArgsForCall(0)
_, secretByte := chaincodeStub.PutStateArgsForCall(1)
_, _ = chaincodeStub.PutStateArgsForCall(1)
oldauthSetByte := authSetByte

aliceSig := "Alice"
Expand All @@ -243,7 +243,7 @@ func TestRollbackAttack(t *testing.T) {
chaincodeStub.GetStateReturnsOnCall(2, authSetByte, nil)
err = secretKeeper.LockSecret(transactionContext, eveSig, newSecret)
require.NoError(t, err)
_, secretByte = chaincodeStub.PutStateArgsForCall(3)
_, secretByte := chaincodeStub.PutStateArgsForCall(3)

chaincodeStub.GetStateReturnsOnCall(3, authSetByte, nil)
chaincodeStub.GetStateReturnsOnCall(4, secretByte, nil)
Expand Down

0 comments on commit 17fca80

Please sign in to comment.