From 113a4f9883fba5e12145cebc72c7ca884fad0d1a Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 4 Jul 2022 01:08:14 +0000 Subject: [PATCH] Automatic update on Mon Jul 4 01:08:14 UTC 2022 --- pkg/cothority/calypso/contracts.go | 12 ++++++++++++ .../personhood/contracts/contract_spawner_test.go | 2 ++ 2 files changed, 14 insertions(+) diff --git a/pkg/cothority/calypso/contracts.go b/pkg/cothority/calypso/contracts.go index ef5ba8d..6db158d 100644 --- a/pkg/cothority/calypso/contracts.go +++ b/pkg/cothority/calypso/contracts.go @@ -79,6 +79,18 @@ func (c ContractWrite) Spawn(rst byzcoin.ReadOnlyStateTrie, inst byzcoin.Instruc err = xerrors.Errorf("proof of write failed: %v", err) return } + var cid string + _, _, cid, _, err = rst.GetValues(c.Write.LTSID[:]) + if err != nil { + err = xerrors.Errorf("couldn't find the corresponding LTSID: %v", + err) + return + } + if cid != ContractLongTermSecretID { + err = xerrors.Errorf("given LTSID points to wrong contract: %s", + cid) + return + } instID, err := inst.DeriveIDArg("", "preID") if err != nil { return nil, nil, xerrors.Errorf( diff --git a/pkg/cothority/personhood/contracts/contract_spawner_test.go b/pkg/cothority/personhood/contracts/contract_spawner_test.go index d071005..f29d1e2 100644 --- a/pkg/cothority/personhood/contracts/contract_spawner_test.go +++ b/pkg/cothority/personhood/contracts/contract_spawner_test.go @@ -197,6 +197,8 @@ func TestContractSpawnerPreID(t *testing.T) { testPreID(t, sr, instCred, ca, null, false) ltsID := byzcoin.NewInstanceID(random.Bits(256, true, random.New())) + require.NoError(t, sr.CreateSCB(byzcoin.Create, + calypso.ContractLongTermSecretID, ltsID, nil, nil)) ltsKP := key.NewKeyPair(cothority.Suite) wr := calypso.NewWrite(cothority.Suite, ltsID, darc.ID{}, ltsKP.Public, []byte("key"))