gitee.com/zhaochuninhefei/fabric-ca-gm@v0.0.2/lib/server/idemix/ra_whitebox_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package idemix 8 9 import ( 10 "testing" 11 12 "gitee.com/zhaochuninhefei/fabric-ca-gm/internal/pkg/util" 13 "gitee.com/zhaochuninhefei/fabric-ca-gm/lib/server/db" 14 "gitee.com/zhaochuninhefei/fabric-gm/idemix" 15 fp256bn "github.com/hyperledger/fabric-amcl/amcl/FP256BN" 16 "github.com/stretchr/testify/assert" 17 ) 18 19 func TestGetUnRevokedHandles(t *testing.T) { 20 ra := &revocationAuthority{issuer: &issuer{name: "ca1", homeDir: ".", cfg: &Config{}}} 21 info := &RevocationAuthorityInfo{ 22 Epoch: 1, 23 LastHandleInPool: 100, 24 NextRevocationHandle: 2, 25 } 26 27 revokedCred := CredRecord{ 28 RevocationHandle: "10", 29 } 30 revokedCreds := []CredRecord{revokedCred} 31 unrevokedHandles := ra.getUnRevokedHandles(info, revokedCreds) 32 assert.Equal(t, 100, len(unrevokedHandles)) 33 34 revokedCred = CredRecord{ 35 RevocationHandle: util.B64Encode(idemix.BigToBytes(fp256bn.NewBIGint(10))), 36 } 37 revokedCreds = []CredRecord{revokedCred} 38 unrevokedHandles = ra.getUnRevokedHandles(info, revokedCreds) 39 assert.Equal(t, 99, len(unrevokedHandles)) 40 } 41 42 func TestDoTransactionNilDB(t *testing.T) { 43 f := func(tx db.FabricCATx, args ...interface{}) (interface{}, error) { 44 return nil, nil 45 } 46 _, err := doTransaction("", nil, f) 47 assert.Error(t, err) 48 }