diff --git a/go/lib/ctrl/signed_util.go b/go/lib/ctrl/signed_util.go index 04d591fd91..92fc03919a 100644 --- a/go/lib/ctrl/signed_util.go +++ b/go/lib/ctrl/signed_util.go @@ -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 diff --git a/go/lib/infra/modules/trust/trust_test.go b/go/lib/infra/modules/trust/trust_test.go index 61c722b9c1..a0290912fb 100644 --- a/go/lib/infra/modules/trust/trust_test.go +++ b/go/lib/infra/modules/trust/trust_test.go @@ -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) @@ -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 } @@ -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)) @@ -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) } diff --git a/go/lib/infra/modules/trust/trustdb/trustdbsqlite/db.go b/go/lib/infra/modules/trust/trustdb/trustdbsqlite/db.go index 0b0add686d..37d3f0f79f 100644 --- a/go/lib/infra/modules/trust/trustdb/trustdbsqlite/db.go +++ b/go/lib/infra/modules/trust/trustdb/trustdbsqlite/db.go @@ -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 } @@ -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 }