diff --git a/samples/chaincode/secret-keeper-go/chaincode/secret-keeper.go b/samples/chaincode/secret-keeper-go/chaincode/secret-keeper.go index 09a6a2b37..b4c38f5b6 100644 --- a/samples/chaincode/secret-keeper-go/chaincode/secret-keeper.go +++ b/samples/chaincode/secret-keeper-go/chaincode/secret-keeper.go @@ -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) @@ -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) @@ -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 @@ -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 diff --git a/samples/chaincode/secret-keeper-go/chaincode/secret-keeper_test.go b/samples/chaincode/secret-keeper-go/chaincode/secret-keeper_test.go index e56751aff..8f49e2d10 100644 --- a/samples/chaincode/secret-keeper-go/chaincode/secret-keeper_test.go +++ b/samples/chaincode/secret-keeper-go/chaincode/secret-keeper_test.go @@ -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" @@ -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) @@ -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" @@ -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)