Skip to content

Commit

Permalink
feedback + revert
Browse files Browse the repository at this point in the history
  • Loading branch information
oncilla committed Oct 1, 2019
1 parent 92b71be commit da3708b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions go/lib/ctrl/signed_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ type SignSrcDef struct {
}

func NewSignSrcDefFromRaw(b common.RawBytes) (SignSrcDef, error) {
s := reSrcDefault.FindSubmatch(b)
if len(s) == 0 {
match := reSrcDefault.FindSubmatch(b)
if len(match) == 0 {
return SignSrcDef{}, common.NewBasicError("Unable to match default src", nil,
"string", string(b))
}
ia, err := addr.IAFromString(string(s[1]))
ia, err := addr.IAFromString(string(match[1]))
if err != nil {
return SignSrcDef{}, common.NewBasicError("Unable to parse default src IA", err)
}
var chainVer, trcVer scrypto.Version
if err := chainVer.UnmarshalJSON(s[2]); err != nil {
if err := chainVer.UnmarshalJSON(match[2]); err != nil {
return SignSrcDef{}, common.NewBasicError("Unable to parse default src ChainVer", err)
}
if err := trcVer.UnmarshalJSON(s[3]); err != nil {
if err := trcVer.UnmarshalJSON(match[3]); err != nil {
return SignSrcDef{}, common.NewBasicError("Unable to parse default src TRCVer", err)
}
return SignSrcDef{IA: ia, ChainVer: chainVer, TRCVer: trcVer}, nil
Expand Down
11 changes: 6 additions & 5 deletions go/lib/infra/modules/trust/trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func TestStoreGetTRC(t *testing.T) {

ctx, cancelF := context.WithTimeout(context.Background(), testCtxTimeout)
defer cancelF()

trcObj, err := store.GetTRC(ctx, test.ISD, test.Version, infra.TRCOpts{})
test.ErrAssertion(t, err)
assert.Equal(t, test.ExpData, trcObj)
Expand Down Expand Up @@ -613,13 +614,13 @@ func loadCrypto(t *testing.T, isds []addr.ISD,
trcMap := make(map[addr.ISD]*trc.TRC)
for _, isd := range isds {
trcMap[isd], err = trc.TRCFromFile(getTRCFileName(isd, 1), false)
require.NoError(t, err)
xtest.FailOnErr(t, err)
}

chainMap := make(map[addr.IA]*cert.Chain)
for _, ia := range ias {
chainMap[ia], err = cert.ChainFromFile(getChainFileName(ia, 1), false)
require.NoError(t, err)
xtest.FailOnErr(t, err)
}
return trcMap, chainMap
}
Expand All @@ -638,7 +639,7 @@ func initStore(t *testing.T, ctrl *gomock.Controller,

t.Helper()
db, err := trustdbsqlite.New(":memory:")
require.NoError(t, err)
xtest.FailOnErr(t, err)
topo := topology.NewTopo()
topotestutil.AddServer(topo, proto.ServiceType_cs, "foo",
topology.TestTopoAddr(nil, nil, nil, nil))
Expand All @@ -657,12 +658,12 @@ func insertTRC(t *testing.T, store *Store, trcObj *trc.TRC) {
t.Helper()

_, err := store.trustdb.InsertTRC(context.Background(), trcObj)
require.NoError(t, err)
xtest.FailOnErr(t, err)
}

func insertChain(t *testing.T, store *Store, chain *cert.Chain) {
t.Helper()

_, err := store.trustdb.InsertChain(context.Background(), chain)
require.NoError(t, err)
xtest.FailOnErr(t, err)
}
5 changes: 3 additions & 2 deletions go/lib/infra/modules/trust/trustdb/trustdbsqlite/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@ func (db *executor) InsertChain(ctx context.Context, chain *cert.Chain) (int64,
return 0, err
}
ia, ver := chain.IAVer()
rowID, err := getIssCertRowIDCtx(ctx, db.db, chain.Issuer.Subject, chain.Issuer.Version)
rowId, err := getIssCertRowIDCtx(ctx, db.db, chain.Issuer.Subject, chain.Issuer.Version)
if err != nil {
return 0, err
}
// NOTE(roosd): Adding multiple rows to Chains table has to be done in a transaction.
res, err := db.db.ExecContext(ctx, insertChainStr, ia.I, ia.A, ver, 1, rowID)
res, err := db.db.ExecContext(ctx, insertChainStr, ia.I, ia.A, ver, 1, rowId)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -675,6 +675,7 @@ func insertIssCert(ctx context.Context, db db.Sqler, crt *cert.Certificate) (int

func parseCert(raw common.RawBytes, ia addr.IA, version scrypto.Version,
err error) (*cert.Certificate, error) {

if err == sql.ErrNoRows {
return nil, nil
}
Expand Down

0 comments on commit da3708b

Please sign in to comment.